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

Custom error message

Votes:

0

I have following sensor to report number of failed orders in our system database. I could not fix the script to reported expected error message. Please provide any suggestion or guidance to fix the issue.

#!/bin/bash

prtg_scripts_result=`cat <<EOF
<?xml version="1.0" encoding='UTF-8'?>
<prtg>
EOF
`
PSQL_QUERY="SELECT COUNT(\"OrderID\") FROM \"Sales\" WHERE \"OrderID\" IN ('SO', 'RN') AND \"StatusID\" = 'F'"
PSQL_EXEC=$(echo "$PSQL_QUERY" | psql -Uxxx -h10.12.13.14 -t --no-align --field-separator=$'\011')

if [ "$PSQL_EXEC" -eq 0 ]; then
    PSQL_EXEC=0
        else
        PSQL_EXEC=$PSQL_EXEC
fi

prtg_scripts_result=$prtg_scripts_result`cat <<EOF

<result>
<channel>Failed Order</channel>
<value>$PSQL_EXEC</value>
<Unit>Custom</Unit>
<LimitMaxError>0.5</LimitMaxError>
<LimitErrorMsg>$PSQL_EXEC Failed Order</LimitErrorMsg>
<LimitMode>1</LimitMode>
</result>
</prtg>
EOF
`

echo "$prtg_scripts_result"

Current error message displayed in MAP and Sensor:

11 # (Failed Order) is above the error limit of 0.50 # in Failed Order. 11 Failed Order

Expectation:

11 Failed Order

Note:

Following SSH-Script is not useful in my case due to sensor should be turned RED if there is more than 1 failed order. There is no valid error code available in PRTG to display without any error code PExxxx.

#!/bin/bash
get_row_count(){
        rowCount=$(echo "$1" | psql -Uxxx -h10.12.13.14 -t --no-align --field-separator=$'\011')
        if [ $rowCount -eq 12 ]
        then
                echo "0:$rowCount:$rowCount Zero Order Status is in Provisioning Failed"
        else
                echo "1:$rowCount:$rowCount Failed Order"
        fi
}
main(){
        get_row_count "SELECT COUNT(\"OrderID\") FROM \"Sales\" WHERE \"OrderID\" IN ('SO', 'RN') AND \"StatusID\" = 'F'"
}
main "$1"

Warning message:

11 Failed Order

prtg ssh ssh-script ssh-script-advanced-sensor

Created on Dec 13, 2017 11:02:40 PM

Last change on Dec 14, 2017 6:23:14 AM by  Luciano Lingnau [Paessler]



4 Replies

Accepted Answer

Votes:

0

Please allow us to focus solely on the script's output:

<?xml version="1.0" encoding='UTF-8'?>
<prtg>
<result>
<channel>Failed Order</channel>
<value>$PSQL_EXEC</value>
<Unit>Custom</Unit>
<LimitMaxError>0.5</LimitMaxError>
<LimitErrorMsg>$PSQL_EXEC Failed Order</LimitErrorMsg>
<LimitMode>1</LimitMode>
</result>
</prtg>

When using this:

<LimitMaxError>0.5</LimitMaxError>
<LimitErrorMsg>$PSQL_EXEC Failed Order</LimitErrorMsg>
<LimitMode>1</LimitMode>

You're creating a limit for this channel, in this case whenever the limit is crossed PRTG will display the following standard text:

%value %unit (%channel) is above the %limittype limit of %definedlimit %unit in %channel.

These are also only passed on the first scan/result and are not updated later. Please have a look here for details:

If you want o have complete control over the error/warning text you need to compare the current value against a limit within the script and then produce an output similar to this:

<prtg>
<error>1</error>
<text>Value ($value) is above limit</text>
</prtg>

The same goes for warning:

<prtg>
<Warning>1</Warning>
<text>Value ($value) is above limit</text>
</prtg>

Best Regards,
Luciano Lingnau [Paessler Support]

Created on Dec 14, 2017 1:32:35 PM by  Luciano Lingnau [Paessler]



Votes:

0

Hello Luciano Lingnau,

Thank you for the reply.

Strange that following message repeated for each scanned interval

11 # (Failed Order) is above the error limit of 0.50 # in Failed Order. 11 Failed Order

Sample result:

<?xml version="1.0" encoding='UTF-8'?>\\
<prtg>\\<result>\\
<channel>Failed Order</channel>\\
<value>11</value>\\
<Unit>Custom</Unit>\\
<LimitMaxError>0.5</LimitMaxError>\\
<LimitErrorMsg>11 Failed Order</LimitErrorMsg>\\
<LimitMode>1</LimitMode>\\
</result>\\
<text>11 Failed Order </text>\\
</prtg>

I cannot use <error>1</error> like following due to channel and unit value will be ignored.
Last/Current value is required in report generation to find number of failed orders reported per month.

<prtg>\\
<error>1</error>\\
<text>Value ($value) is above limit</text>\\
</prtg>

It would be better to have a feature request to display exact message passed in <LimitErrorMsg> instead of:
%value %unit (%channel) is above the %limittype limit of %definedlimit %unit in %channel.

or SSH Script without displaying error code PExx in message.

ValueDescription
0OK
1WARNING
2Error
3System Error (e.g. a network/socket error)
4Protocol Error (e.g. web server returns a 404)
5Content Error (e.g. a web page does not contain a required word)

Created on Dec 14, 2017 5:41:29 PM

Last change on Dec 15, 2017 9:06:43 AM by  Luciano Lingnau [Paessler]



Votes:

0

Hi,

Is it now possible to customise the returned message now - without having to use <error></error> & <text></text>??
If you have a sensor with many channels and you want the other channels to continue to log data than this is really not an ideal solution!

We need to be able to remove the excessive message prefix;
%value %unit (%channel) is above the %limittype limit of %definedlimit %unit in %channel.

It's really excessive~

--
As a work around for this, I use 2 sensors - one which I return <error></error> & <text></text> in the schema and then another sensor which continues to log values but never goes down.

Created on Jan 11, 2019 4:51:43 AM

Last change on Jan 11, 2019 3:12:28 PM by  Birk Guttmann [Paessler Support]



Votes:

0

Hi Jaime,
This is still not possible and also not planned for the future at the moment.

If tyou think this could be important for other customers, you can also open a feature request here. Please follow this manual. If the post gets upvotes we will take a closer look.


Kind regards,
Birk Guttmann, Tech Support Team

Created on Jan 11, 2019 4:39:35 PM by  Birk Guttmann [Paessler Support]




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.