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!


Article Comments

Found a solution: https://helpdesk.paessler.com/en/support/solutions/articles/60478-how-can-i-monitor-licenses-in-my-network


Jan, 2019 - Permalink

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

www.it-admins.com


Jan, 2019 - Permalink

Hi there,

Thanks for your contribution Florian! :)

Best regards.


Jan, 2019 - Permalink

Here is one more.

DaysUntil Number of days until the given end date.


Sensors | Multi Channel Sensors | Tools | Notifications

Kind regards,

[[http://prtgtoolsfamily.com]] PRTGToolsFamily


Jan, 2019 - Permalink

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??


Aug, 2022 - Permalink

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,

[[https://prtgtoolsfamily.com]] PRTG Tools Family


Aug, 2022 - Permalink