[Nagiosplug-help] plugin not returning variable value

Andrew Hall andyjohnhall at gmail.com
Mon Mar 5 17:33:39 CET 2007


Hi there.

I've just written a quick-and-dirty shell script to let me know how
many connections are left on a MySQL server.

This works fine when run on the local machine, but when run from our
nagios server doesn't either return or display a variable.

And I just can't understand why?

Here's the script...

#!/bin/bash
# Check maximum number of allowed connections and compare this to the
number of open connections.
# Warn if these two values are getting close.

warn=$2
crit=$4

MaxConnections=`mysqladmin variables | grep max_connections | awk '{print $4}'`
ThreadsConnected=`mysqladmin extended-status | grep Threads_connected
| awk '{print $4}'`

let Difference=$MaxConnections-$ThreadsConnected

if [ $Difference -lt $crit ]; then
  echo "CRITICAL: Only $Difference connections left" && exit 2

elif [ $Difference -lt $warn ]; then
        echo "WARNING: Only $Difference connections left" && exit 1

else

echo "OK: $Difference connections left" && exit 0

fi

And here's the entry in /etc/nagios/nrpe.cfg on the local machine...

command[check_max_connections]=/usr/lib/nagios/plugins/check_max_connections
-w 300 -c 100

Which when run on the local machine returns...

OK: 658 connections left

But when run from the nagios server only returns...

OK:  connections left

Missing out the value of the $Difference variable

Can anyone explain why this is and how I can resolve it?

Thanks very much for your help.




More information about the Help mailing list