#!/bin/bash# Global varsCOLUMN="Asterisk"color="green"MSG=""reg=`sudo/usr/sbin/asterisk-rx"sip show registry"`peer=`sudo/usr/sbin/asterisk-rx"sip show peers"`nreg=`echo"$reg"|sed'1,1d'|sed'N;$!P;$!D;$d'|grep-cvRegistered|sed-e's/:/./g'`if[$nreg-eq0];thengreg=`echo"$reg"|sed'1,1d'|sed'N;$!P;$!D;$d'|sed-e's/:/./g'`reg_msg="<b>All external line Ok.</b>$greg"elseareg=`echo"$reg"|sed'1,1d'|sed'N;$!P;$!D;$d'|grep-v"Registered"|sed-e's/:/./g'`reg_msg="<b>Alarm on $nreg external line!!!</b>$areg"color="red"finpeer=`echo"$peer"|grep-c"UNKNOWN"`if[$npeer-eq0];thencpeer=`echo"$peer"|sed'1,1d'|sed'N;$!P;$!D;$d'|grepOK`peer_msg="<b>All internal peers Ok.</b>$cpeer"elseapeer=`echo"$peer"|grepUNKNOWN`peer_msg="<b>Warning on $npeer internal peer!!</b>$apeer"if["$color"=="red"];thencolor="red"elsecolor=yellow
fifiMSG="`echo "$reg_msg"`<br />`echo "$peer_msg"`<br />`echo "<b>Currentevents</b>"``echo alarm : "$nreg"``echo warning : "$npeer"`"# Send data to XYMon$BB$BBDISP"status $MACHINE.$COLUMN$color `date`$MSG"exit0
STEP 2
Get xymonlaunch to run the script
Add a section to the ~xymon/client/etc/clientlaunch.cfg to run it every 5 minutes:
Add the graph to the collection of graphs on the trends column
GRAPHS="la,disk,inode,...,asterisk"
STEP 3
Setup a graph definition
The next step is to tell Xymon how to create a graph from the data in the RRD file.
This is done in the ~xymon/server/etc/graphs.cfg file.
[asterisk]TITLE Lost of registerYAXIS EventsDEF:alarm=asterisk.rrd:alarm:AVERAGEDEF:warning=asterisk.rrd:warning:AVERAGELINE2:alarm#FF0000:AlarmLINE2:warning#FFA500:WarningCOMMENT:this graph show event when PEER lost register\nGPRINT:alarm:LAST: alarm \: %5.1lf (cur)GPRINT:alarm:MAX: \: %5.1lf (max)GPRINT:alarm:MIN: \: %5.1lf (min)GPRINT:alarm:AVERAGE: \: %5.1lf (avg)\nGPRINT:warning:LAST: warning \: %5.1lf (cur)GPRINT:warning:MAX: \: %5.1lf (max)GPRINT:warning:MIN: \: %5.1lf (min)GPRINT:warning:AVERAGE: \: %5.1lf (avg)\n
STEP 4
Enable xymonast test in ~xymon/server/etc/hosts.cfg file
xxx.xxx.xxx.xxx asterisk # conn asterisk
STEP 5
In your XYMon client put next records to SUDOERS file
Cmnd_Alias XYM = /usr/sbin/asterisk *
xymon ALL = NOPASSWD: XYM
STEP 6
Restat XYMon on server and client
xymon@pbx:/#/etc/rc.d/rc.xymonclient restart
xymon@xymon:/#/etc/rc.d/rc.xymonserver restart
Done!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Step 1
Make a script to collect the data:
user@pbx:/# cat ./asterisk.sh
STEP 2
Get xymonlaunch to run the script
Add a section to the ~xymon/client/etc/clientlaunch.cfg to run it every 5 minutes:
Arrange for the data to be collected into an RRD file
To enable this, on the Xymon server edit the ~xymon/server/etc/xymonserver.cfg file
Add the graph to the collection of graphs on the trends column
GRAPHS="la,disk,inode,...,asterisk"
STEP 3
Setup a graph definition
The next step is to tell Xymon how to create a graph from the data in the RRD file.
This is done in the ~xymon/server/etc/graphs.cfg file.
STEP 4
Enable xymonast test in ~xymon/server/etc/hosts.cfg file
xxx.xxx.xxx.xxx asterisk # conn asterisk
STEP 5
In your XYMon client put next records to SUDOERS file
Cmnd_Alias XYM = /usr/sbin/asterisk *
xymon ALL = NOPASSWD: XYM
STEP 6
Restat XYMon on server and client
xymon@pbx:/#/etc/rc.d/rc.xymonclient restart
xymon@xymon:/#/etc/rc.d/rc.xymonserver restart
Done!