What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Configure sensor to monitor a date

Votes:

0

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!

date monitoring prtg

Created on Jan 15, 2019 12:55:11 PM



6 Replies


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

www.it-admins.com

Created on Jan 15, 2019 3:52:34 PM



Votes:

0

Hi there,

Thanks for your contribution Florian! :)

Best regards.

Created on Jan 15, 2019 3:55:27 PM by  Dariusz Gorka [Paessler Support]



Votes:

0

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

Created on Jan 18, 2019 3:11:55 PM



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,

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

Created on Aug 4, 2022 1:59:50 PM




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.