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
Add comment