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-SSH-Script Return Value 2 Produce Integer Values

Votes:

0

Hello, I have put together a bash script for a custom SSH Script Sensor so that I can monitor used INode counts. We have a Linux server that seems to spike on INode or open file usage and crashes. I should mention that I am fairly new to the world of PRTG and bash scripting. My script works in that I can set a threshold count range and it will produce the correct value count, plus PRTG recognizes the state changes (OK, Warning, Error).

The problem I'm hoping to get some help with is that when I set the return value to a "2" by the nature of that being seen as a system error, PRTG doesn't seem to display any integer counts in the "Value" channel. But it will display them if you change the return value to a "0" or a "1". So an example sensor message with the "2" value might look like this: "System Error: Count EXCEEDED Test (Code: PE022). Graph = Value > No data.

We'd like to be able graph the used INodes data when it crashes and goes into a down state or "2". This is the script that works on our Linux server:

 #!/bin/bash

 #A shell script to monitor INode counts for root
output=$(df -i | grep root | awk '{print $3}')
if [ "$output" -ge 0 ] && [ "$output" -le 30000 ]; then
echo 0:$output:Count OK
elif [ "$output" -ge 30000 ] && [ "$output" -le 36000 ]; then
echo 1:$output:Count WARNING
elif [ "$output" -ge 36000 ] && [ "$output" -gt 42000 ]; then
echo "2:$output:$output:Count EXCEEDED Test"
fi

I put the extra $output in the code because I found that PRTG will put the correct INode integer counts in the header that way, but it still won't graph the data.

Is there a way to get the values to produce for the "2" return value and if so, might someone have a suggestion as to how I can do this? Thanks for any help you can offer!

prtg sensor ssh-script

Created on Oct 31, 2016 8:18:47 PM

Last change on Nov 1, 2016 1:38:01 PM by  Arne Seifert [Paessler Support]



3 Replies

Votes:

0

Dear doylesd,

please clarify, what exactly are you trying to do? Return two values per sensor call? This can be done only via the SSH Script Advanced sensor, which requires a more complex return structure using XML. The XML is explained in the API documentation via Setup / PRTG API, Tab "Custom Sensors", section "ADVANCED SCRIPT AND HTTP DATA SENSORS".

Or do you want to set the sensor in the error status and also get data? The easiest way to do that would be to trigger the error status by channel values. The channel limits however have to be set manually when you use the SSH script standard (non-advanced) sensor.

Created on Nov 1, 2016 1:51:09 PM by  Arne Seifert [Paessler Support]

Last change on Nov 1, 2016 1:51:21 PM by  Arne Seifert [Paessler Support]



Votes:

0

Good afternoon,

Thanks for your response. With regards to your question, I would say the latter is what I'm looking for. I'd like to still graph the data when an error state occurs. But I believe that, by design, if the server enters an error state of "2", then PRTG sees the server as being actually down and no data can graph . Is that correct? You mention setting the channel limits manually - does that mean something like adding a Threshold Trigger to the sensor?

That's what I decided to try recently. I have set a custom threshold trigger so that when the Primary channel goes above a certain number, it notifies me via email and generates an alert. If I set the custom script to a "2" it produces the system error and will graph the down times, but again, no channel # value data seems to graph.

You mention adding channel values and limits manually to get the error status and data to graph - is there a better or different way to do this that I should try or does it seem like the threshold trigger method is correct for the SSH script standard sensor? Is there maybe a way to change the color of the error manually so if I need to set it as a Warning to graph the data and keep it red?

Created on Nov 2, 2016 9:38:49 PM



Votes:

0

Dear doylesd,

the sensor status color coding "red" for "Error" does not discern real errors and limit errors. But you can employ the yellow warning state to have a status between Ok and Error, depending on the sensor result.

In the PRTG interface, please click on the channel gauge to open its configuration. Enable the limits and fill the fields accordingly. If you set the upper error limit for example to 10, a value of 10 will not trigger the Error status, but anything above will. This is an error status which does not prevent the graphing of the data, so you have both your data and the error status.

If you just need the notification and no error status in PRTG, you can let the limits disabled and add a threshold trigger (tab "Notification") and evaluate the sensor value directly.

Created on Nov 3, 2016 1:05:15 PM by  Arne Seifert [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.