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

SSH Scripts output to gives error PE 132

Votes:

0

hi i wanted to monitor tcp connections on specific ports so i created one ssh script which i kept in /var/prtg/scripts

scripts contents as follows

  1. !/bin/bash netstat -anp |egrep '(8081|8082|8083|8885)' |grep ESTABLISHED | awk '{print $1,$4,$5}'

which gives me error Response not wellformed: IP :PORT IP:PORT (code: PE132) i believe value:message is some setting is missing, i downt know to put where exactly or how can i get output in PRTG so that i can keep monitoring for the TCP Connections. Thanks in advance

prtg ssh ssh-script

Created on Mar 14, 2016 8:53:15 AM



4 Replies

Votes:

0

The output from scripts used by the SSH sensor need to be in the following format:

<exitcode>:<value>:<message>

Example:

0:2:The value is 2

Make sure it matches. Since you're having multiple key value pairs, you might want to look into the SSH Script Advanced sensor which can take XML as a result. The format needs to be like this:

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

Created on Mar 14, 2016 9:34:59 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi sanjaygurav2003

I think you expect a variable return in the sensor with multiple entries. But I don't think its possible what you want. You could measure "how many" established connections there are or if there is in fact one or not. But you cannot get variable data like all established connections. It would be possible as XML but then the amount of "lines" you get back is then fixed when you create the sensor.

You could count all the established connections and if there are too many, then the sensor will go red. Or even use the unusal detection. just add "| wc -l" at the end, then you should get how many established connections you have.

Have you already read through this?

https://kb.paessler.com/en/topic/39513-is-there-a-shell-script-example-for-prtg-s-ssh-script-sensor

regards Thomas

Created on Mar 14, 2016 9:57:14 AM



Votes:

0

Hi Thomos

Ya true , i was expecting a variable return, instead of count in the sensor with the output with ip's & port. i can get now what i wanted from the link given by you. Thanks for your help

script used ( which shows 8885 port Established connection status)

#!/bin/bash
port="8885"
service="FIX-8885"

NETSTAT=`which netstat`
ID=`which id`

die(){
        exit 999
}
is_root(){
        local id=$($ID -u)
        if [ $id -ne 0 ]
        then
                echo "4:500:You have to be root to run $0."    # returncode 4 = put sensor in DOWN status
                die
        fi
}
preparation(){
        if [ ! -x $NETSTAT ]
        then
                echo "2:500:netstat not found."
                die
        fi
        if [ ! -x $ID ]
        then
                echo "2:500:id not found."    # returncode = 2 = put sensor in DOWN status
                die
        fi
        is_root
}
check_service(){
        serviceIsRunning=false
        openPorts=$($NETSTAT -n | grep '8885'| awk '{ print $4}' | awk -F: '{print $NF}' | sed '/^$/d' | sort -u)
        for openPort in $openPorts
        do
                if [ "$port" == "$openPort" ]
                then
                        serviceIsRunning=true
                        echo "0:200:$service is running."    # returncode 0 = put sensor in OK status
                        break
                fi
        done
        if [ $serviceIsRunning == false ]
        then
                echo "1:404:$service is not running."    # returncode 1 = put sensor in WARNING status
        fi
}
main(){
        preparation
        check_service
}
main

EDIT BY MOD: Formatting!

Created on Mar 16, 2016 6:03:46 AM

Last change on Mar 16, 2016 1:55:06 PM by  Konstantin Wolff [Paessler Support]



Votes:

0

Hi sanjaygurav2003

pleasure to help.

cheers Thomas

Created on Mar 16, 2016 2:02:10 PM




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.