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

Dynamic LimitMaxError in custom EXEXML

Votes:

0

Hey there!

I have created a custom xml sensor which should have different "LimitMaxError" values depending on a condition. The sample below should illustrate what I am trying.

$hour = (get-date).Hour

if($hour -lt 9){
    $limit = 5
} else{
    $limit = 15
}

$xml += "<?xml version=""1.0"" encoding=""Windows-1252"" ?>"
$xml += "<prtg>"
$xml += "<result>"
$xml += "<Channel>Hour</Channel>"
$xml += "<Value>$hour</Value>"
$xml += "<Unit>Custom</Unit>"
$xml += "<CustomUnit>#</CustomUnit>"
$xml += "<LimitMaxError>$limit</LimitMaxError>"
$xml += "<LimitMode>1</LimitMode>"
$xml += "</result>"
$xml += "</prtg>"
$xml

If $hour < 9, $limit = 5 and if $hour > 9, $limit = 15. When I run this script in PowerShell ISE the value of $limit is correctly changing dependig on the condition but when the sensor is created the value of <LimitMaxError> does not change. The Value $hour is updated correctly.

Is there any way to realize this or can't limits of a channel be updated during script runtime?

Thanks in advance Kind Regards

custom-sensor exexml powershell

Created on Oct 14, 2015 8:08:52 AM

Last change on Oct 14, 2015 9:20:05 AM by  Luciano Lingnau [Paessler]



2 Replies

Accepted Answer

Votes:

0

Hello,
we appreciate your inquiry.

As per the documentation available within PRTG (Setup > PRTG API > Custom Sensors):

<LimitMaxError>
Define an upper error limit for the channel. If enabled, the sensor will be set to a "Down" status if this value is overrun and the LimitMode is activated. Note: Please provide the limit value in the unit of the base data type, just as used in the <Value> element of this section. While a sensor shows a "Down" status triggered by a limit, it will still receive data in its channels. The values defined with this element will be considered only on the first sensor scan, when the channel is newly created; they are ignored on all further sensor scans (and may be omitted). You can change this initial setting later in the Channel settings of the sensor.
This also applies to the following elements:
  • <ShowChart>
  • <ShowTable>
  • <LimitMaxError>
  • <LimitMaxWarning>
  • <LimitMinWarning>
  • <LimitMinError>
  • <LimitErrorMsg>
  • <LimitWarningMsg>


Within Custom Sensors, you can "workaround" this by using the following tags to set the sensor to error or warning based on specific conditions within the script:

  • <Warning>
  • <Error>
As example:
write-host "<prtg>"
write-host "<error>1</error>"
write-host "<text>Value ($value) is above limit</text>"
write-host "</prtg>"



Best Regards,

Created on Oct 14, 2015 9:23:59 AM by  Luciano Lingnau [Paessler]

Last change on Jan 13, 2016 2:26:53 PM by  Luciano Lingnau [Paessler]



Votes:

0

Hello,

thank you for the fast reply. I must have skipped this.

Thanks for the example.

Kind Regards

Created on Oct 14, 2015 9:44:30 AM




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.