Freeswitch munin module

From FreeSWITCH Wiki
Jump to: navigation, search

For external monitoring munin modules as well as other monitoring software modules could be very helpful.

Example * modules for munin can be found here for a starting point:

Channel Usage

Thanks to hads for the python scripting help. This munin plugin will graph the channel usage:


import os
import sys
from xmlrpclib import ServerProxy

host = os.environ['fs_host']
username = os.environ['fs_username']
password = os.environ['fs_password']
port = os.environ['fs_port']

if len(sys.argv) == 2 and sys.argv[1] == 'autoconf':
        print "yes"
elif len(sys.argv) == 2 and sys.argv[1] == 'config':	
        print 'graph_title Channels used'
	print 'graph_args -l 0 --base 1000'
        print 'graph_vlabel active channels'
	print 'graph_category network'
        print 'channels.label channels'
	print 'channels.max 50000'
	print 'channels.min 0'

        server = ServerProxy('http://%s:%s@%s:%s' % (username, password, host, port))
        args = 'show channels'.split(' ')
        print 'channels.value '+'\n'.join(server.freeswitch.api(*args).strip('\n').replace(' total.','').split('\n')[-1:])

Save the plugin as freeswitch_channels and save it in /usr/share/munin/plugins/ and create a symlink to /etc/munin/plugins/freeswitch with

ln -s /usr/share/munin/plugins/freeswitch_channels /etc/munin/plugins/freeswitch

and make it

chmod 755 /usr/share/munin/plugins/freeswitch_channels

Then add:

group root
env.fs_host localhost
env.fs_username freeswitch
env.fs_password works
env.fs_port 8080

to /etc/munin/plugin-conf.d/munin-node

Channel Usage by Query core DB

This is another approach of freeswitch_channels, be sure to change the DB path according to your FS configuration. (On Debian/Ubuntu FreeSwitch would use /opt/freeswitch/db/core.db instead of /usr/local/freeswitch/db/core.db for example.)



if [[ $# -eq 1 ]] && [[ $1 == 'autoconf' ]]; then
        echo "yes"

if [[ $# -eq 1 ]] && [[ $1 == 'config' ]]; then
        echo "graph_title Channels used"
        echo "graph_args -l 0" # --base 1"
        #echo "graph_args -l 0 --base 1"
        echo "graph_vlabel active channels"
        echo "graph_category freeswitch"
        echo "sofia_channels.label sofia"
        echo "sofia_channels.max 50000"
        echo "sofia_channels.min 0"
        echo "sofia_channels.draw LINE1"
        echo "skype_channels.label skype"
        echo "skype_channels.max 50000"
        echo "skype_channels.min 0"
        echo "skype_channels.draw LINE1"
        echo "gtalk_channels.label gtalk"
        echo "gtalk_channels.max 50000"
        echo "gtalk_channels.min 0"
        echo "gtalk_channels.draw LINE1"

sofia_channels=`echo "SELECT COUNT(1) FROM channels WHERE name LIKE 'sofia%';" | sqlite3 $FS_DB`
skype_channels=`echo "SELECT COUNT(1) FROM channels WHERE name LIKE 'skypiax%';" | sqlite3 $SKYPE_DB`
gtalk_channels=`echo "SELECT COUNT(1) FROM channels WHERE name LIKE 'dingaling%';" | sqlite3 $GTALK_DB`

echo "sofia_channels.value $sofia_channels"
echo "skype_channels.value $skype_channels"
echo "gtalk_channels.value $gtalk_channels"

Save the plugin as freeswitch_channels_2 in /usr/share/munin/plugins/

Create a symlink to /etc/munin/plugins/freeswitch_2 with:

ln -s /usr/share/munin/plugins/freeswitch_channels /etc/munin/plugins/freeswitch_2

then make the plugin executable:

chmod 755 /usr/share/munin/plugins/freeswitch_channels

If your freeswitch is running (for example) as user "freeswitch", add these lines to /etc/munin/plugin-conf.d/munin-node (otherwise sqlite3 and munin might not be able to access the database):

 user freeswitch

Make sure sqlite3 is in the path ($PATH). On Ubuntu or Debian, simply do

sudo apt-get install sqlite3

Finally you need to restart munin-node to take the changes into account:

/etc/init.d/munin-node restart

It's also easy to change if you are using ODBC.

Requests for modules: