Skip to main content

Freeswitch munin module

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: http://rodolphe.quiedeville.org/hack/munin/asterisk-1.2/

Click here to expand Table of Contents

Channel Usage

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

#!/usr/bin/python

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'


else:
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:

[freeswitch_*]
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.)

#!/bin/bash

FS_DB=/usr/local/freeswitch/db/core.db
SKYPE_DB=/usr/local/skype/db/core.db
GTALK_DB=/usr/local/freeswitch/db/core.db

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

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"
exit
fi


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):

 [freeswitch_*]
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.