Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
deelight
Posts: 6 Joined: Wed Dec 16, 2015 6:23 pm
Post
by deelight » Wed Dec 16, 2015 6:30 pm
Hi Guys,
i've got a problem with the check_tcp plugin and counld not find any plugin who works like i need.
I'm sending a string to a port via check_tcp and get a number back, in this case 2580. On this number i need to define warning and crital values.
Example:
Code: Select all
/usr/lib/nagios/plugins# ./check_tcp -H XXXXXXXXXX -p 51031 -E -s "status\r\n" -d 1 -t 30 -e "SOMEThING"
TCP WARNING - Unexpected response from host/socket: [b]2580[/b]|time=0,000358s;;;0,000000;30,000000
I need somthing like
Code: Select all
/usr/lib/nagios/plugins# ./check_tcp -H XXXXXXXXXX -p 51031 -E -s "status\r\n" -d 1 -t 30 -w 2500 -c 3000
Is there anyway to do this or any plugin i've not found yet?
rkennedy
Posts: 6579 Joined: Mon Oct 05, 2015 11:45 am
Post
by rkennedy » Thu Dec 17, 2015 12:58 pm
The check_tcp command is generating warning / critical based on the response time from the TCP port.
To help you find a plugin that will work for you, what kind of application is this?
Former Nagios Employee
deelight
Posts: 6 Joined: Wed Dec 16, 2015 6:23 pm
Post
by deelight » Thu Dec 17, 2015 5:16 pm
It's a custom tool that looks into a folder at another location and show how many file are waiting. i have no other way to monitor this.
I need, like in check_smtp to define a warning/critical on the value i get beack when i ask the port for his status.
hsmith
Agent Smith
Posts: 3539 Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:
Post
by hsmith » Thu Dec 17, 2015 5:23 pm
You could write a wrapper script that executes the plugin, and exit 0/1/2 depending on what it finds using some if statements.
Do you follow?
Former Nagios Employee.
me.
deelight
Posts: 6 Joined: Wed Dec 16, 2015 6:23 pm
Post
by deelight » Thu Dec 17, 2015 5:26 pm
yes, i just had hoped that there would be an easyier way ...
deelight
Posts: 6 Joined: Wed Dec 16, 2015 6:23 pm
Post
by deelight » Fri Dec 18, 2015 5:42 pm
I build a small bash script that is working basicly... i'm just struggling with the difference between when it is a warning and a critical.
Code: Select all
if [ $RESPONSE -lt $WARN ]
then
echo "OK- $RESPONSE $MSG"
exit 0
elif [ $RESPONSE -ge $WARN -lt $CRIT ]
then
echo "WARNING- $RESPONSE $MSG"
exit 1
elif [ $RESPONSE -ge $CRIT ]
then
echo "CRITICAL- $RESPONSE $MSG"
exit 2
else
echo "UNKNOWN- $output"
exit 3
fi
hsmith
Agent Smith
Posts: 3539 Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:
Post
by hsmith » Mon Dec 21, 2015 10:21 am
deelight wrote: i'm just struggling with the difference between when it is a warning and a critical.
Can you elaborate on this a bit?
Former Nagios Employee.
me.
deelight
Posts: 6 Joined: Wed Dec 16, 2015 6:23 pm
Post
by deelight » Mon Dec 21, 2015 6:29 pm
got it... just switched the order. The problem was, that when it was a critical value it was also a warning value so it exits already with 1. Now i have it like this:
Code: Select all
if [ $RESPONSE -lt $WARN ]
then
echo "OK- $RESPONSE $MSG"
exit 0
elif [ $RESPONSE -ge $CRIT ]
then
echo "CRITICAL- $RESPONSE $MSG"
exit 2
elif [ $RESPONSE -ge $WARN ]
then
echo "WARNING- $RESPONSE $MSG"
exit 1
else
echo "UNKNOWN- $RESPONSE"
exit 3
fi
deelight
Posts: 6 Joined: Wed Dec 16, 2015 6:23 pm
Post
by deelight » Mon Dec 21, 2015 6:43 pm
My current solution looks like this:
Code: Select all
#!/bin/bash
#
[code]# Check TCP Response fuer NAGIOS
#
# by Kjell Krenz
#
#
# Version 0.1
#
#
while [ $# -gt 0 ]
do
case $1 in
-h)
HOST=$2
shift 2
;;
-p)
PORT=$2
shift 2
;;
-s)
STRING=$2
shift 2
;;
-w)
WARN=$2
shift 2
;;
-c)
CRIT=$2
shift 2
;;
-m)
MSG=$2
shift 2
;;
*)
echo "Usage:"
echo "-h: Host (IP)"
echo "-p: TCP Port"
echo "-s: STRING"
echo "-w: WARNING VALUE"
echo "-c: CRITICAL VALUE"
echo "-m: Custom Message Label"
shift 1
;;
esac
done
exec 3<>/dev/tcp/$HOST/$PORT
echo -en "$STRING\n" >&3
RESPONSE="`cat <&3`"
if [ $RESPONSE -lt $WARN ]
then
echo "OK- $RESPONSE $MSG"
exit 0
elif [ $RESPONSE -ge $CRIT ]
then
echo "CRITICAL- $RESPONSE $MSG"
exit 2
elif [ $RESPONSE -ge $WARN ]
then
echo "WARNING- $RESPONSE $MSG"
exit 1
else
echo "UNKNOWN- $RESPONSE"
exit 3
fi
esac
echo $RESPONSE
exit $EXIT