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

PRTG displays wrong state SSH Script

Votes:

0

I'm using a custom SSH script to retrieve the state of a service on a Ubuntu server. I added test123 to the array to check if I receive a down state on my channel. But PRTG displays all services are running, even test123. What am I missing here?

Script:

#!/bin/bash
#
array=(psa apache2 test123 )

function check_service {
 service $1 status > /dev/null 2>&1
        if [ $? -ne 0 ]; then
                echo -n "1:$?:Down"
        else
                echo -n "0:$?:OK"
        fi
}

echo "<prtg>"

# <-- Start
for i in "${array[@]}"
do

echo -n "   <result>
       <channel>Service: $i</channel>
         <value>"
check_service $i
echo "</value>
         <ValueLookup>icr.linux.ssh</ValueLookup>
  </result>"
done
# End -->
echo "</prtg>"
exit

Custom lookup file:

<?xml version="1.0" encoding="UTF-8"?> <ValueLookup id="icr.linux.ssh" desiredValue="0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="PaeValueLookup.xsd"> <Lookups> <SingleInt state="Ok" value="0"> Running </SingleInt> <SingleInt state="Warning" value="1"> Stopped </SingleInt> </Lookups> </ValueLookup>

The XML output from the PRTG log:

<prtg> <result> <channel>Service: psa</channel> <value>0:1:OK</value> <ValueLookup>icr.linux.ssh</ValueLookup> </result> <result> <channel>Service: apache2</channel> <value>0:1:OK</value> <ValueLookup>icr.linux.ssh</ValueLookup> </result> <result> <channel>Service: test123</channel> <value>1:0:Down</value> <ValueLookup>icr.linux.ssh</ValueLookup> </result> </prtg>

Thank you in advance

linux prtg script ssh

Created on May 2, 2022 9:41:50 AM

Last change on May 2, 2022 3:05:11 PM by  Felix Wiesneth [Paessler Support]



1 Reply

Votes:

0

Hi John,

I think you mixed here something up.
If you want to use a SSH Script sensor the output is only following:

returncode:value:message

If you are using the SSH Script Advanced sensor you need to use following output:

 <prtg>
           <result>
           <channel>First channel</channel>
           <value>10</value>
           </result>
           <result>
           <channel>Second channel</channel>
           <value>20</value>
           </result>
           </prtg>

This means you need to either change the sensor type (you only can use one channel) or you need to change your output accordingly. ----- Kind regards

Felix Wiesneth - Team Tech Support

Created on May 3, 2022 8:08:28 AM by  Felix Wiesneth [Paessler Support]

Last change on May 3, 2022 8:08:43 AM by  Felix Wiesneth [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.