Wednesday, September 12, 2012

OpenSIPS Monitoring using SNMP [ Part-I ]

OpenSIPS Monitoring 
using SNMP

This is once again a little personal development project on creating a VoIP Monitoring server capable of displaying stats from all the VoIP tools we've ever deployed and used in our company. I want to make a monitoring server which will publish stats from OpenSIPS, Kamailio, FreeSwitch, and Asterisk servers all at one place. 

The very first thing one should focus on for any project like this should be the choice of monitoring tool, this is critical because it gets really hard at some later stage to switch to any other NMS. I had a good experience with Zabbix and knew the flexibility and options available in this tool so I used Zabbix.

In this post I'll just focus on collecting stats from the OpenSIPS server, rest of the applications are just the same steps.

Installation of zabbix can be another post and I don't really want to make this a huge blog post now.

One should have atleast a running opensips server and a zabbix server running.

The first way of asking OpenSIPS to start publishing monitoring data is useing the SNMPSTATS  module.

In your opensips.cfg file add these lines in appropriate sections.

loadmodule "snmpstats.so"

modparam("snmpstats", "sipEntityType", "registrarServer")
modparam("snmpstats", "snmpgetPath", "/usr/bin/")

Next define a RO community in the snmpd.conf file (again assuming the snmpd is installed already and have all the MIBs) 

my snmpd.conf file has just these lines.

rocommunity  voip_monitoring
syslocation  "VM, Virtual DataCenter"
syscontact  govoiper@gmail.com

Then in /etc/snmp/snmp.conf file I've these lines only

defVersion      2c
defCommunity    voip_monitoring


Following line needs to be in the /etc/snmp/snmpstats.conf file

agentXSocket tcp:localhost:705


Next we need to copy the OPENSER-MIB files from the source installation directory to the default directory where all MIBs are place already.

My default directory for all MIBs is /var/lib/mibs/ietf/


root@opensips-1:~#cp /usr/src/opensips-1.7.2-tls/modules/snmpstats/mibs/* /var/lib/mibs/ietf/
The file /etc/default/snmpd has following line edited as follows.


SNMPDOPTS='-x tcp:localhost:705 -Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf'


Restart opensips and snmpd services , if everything is started successfully verify that we can fetch SNMP values from the OpenSIPS.


root@opensips-1:~# snmpbulkwalk -v2c -Os -c voip_monitoring localhost OPENSER-REG-MIB::openser


Showed a huge list of data: (See end of page)


root@opensips-1:~# snmpbulkwalk -O s -v 2c -c  voip_monitoring localhost OPENSER-SIP-COMMON-MIB::openserSIPCommonObjects


openserSIPProtocolVersion.0 = STRING: SIP/2.0
openserSIPServiceStartTime.0 = Timeticks: (1308884) 3:38:08.84
openserSIPEntityType.0 = BITS: 08 registrarServer(4)
openserSIPTransportRcv.ipv4."192.168.56.3".5060 = BITS: 40 udp(1)
openserSIPMethodName.1 = STRING: METHOD_INVITE
openserSIPMethodName.2 = STRING: METHOD_CANCEL
openserSIPMethodName.3 = STRING: METHOD_ACK
openserSIPMethodName.4 = STRING: METHOD_BYE
openserSIPMethodName.5 = STRING: METHOD_INFO
openserSIPMethodName.7 = STRING: METHOD_UPDATE
openserSIPMethodName.8 = STRING: METHOD_REGISTER
openserSIPMethodName.9 = STRING: METHOD_MESSAGE
openserSIPMethodName.10 = STRING: METHOD_SUBSCRIBE
openserSIPMethodName.11 = STRING: METHOD_NOTIFY
openserSIPMethodName.12 = STRING: METHOD_PRACK
openserSIPMethodName.13 = STRING: METHOD_REFER
openserSIPMethodName.14 = STRING: METHOD_PUBLISH
openserSIPSummaryInRequests.0 = Counter32: 496
openserSIPSummaryOutRequests.0 = Counter32: 0
openserSIPSummaryInResponses.0 = Counter32: 0
openserSIPSummaryOutResponses.0 = Counter32: 26862
openserSIPSummaryTotalTransactions.0 = Counter32: 26376
openserSIPCurrentTransactions.0 = Gauge32: 8
openserSIPNumUnsupportedUris.0 = Counter32: 0
openserSIPNumUnsupportedMethods.0 = Counter32: 3
openserSIPOtherwiseDiscardedMsgs.0 = Counter32: 4


Next Step is to collect the Full number OID of each interesting OID from above by using this command


root@opensips-1:~# snmptranslate -On OPENSER-SIP-COMMON-MIB::openserSIPNumUnsupportedMethods.0

This resulted in a number like this:

.1.3.6.1.4.1.27483.3.1.1.1.8.2.0

We will use the above number and its Key in Zabbix for plotting this Data later on.
My output for SNMPD process listening on interfaces:



root@opensips-1:~# netstat -pln | grep snmp
tcp        0      0 127.0.0.1:705           0.0.0.0:*               LISTEN      31456/snmpd
udp        0      0 0.0.0.0:161             0.0.0.0:*                           31456/snmpd
root@opensips-1:~


Adding Host in Zabbix

Open the Zabbix web interface:

Goto Configuration -> Hosts -> Create Host (Button on top right side)
Add a SNMP interface, fill in the details accordingly.



Once Host is created add a new monitoring "item" in that Host.


SNMP module gives some very useful info but I wanted to find out if there is any other way to look more into the OpenSIPS.
SNMP Data Example Graph - SIP Request/Responses In/Out

See Next Part of this Post using the MI_XMLRPC Module to collect more stats.

Links Consulted:

http://www.opensips.org/html/docs/modules/1.5.x/mi_xmlrpc.html#id228103
http://www.opensips.org/html/docs/modules/1.7.x/snmpstats.html
http://kamailio.org/docs/modules/1.3.x/snmpstats.html#AEN46
http://www.opensips.org/Resources/DocsTipsFaqs#toc3
http://remarks.peurat.net/integrating-opensips-and-cacti-using-xmlrpc/
http://www.personal.psu.edu/sus21/blogs/sven/2009/10/configuring-snmpstats-for-kamailio-openser.html
http://sysadvent.blogspot.com/2008/12/day-4-extending-net-snmps-snmpd.html



------------------------------------------------------------------------------------------------------------

root@opensips-1:~#snmpbulkwalk -v 2c -c public localhost OPENSER-MIB::openserDialog


OPENSER-MIB::openserCurNumDialogs.0 = Gauge32: 0
OPENSER-MIB::openserCurNumDialogsInProgress.0 = Gauge32: 0
OPENSER-MIB::openserCurNumDialogsInSetup.0 = Gauge32: 0
OPENSER-MIB::openserTotalNumFailedDialogSetups.0 = Counter32: 0
OPENSER-MIB::openserDialogLimitMinorThreshold.0 = INTEGER: -1
OPENSER-MIB::openserDialogLimitMajorThreshold.0 = INTEGER: -1
OPENSER-MIB::openserDialogUsageState.0 = INTEGER: idle(0)
OPENSER-MIB::openserDialogLimitAlarmStatus.0 = BITS: 00
OPENSER-MIB::openserDialogLimitMinorAlarm.0 = INTEGER: clear(0)
OPENSER-MIB::openserDialogLimitMajorAlarm.0 = INTEGER: clear(0)

root@opensips-1:/var/lib/mibs/ietf# snmpbulkwalk -v2c -Os -c public localhost OPENSER-REG-MIB::openser
openserSIPCommonMIB.1.1.1.0 = STRING: "SIP/2.0"
openserSIPCommonMIB.1.1.2.0 = Timeticks: (1308884) 3:38:08.84
openserSIPCommonMIB.1.1.4.0 = Hex-STRING: 08
openserSIPCommonMIB.1.1.5.1.4.1.4.192.168.56.3.5060 = STRING: "@"
openserSIPCommonMIB.1.1.7.1.2.1 = STRING: "METHOD_INVITE"
openserSIPCommonMIB.1.1.7.1.2.2 = STRING: "METHOD_CANCEL"
openserSIPCommonMIB.1.1.7.1.2.3 = STRING: "METHOD_ACK"
openserSIPCommonMIB.1.1.7.1.2.4 = STRING: "METHOD_BYE"
openserSIPCommonMIB.1.1.7.1.2.5 = STRING: "METHOD_INFO"
openserSIPCommonMIB.1.1.7.1.2.7 = STRING: "METHOD_UPDATE"
openserSIPCommonMIB.1.1.7.1.2.8 = STRING: "METHOD_REGISTER"
openserSIPCommonMIB.1.1.7.1.2.9 = STRING: "METHOD_MESSAGE"
openserSIPCommonMIB.1.1.7.1.2.10 = STRING: "METHOD_SUBSCRIBE"
openserSIPCommonMIB.1.1.7.1.2.11 = STRING: "METHOD_NOTIFY"
openserSIPCommonMIB.1.1.7.1.2.12 = STRING: "METHOD_PRACK"
openserSIPCommonMIB.1.1.7.1.2.13 = STRING: "METHOD_REFER"
openserSIPCommonMIB.1.1.7.1.2.14 = STRING: "METHOD_PUBLISH"
openserSIPCommonMIB.1.3.1.0 = Counter32: 500
openserSIPCommonMIB.1.3.2.0 = Counter32: 0
openserSIPCommonMIB.1.3.3.0 = Counter32: 0
openserSIPCommonMIB.1.3.4.0 = Counter32: 27438
openserSIPCommonMIB.1.3.5.0 = Counter32: 26948
openserSIPCommonMIB.1.6.1.0 = Gauge32: 6
openserSIPCommonMIB.1.8.1.0 = Counter32: 0
openserSIPCommonMIB.1.8.2.0 = Counter32: 3
openserSIPCommonMIB.1.8.3.0 = Counter32: 4
openserSIPServerMIB.1.3.1.0 = INTEGER: 3
openserSIPServerMIB.1.3.3.0 = INTEGER: 1
openserSIPServerMIB.1.3.4.0 = STRING: " "
openserSIPServerMIB.1.4.1.0 = Counter32: 0
openserSIPServerMIB.1.5.2.0 = Gauge32: 0
openserSIPServerMIB.1.5.3.0 = Gauge32: 4294967295
openserSIPServerMIB.1.5.4.0 = Gauge32: 1
openserSIPServerMIB.1.5.5.0 = Gauge32: 3600
openserSIPServerMIB.1.5.6.1.2.1 = STRING: "DefaultUser"
openserSIPServerMIB.1.5.6.1.2.16 = STRING: "40277@192.168.56.3"
openserSIPServerMIB.1.5.6.1.3.1 = Counter32: 0
openserSIPServerMIB.1.5.6.1.3.16 = Counter32: 0
openserSIPServerMIB.1.5.7.1.2.1.1 = STRING: "DefaultUser"
openserSIPServerMIB.1.5.7.1.2.16.1 = STRING: "sip:40277@192.168.82.5:6074"
openserSIPServerMIB.1.5.7.1.2.16.3 = STRING: "sip:40277@192.168.56.1:65118;rinstance=840080c63710e46b"
openserSIPServerMIB.1.5.7.1.3.1.1 = STRING: "DefaultUser"
openserSIPServerMIB.1.5.7.1.3.16.1 = STRING: "sip:40277@192.168.82.5:6074"
openserSIPServerMIB.1.5.7.1.3.16.3 = STRING: "sip:40277@192.168.56.1:65118;rinstance=840080c63710e46b"
openserSIPServerMIB.1.5.7.1.4.1.1 = Hex-STRING: 00 00 00 00 00 00 00 00
openserSIPServerMIB.1.5.7.1.4.16.1 = Hex-STRING: 07 DC 09 07 0F 12 0F 00
openserSIPServerMIB.1.5.7.1.4.16.3 = Hex-STRING: 07 DC 09 07 0F 10 3B 00
openserSIPServerMIB.1.5.7.1.5.1.1 = Hex-STRING: 00 00 00 00 00 00 00 00
openserSIPServerMIB.1.5.7.1.5.16.1 = Hex-STRING: 07 DC 09 07 10 12 0F 00
openserSIPServerMIB.1.5.7.1.5.16.3 = Hex-STRING: 07 DC 09 07 10 10 3B 00
openserSIPServerMIB.1.5.7.1.6.1.1 = STRING: "-0.01"
openserSIPServerMIB.1.5.7.1.6.16.1 = STRING: "-0.01"
openserSIPServerMIB.1.5.7.1.6.16.3 = STRING: "-0.01"
openserSIPServerMIB.1.5.8.0 = Counter32: 68
openserSIPServerMIB.1.6.1.0 = Counter32: 240
openserSIPServerMIB.1.6.2.0 = Counter32: 0
openserMIB.1.2.3.1.0 = Gauge32: 0
openserMIB.1.2.3.2.0 = INTEGER: -1
openserMIB.1.2.3.3.0 = INTEGER: -1
openserMIB.1.2.4.1.0 = Hex-STRING: 00
openserMIB.1.2.4.2.0 = INTEGER: 0
openserMIB.1.2.4.3.0 = INTEGER: 0
openserMIB.1.3.2.1.0 = Gauge32: 0
openserMIB.1.3.2.2.0 = Gauge32: 0
openserMIB.1.3.2.3.0 = Gauge32: 0
openserMIB.1.3.2.4.0 = Counter32: 0
openserMIB.1.3.2.5.0 = INTEGER: -1
openserMIB.1.3.2.6.0 = INTEGER: -1
openserMIB.1.3.3.1.0 = INTEGER: 0
openserMIB.1.3.4.1.0 = Hex-STRING: 00
openserMIB.1.3.4.2.0 = INTEGER: 0
openserMIB.1.3.4.3.0 = INTEGER: 0



root@opensips-1:/var/lib/mibs/ietf# snmpbulkwalk -O s -v 2c -c public localhost OPENSER-SIP-SERVER-MIB::openserSIPServerObjects
openserSIPProxyStatefulness.0 = INTEGER: callStateful(3)
openserSIPProxyRecordRoute.0 = INTEGER: true(1)
openserSIPProxyAuthMethod.0 = BITS: 20 digest(2)
openserSIPNumProxyRequireFailures.0 = Counter32: 0
openserSIPRegMaxContactExpiryDuration.0 = Gauge32: 0 seconds
openserSIPRegMaxUsers.0 = Gauge32: 4294967295
openserSIPRegCurrentUsers.0 = Gauge32: 1
openserSIPRegDfltRegActiveInterval.0 = Gauge32: 3600 seconds
openserSIPUserUri.1 = STRING: DefaultUser
openserSIPUserUri.16 = STRING: 40277@192.168.56.3
openserSIPUserAuthenticationFailures.1 = Counter32: 0
openserSIPUserAuthenticationFailures.16 = Counter32: 0
openserSIPContactDisplayName.1.1 = STRING: DefaultUser
openserSIPContactDisplayName.16.1 = STRING: sip:40277@192.168.82.5:6074
openserSIPContactDisplayName.16.3 = STRING: sip:40277@192.168.56.1:65118;rinstance=840080c63710e46b
openserSIPContactURI.1.1 = STRING: DefaultUser
openserSIPContactURI.16.1 = STRING: sip:40277@192.168.82.5:6074
openserSIPContactURI.16.3 = STRING: sip:40277@192.168.56.1:65118;rinstance=840080c63710e46b
openserSIPContactLastUpdated.1.1 = STRING: 0-0-0,0:0:0.0
openserSIPContactLastUpdated.16.1 = STRING: 2012-9-7,14:35:52.0
openserSIPContactLastUpdated.16.3 = STRING: 2012-9-7,14:22:58.0
openserSIPContactExpiry.1.1 = STRING: 0-0-0,0:0:0.0
openserSIPContactExpiry.16.1 = STRING: 2012-9-7,15:35:52.0
openserSIPContactExpiry.16.3 = STRING: 2012-9-7,15:22:58.0
openserSIPContactPreference.1.1 = STRING: -0.01
openserSIPContactPreference.16.1 = STRING: -0.01
openserSIPContactPreference.16.3 = STRING: -0.01
openserSIPRegUserLookupCounter.0 = Counter32: 66
openserSIPRegAcceptedRegistrations.0 = Counter32: 238
openserSIPRegRejectedRegistrations.0 = Counter32: 0

2 comments:

  1. Hi
    Nice work, thanks.
    However, at times snmpstats seems to get confused, as it returns 4294967295 (unsigned int with all bits to 1) for the GAUGE value of IN PROGRESS dialogs.
    Also your example above seems to be affected
    openserSIPServerMIB.1.5.3.0 = Gauge32: 4294967295

    How can I fix this?
    Cheers

    ReplyDelete
    Replies
    1. Hi,

      Thanks for trying this. Since this is just a personal blog, I'll request you to post the issues on mailing list where a large number of experts will respond to this issue. If you still seek my help then you're welcome.

      Delete