[asterisk-users] Nagios under *
Steve Edwards
asterisk.org at sedwards.com
Thu Jun 18 13:56:28 CDT 2009
On Thu, 18 Jun 2009, Sriram wrote:
> I am trying to implement monitoring of asterisk (all 4 spans-i want to
> show them line by line Up or down) using nagios using below script, but
> i always get the status as down and red..can anyone let me know how to
> read an output from nagios plugin ? nagios etc is configured already and
> is working
I'm a 1.2 Luddite, but here's my $0.02.
> PATH=/bin:/sbin:/usr/bin:/usr/sbin
> FAILS=""
> STATUS=$(asterisk -rnx "pri show span 1" | grep -a Status | awk '{print $3;}' | cut -d, -f1)
> if [ "${STATUS}" == "Up" ]; then
> echo "PRI UP"
> exit 0
> else
> echo "PRI DOWN"
> exit 2
> fi
Does the user running Nagios have access to /var/run/asterisk.ctl?
Using sudo will work. You could change the ownership or permissions of
asterisk.ctl, but using sudo should survive upgrades better and has less
chance of breaking something else.
FAILS is never used.
You don't need grep or cut. Since (I'm assuming) this script will run
frequently, cutting the number of processes created in half seems like a
good idea.
STATUS=$(sudo asterisk -rnx "pri show span 1"\
| awk '/Status/ {print $3}'\
)
if [ "Up," == "${STATUS}" ]
then echo "PRI UP"
exit 0
else echo "PRI DOWN"
exit 2
fi
Keep in mind that if the span has multiple D channels (like an NFAS group)
you will get multiple statuses.
I'm not a big fan of using "-rx." I think AMI should be used for all new
code.
Thanks in advance,
------------------------------------------------------------------------
Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
More information about the asterisk-users
mailing list