Categories

Archives

Setup SNMP on an Asterisk server

Today I happened to troubleshoot a server in a remote part of the world, which I had shipped with SNMP and MRTG installed. It was a very wise decision to do this at that time, as it made an important troubleshooting very simple, which otherwise could have wasted days and still yielded no results.

While going over my notes in this regard, I thought to put this information here as well if it could help someone else who is looking to do a similar setup. But you should know that setting up SNMP can be tricky and the following might not work for you.

SNMP – Simple Network Monitoring Protocol, as it name suggests, is a protocol used to monitor various properties of network equipment. These properties are identified by something called OIDs (Object Identifiers) which are long numeric strings and identify various things, like hardware version, time on the device, data flow rate, and tons of other stuff. OIDs and grouped in what is called a MIB (Management Information Base). Asterisk has a list of its own OIDs which provide various pieces of information over the SNMP when requested by a software or hardware which is interested in that information. More on SNMP you can read on the Internet.

The following assumes that you do have SNMP module installed with your asterisk installation. You select this when running the #make menuselect just before the installation of asterisk. See my blog on asterisk installation for more details.

SNMP Setup

Following are the steps which I used on this CentOS 5.3/Asterisk 1.4 machine to setup SNMP:

yum install net-snmp-util

Created /etc/snmp/snmpd.conf with the following:

rocommunity public
master agentx
agentXSocket /var/agentx/master
agentXPerms 0660 0550 nobody asterisk
com2sec local localhost public
com2sec mynetwork0 192.168.1.0 public
com2sec MyROGroup any local
com2sec MyROGroup any mynetwork0
view all included . 1
access MyROGroup "" any noauth 0 all none none

Going into the detail of what all these lines mean is not the goal here, but the words in bold red are the ones which will be specific to your own network. The word ‘public’ is like a password, and almost all SNMP devices come preconfigured with this password. The user is ‘asterisk’, in your setup it might be ‘root’ or some other user.

Asterisk SNMP Config

Now add the following in /etc/asterisk/res_snmp.conf. If the file doesn’t exist, create one:

[general]
subagent = yes
enabled = yes

And now copy the Asterisk related MIB to the SNMP folder:

cp /usr/share/doc/asterisk-1.4.22/digium-mib.txt /usr/share/snmp/mibs
cp /usr/share/doc/asterisk-1.4.22/asterisk-mib.txt /usr/share/snmp/mibs

It is possible that these files don’t exist on your system, in which case you’ll have to get them from the Internet.

Next do the following:

export MIBS=+ASTERISK-MIB
chmod 755 /var/agentx

Done

This is all. Now restart asterisk, add snmpd and snmptrapd in chkconfig and start these services as daemons:

chkconfig snmpd on
chkconfig snmptrapd on
service snmpd start
service snmptrapd start

Testing it

In order to test if SNMP is properly installed, do the following:

snmpwalk -On -c public -v 2c localhost asterisk

and it’ll give you a list of the asterisk related MIBS

What’s Next?

Now that you have the SNMP setup and working, how do you see it? For this we shall use MRTG, about which I shall write in a separate blog soon.

Other posts related to this topic

  • Proxmox and Two Subnets on the Same Network Interface, Properly Routed
    This was a little bit tricky, but thanks to the power of the freely available (though hard to find sometimes) knowledge on the Internet, and Google's searches, I just finished this task and thought to write a blog about it. Though the following is fo...
  • Phone Reminders – Make your life easier
    A phone reminder is a reminder which is sent to you over the phone. It amazingly makes various things in your life more manageable which otherwise would stay mismanaged because you simply forget about them. Life is busy for everyone in this age, an...
  • Getting started with AEL
    AEL stands for Asterisk Extensions Language. It is intended to make writing dialplans easier than the standard syntax used in extensions.conf. The standard syntax is not very user friendly, makes it difficult to write complex dialplans, and makes it ...
  • Keep track of number of active calls in Asterisk
    How to keep track of the total number of calls in Asterisk? There is no predefined variable yet which keeps track of this very important piece of information, which is sometimes very critical to make certain decisions in a dialplan. There are vari...
  • Scaling an Asterisk installation
    Scaling basically means that if the hardware in your system can't handle any more load, then the system should be able to take additional hardware and share extra load with it. In case of VoIP calls, if you server is capable of handling, lets say 300...
  • What to do when your asterisk is hacked
    There are various types of malicious hacks on Linux systems. When dealing with Asterisk server, most common one is that of registering a SIP extension from a hacker's machine and use it to make expensive international calls. This is financi...
  • Securing Asterisk – Fail2Ban
    Fail2Ban from www.fail2ban.org is a great tool to block unwanted IP addresses from accessing your server. It works along with iptables, and checks the log files for predefined patterns, and on finding a matching pattern blocks the IP address ...
  • SIP on Android / VoIP Client
    One of the first apps which I installed on my Milestone/Droid was sipdroid. This app is a softphone and very easy and straight forward to use. To my surprise the voice quality on it was just fine, though it uses ulaw, which consumes the most bandwidt...
  • Monitoring Asterisk using AstAssisstant
    By the time of this posting (June 2010 ) there is still a great need for a good open source monitoring solution for Asterisk. Somebody had written Flash OP many years ago but it never evolved beyong a certain point, leaving it very ugly looking and v...
  • How to setup a VoIP Server
    I got introduced with VoIP in late 2004. It was one of my very good friends, who ran a successful telecom company called Telcan (www.telcan.net), now called Callture (www.callture.com) who told me that there was a software called Asterisk w...

2 comments to Setup SNMP on an Asterisk server

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Spam protection by WP Captcha-Free