[Freeswitch-users] FreeSWITCH Nagios Plugin

peely freeswitch at peely.com
Thu Oct 28 06:01:29 PDT 2010




Kristian Kielhofner-3 wrote:
> 
> Hello everyone,
> 
>   I've been looking for a FreeSWITCH Nagios plugin.  Ideally I'd like
> to connect to the event socket and run some api commands and return
> them (as opposed to checking SIP, for example).  I haven't found
> anything and I've started to write one in perl using ESL.  I'm sure
> whatever I come up with is going to be pretty ugly and I'd much rather
> use something else.  Has this been done?
> 
> 
> 


This may be a bit basic for your needs, but it does what I need.

It outputs something like:

Occupancy: 17/2000, Uptime: 0y0d 0:38:7.78287s 

check_freeswitch.sh:

#!/bin/bash
host="$1"
pass="$2"

set fsStatus=" "
/usr/lib/nagios/plugins/fs_cli -H $host -p $pass -x "show calls count" >
/tmp/fsStatus
if [ $? -ne 0 ]; then
        echo "Critical: Freeswitch not responding!"
        rm /tmp/fsStatus
        exit -1
fi

fsCalls=`grep "total."</tmp/fsStatus`
/usr/lib/nagios/plugins/fs_cli -H $host -p $pass -x "status" > /tmp/fsStatus
fsUptime=`grep "UP"</tmp/fsStatus`
fsMaxChannels=`grep "max"</tmp/fsStatus`

#Strip unwanted chars from the channels responses to get pure ints.
fsCalls=${fsCalls/ total./}
fsMaxChannels=${fsMaxChannels/ session(s) max/}

# Reformat the uptime statement for efficiency
fsUptime=${fsUptime/UP /}
fsUptime=${fsUptime/ years, /y}
fsUptime=${fsUptime/ year, /y}
fsUptime=${fsUptime/ days, /d }
fsUptime=${fsUptime/ day, /d }
fsUptime=${fsUptime/ hours, /:}
fsUptime=${fsUptime/ hour, /:}
fsUptime=${fsUptime/ minutes, /:}
fsUptime=${fsUptime/ minute, /:}
fsUptime=${fsUptime/ seconds, /.}
fsUptime=${fsUptime/ second, /.}
fsUptime=${fsUptime/ milliseconds, /}
fsUptime=${fsUptime/ millisecond, /}
fsUptime=${fsUptime/ microseconds/s}
fsUptime=${fsUptime/ microsecond/s}

# Build a message up
message="Occupancy: $fsCalls/$fsMaxChannels, Uptime: $fsUptime"
echo $message

rm /tmp/fsStatus
#exit $fsCalls
exit 0



commands.cfg:

#check freeswitch status
define command{
        command_name    check_freeswitch
        command_line    $USER1$/check_freeswitch.sh $HOSTADDRESS$
EslPassword << change this.
}



Services configuration:

define service{
        hostgroup_name                  mediaservers
        use                             generic-service         ; Name of
service template to use
        service_description             Freeswitch
        check_command                   check_freeswitch
        check_interval                  1
        retry_interval                  1
        max_check_attempts              3
        }




Hope it helps, or at least gives you a starting point.


Neil.




-- 
View this message in context: http://old.nabble.com/FreeSWITCH-Nagios-Plugin-tp26783791p30076321.html
Sent from the Freeswitch-users mailing list archive at Nabble.com.




More information about the FreeSWITCH-users mailing list