Capture numeric result in Linux
Posted on 2011-09-26
I am running a few Asterisk servers and I would like the run a daily cron job to check and see how many sip peers are resisted on my servers. Currently we are only able to do this manually which can be a lot of work. Below is the command we run which shows the result.
COMMAND: /usr/sbin/asterisk -rx "sip show peers" | grep "sip peers"
RESULT: 901 sip peers [Monitored: 22 online, 4 offline Unmonitored: 771 online, 104 offline]
I need some help with a script that will run the above command, read the first number into a numeric variable (example: 901 above. This will always be between 0 and 1,500), and then process an IF statement to send me an email alert once the value is above 1,300.