VoIPowering Your Office: Cool Tools for SipX

by Carla Schroder

VoIP servers need configuration and maintenance. SipX provides the tools you need—your choice of command line or browser interface.

SipX, in keeping with its overall theme of making life easy for the VoIP server admin, has the SipXtools package for keeping an eye on server activity from the command line. The same information is available from the Web interface, and while it's still a bit rough around the edges, it won't hurt to get acquainted with it. If you find yourself in a situation where the Web interface is not available, SipXtools will save the day.

Installing SipXtools
If you installed SipX from the installation CD, which includes Fedora Linux, this is so easy it will be like a vacation. First install the configuration file for the SipX software repository:

[root@sipx sipxpbx]# wget -P /etc/yum.repos.d http://www.sipfoundry.org/pub/sipX/sipx-fc.repo
Then install SipXtools:
[root@sipx sipxpbx]# yum install --enablerepo=sipx-development sipxtools
On Red Hat Enterprise Linux and CentOS, download the RPM from www.sipfoundry.org/temp/sipX/main/FC/5/RPM/. Then install it manually:
[root@sipx sipxpbx]# rpm -ivh sipxtools-3.7.0-009131.i386.rpm
You'll end up with following executables, which you can see with the rpm -ql sipxtools command:
Running any of these with the -h option will display a Help dialog.

What it all means
expire-spread tracks subscriptions and registrations over time. This is helpful for getting a picture of peak use times. Run it like this to see all data:

[root@sipx sipxpbx]# expire-spread
You can also view results from selected databases from /var/sipxdata/sipdb with the --db option:
[root@sipx sipxpbx]# expire-spread --db /var/sipxdata/sipdb/permission.xml
[root@sipx sipxpbx]# expire-spread --db /var/sipxdata/sipdb/registration.xml
sipdb-dump digs through SipX's services files to give you a snapshot of current status. For example, you can see the expired status of all phones. This example changes to the /var/sipxdata/sipdb directory, then dumps the contents of registration.xml:

[root@sipx sipxpbx]# cd /var/sipxdata/sipdb
[root@sipx sipdb]# sipdb-dump registration.xml
callid=615655839@ cseq=3565 primary=
uri=sip:200@alrac.net contact="carla schroder"<sip:200@;transport=udp>
contact_host= qvalue= expires=1174606170 expired=trueinstance_id= gruu=

That's the output of a single registration, so you can imagine how it looks when there is a lot of activity. This command whittles the output to show expired status and IP address:

[root@sipx sipdb]#  sipdb-dump registration.xml | awk -F\\t '{print $9 " " $6}' | sort
This command finds just the active registrations:
[root@sipx sipdb]# sipdb-dump registration.xml | awk -F\\t '/expired=false/ {print $9 " " $6}'
This command finds expired subscriptions:
[root@sipx sipdb]# sipdb-dump subscription.xml | awk -F\\t '/expired=true/ { print $10 }'
This one shows all aliases nicely sorted in numerical order:
[root@sipx sipdb]# sipdb-dump alias.xml | awk -F\\t '/contact=sip:*/ {print}'|sort
You can pluck out aliases by domain:
[root@sipx sipdb]# sipdb-dump alias.xml | grep 'alrac.net'
identity=*88@alrac.net  contact=sip:*88@sipx.alrac.net:5130     contact_host=sipx.alrac.net
identity=*86@alrac.net  contact=sip:*86@sipx.alrac.net:5130     contact_host=sipx.alrac.net
The sipx-stats command presents logfiles in a nice table format:
[root@sipx sipxpbx]# cd /var/log/sipxpbx
[root@sipx sipdb]# sipx-stats sipxpresence.log sipxpresence.log.1
You can store the output in a text file:
[root@sipx sipdb]# sipx-stats < sipxpresence.log sipxpresence.log.1 > log.txt
You may use this on any number of logfiles, from a single one to several. Older logfiles are compressed, so you'll need to unzip them first:
[root@sipx sipdb]# gunzip sipxpresence.log.3.gz
sipxproc displays and manages SipX processes. This is a great little command, because trying to use the traditional ps ax command to dig out the SipX processes will make you crazy. sipxproc displays the current status of all SipX processes:
[root@sipx sipdb]# sipxproc
warning: peer certificate won't be verified in this SSL session
SIPStatus Started
MediaServer Started
SIPRegistrar Started
SIPAuthProxy Started
KeepAlive Started
ParkServer Started
PresenceServer Started
ConfigAgent Started
CallResolver Started
ConfigServer Started
SIPProxy Started
Ignore the SSL warning; it just means there is no peer to verify, since you're running commands on the server.

The most useful option is you can restart individual processes without bringing down the whole server:

[root@sipx sipdb]# sipxproc  -r ConfigServer
[root@sipx sipdb]# sipxproc  -r SIPProxy
The -s option starts a service, and -k stops it. -h displays help.

sipxcar is an interesting command for comparing your configuration files to an archive of default files. This one lists changed files:

[root@sipx ~]# sipxcar -m
M /etc/sipxpbx/config.defs
? /etc/sipxpbx/authproxy-config.in
M means the file has been modified from the defaults, and the question mark means the file has been deleted.

This shows the changes in the files, using standard diff notation:

[root@sipx ~]# sipxcar -d
--- /tmp/config.defs.5954.0     2007-03-23 10:18:27.000000000 -0700
+++ /etc/sipxpbx/config.defs    2007-02-16 11:37:32.000000000 -0800
@@ -14,7 +14,7 @@
 # to domain name (e.g. domain.com), so comment out the assignment
 # below that uses -f and uncomment the one that uses -d:
If you get hopelessly horked and want to start over, run this command to reset the file to the defaults:
[root@sipx ~]# sipxcar --reset /etc/sipxpbx/config.defs 
You can also use sipxcar to apply patches to your configuration files, but that's too geeky even for me. I'm OK with plain old editing in a text editor.

My favorite feature of the sipxcar command is using it to find the SipX RPM packages:

[root@sipx ~]# sipxcar
And then listing the configuration files for each package:
[root@sipx ~]# sipxcar -l sipxregistry
These are ordinary RPMs, so you can use the usual RPM commands to query them as well, like rpm -ql sipxregistry to list all the files in the package.

This Wiki page has more information on SipXtools
The SipX Wiki is a great resource for all things SipX
VoIPowering Your Office: Meet SipX, the SIP iPBX Server for Linux
VoIPowering Your Office: Installing SipX
VoIPowering Your Office: Recovering SipX Passwords and DNS Done Right
VoIPowering Your Office: SipX and IP Phones
VoIPowering Your Office: Connect SipX to Analog Phone Lines

This article was originally published on Tuesday Mar 27th 2007