PRTG IPsec tunnel monitor script

Showing results for 
Show  only  | Search instead for 
Did you mean: 
Please sign in to see details of an important advisory in our Customer Advisories area.

PRTG IPsec tunnel monitor script

L0 Member

We are using PRTG for network monitoring and need to have alerts created and sent when an IPsec tunnel goes down. i found some article for scripts to use with the advanced script sensor, but we run into issues when actually trying to run the script. it seems to just stop the connection and Powershell ISE shows an error for the line invoking the rest method.


Here is the script we are trying to use :
# Disable SSL certificate checking so we can connect to servers using a cert signed by a private CA
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = { $true }

#Set Powershell to use TLS1.2 when connecting to the Firewall
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12,

$VPNTunnelURI = @{uri = "https://(FW IP Address)/api/?type=op&cmd=<show><vpn><ipsec-sa><tunnel>(TUNNEL NAME)</tunnel></ipsec-sa></vpn></show>&key=(Key Removed)";
    "Method"  = 'GET';

#Set Powershell to use TLS1.2 when connecting to the Firewall
#[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls12

[xml]$VPNTunnelStateXML = Invoke-RestMethod @VPNTunnelURI

$VPNTunnelStateTest = $VPNTunnelStateXML.SelectSingleNode("//response/result/error")
If ($VPNTunnelStateTest -ne $null) {
    $VPNTunnelStateResult = 1
Else {
    $VPNTunnelStateResult = 0

Write-Output "STATE"
Write-Output $VPNTunnelStateTest
# XML Output for PRTG
Write-Host "<result>"

Write-Host "</prtg>"

This is a screen shot of the error we get when testing, upon research it looked like a TLS issue but this is with the script being forced to use TLS1.2 and we verified with wireshark it is connecting over TLS1.2

This is the error we are seeing when testing the scriptThis is the error we are seeing when testing the script


Looking for any help with the script or another possible method to be able to get tunnel down alerts with PRTG

  • 0 replies
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

Click Accept as Solution to acknowledge that the answer to your question has been provided.

The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!

These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!

The LIVEcommunity thanks you for your participation!