I am looking to monitor our software maintenance contract expiration dates in PRTG. Is there a way to set up some type of sensor that would monitor a date, similar to the SSL "Days to Expiration" channel? Maybe it would read a text file of some sort? Or, if someone has some other ideas. Maybe i'm overlooking something simple. Thansk!
Configure sensor to monitor a date
Votes:
0
6 Replies
Votes:
0
Votes:
0
You easily can do this with e.g. a VBscript - or PowerShell script.
E.g. this:
param( $AlertStartDate, #starting this date, the script will respond with an alarm state - format: yyyy-mm-dd or mm/dd/yyyy $StartWarningXdaysBefore #numeric, amount of days before the date to raise warning level ) $AlertLevel = 0; $AlertMessage = ""; $result = ""; try { $TimeSpan = New-TimeSpan -Start (Get-Date).ToString("yyyy-MM-dd") -End $AlertStartDate; if ($TimeSpan.Days -gt $StartWarningXdaysBefore) { $AlertMessage = "Green status - you have " + $TimeSpan.Days + " days left"; } elseif ($TimeSpan.Days -le $StartWarningXdaysBefore -and $TimeSpan.Days -gt 0) { $AlertMessage = "You have " + $TimeSpan.Days + " days left"; $AlertLevel = 1; } elseif ($TimeSpan.Days -le 0) { $AlertMessage = "Date reached or surpassed by " + $TimeSpan.Days + " days"; $AlertLevel = 2; } else { $AlertMessage = "Unknown value in calculation"; $AlertLevel = 4; } } catch { $AlertMessage = "Invalid date parameter or date format issue"; $AlertLevel = 3; } Function WriteXmlToScreen ([xml]$xml) #just to make it clean XML code... { $StringWriter = New-Object System.IO.StringWriter; $XmlWriter = New-Object System.Xml.XmlTextWriter $StringWriter; $XmlWriter.Formatting = "indented"; $xml.WriteTo($XmlWriter); $XmlWriter.Flush(); $StringWriter.Flush(); Write-Output $StringWriter.ToString(); } $PRTGstring="<prtg> <result> <channel>Alert Level</channel> <value>$AlertLevel</value> </result> <result> <channel>Days Left</channel> <value>" + $TimeSpan.Days + "</value> </result> <text>$AlertMessage</text> </prtg>" WriteXmlToScreen $PRTGstring
It's and advanced EXE sensor script - you can set the date as a parameter...
Regards
Florian Rossmark
Votes:
0
Hi there,
Thanks for your contribution Florian! :)
Best regards.
Votes:
0
Here is one more.
DaysUntil Number of days until the given end date.
Sensors |
Multi Channel Sensors |
Tools |
Notifications
Kind regards,
PRTGToolsFamily
Votes:
0
Hi Everyone, I have tried to apply the above EXE script, but the sensor gives a response as follows:
Response not well-formed: "(<prtg> <result> <channel>Alert Level</channel> <value>0</value> </result> <result> <channel>Days Left</channel> <value>104</value> </result> <text>Green status - you have 104 days left</text> </prtg> )" (code: PE132)
Any ideas??
Created on Aug 3, 2022 2:36:51 AM
Last change on Aug 3, 2022 6:30:44 AM by
Felix Wiesneth [Paessler Support]
Votes:
0
Most likely you have added this EXE sensor as an EXEXML sensor.
The sensor.exe needs to be copied to the '\Custom Sensors\EXE' folder of your PRTG installation and added as an 'Standard EXE/Script Sensor'
Please also see this part of the manual.
Sensors |
Multi Channel Sensors |
Tools |
Notifications
Kind regards,
PRTG Tools Family
Add comment