Hi 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 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 if i execute the script from command line i get the correct output i.e OK for span 1 but on nagios web interface i get it as down... If anyone can share the above script for asterisk monitoring then i wud be grateful rgds Sriram -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20090618/4fbb307e/attachment.htm
Check the script permissions for nagios user Sriram escreveu:> > Hi > 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 > 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 > > if i execute the script from command line i get the correct output i.e > OK for span 1 but on nagios web interface i get it as down... > If anyone can share the above script for asterisk monitoring then i wud > be grateful > > rgds > Sriram > > > ------------------------------------------------------------------------ > > _______________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users-- Diego Aguirre (DagMoller) Infodag Consultoria FWD#: 459696 Enum#: +55 21 8871-4916 (e164.org) DUNDi-br#: 21 8871-4916
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 workingI'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 > fiDoes 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
Hi Steve I tried your script : 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 but still i get PRI down in the Nagios web interface while if i execute this command from command line i get PRI UP...i m really going mad..did a clean install again but still same problem.. Iv;e also given permission of 777 to the script and saved it under /usr/local/nagios and given the same path in commands.cfg under objects folder of /usr/local/nagios/etc ... can anyone please help me out ? Thanks Sriram -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20090619/ea586719/attachment.htm