source: npl/phone/custom_scripts/asterisk_guardian.sh @ c5c522c

gcc484ntopperl-5.22
Last change on this file since c5c522c was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

  • Property mode set to 100644
File size: 1.1 KB
Line 
1#!/bin/bash
2#(C) 2009 DatuX HR Meertens
3#This script monitores system values and generates snmptraps
4
5source /etc/asterisk_guardian.conf
6
7function retrieveActiveCalls {
8        return `asterisk -r -x "show channels" | grep "active call" | cut -d ' ' -f 1`
9}
10function sendSnmpTrap {
11        #`snmptrap -e $EngineID -v 3 -u $Username -a MD5 -A $Password -l authNoPriv $Hostname "" snmpTrap .1.3.6.1.4.1.22736.1.2.5 i $1`
12        `snmptrap -v 2c -c public $Hostname "" snmpTrap .1.3.6.1.4.1.22736.1.2.5 i $1`
13}
14
15
16#initial check
17retrieveActiveCalls
18PreviousActiveCalls=$?
19timer=0
20
21while(true);
22do
23
24        retrieveActiveCalls
25        activeCalls=$?
26        if [ $activeCalls -ge `echo "$PreviousActiveCalls+$CallDeviateValue" | bc` ]; then
27                sendSnmpTrap $activeCalls
28        fi
29        if [ $activeCalls -le `echo "$PreviousActiveCalls-$CallDeviateValue" | bc ` ]; then
30                sendSnmpTrap $activeCalls
31        fi
32        if [ $timer -ge $SendActiveCallsStatusInterval ]; then
33                #Retrieve active calls
34                retrieveActiveCalls
35                activeCalls=$?
36                sendSnmpTrap $activeCalls
37                #reset timer
38                timer=0
39        fi
40        PreviousActiveCalls=$activeCalls
41        sleep $CallDeviateCheckInterval
42        timer=`echo "$CallDeviateCheckInterval+$timer" |bc`
43done
Note: See TracBrowser for help on using the repository browser.