I came upon some threads re SNMP here the other day and found a distinct lack of attention to documenting the implementation and behavior of SNMP in regards to Asterisk, FreePBX and Distro with many forum members providing unhelpful posts and external links instead of actually discussing it to the benefit of the community.
So… I hope this helps those seeking answers to SNMP in direct relation to the product. The trick is just to get over the hump of understanding how the SNMP implementation differs to a standard OS install… Asterisk SNMP is a sub-agent of the yum-installed base SNMP package.
In this example, I’ve used a legacy (pre-Sangoma) model of FreePBX (2.11.0.43). I know this is old (ish) but it’s a good starting point as many folks will have oldish deployments out there. I’ll update this guideline with a modern Distro when I do my next site deployment.
Now… Myself, I only using SNMP for traffic monitoring so i haven’t full tested the Asterisk and Digium MIBs but we can work through that bit later. You will need both the Asterisk and Digium MIBs as they reference each other. I’m not sure if i’m allowed to post the MIB content here but it would become outdated anyway so I’ll just reference the Digium public definitions.
Home - Asterisk Documentation
For recent versions of Distro, you should be able to get snmp functioning pretty easily.
ie… no need to compile/recompile anything. You just yum install what you need and reconfigure snmpd.
1. Install SNMP and Dependencies:
# yum install net-snmp net-snmp-utils net-snmp-devel
Important!
One thing that I have found is that when you install net-snmp, you don’t really know what state the default configuration is in and sometimes it just doesn’t work out of the box. So… you should start with a clean slate by discarding the default configs then reconfigure by answering all the questions in the setup wizard…
cd /etc/snmp
mv snmpd.conf snmpd.conf.orig
mv snmptrapd.conf snmptrapd.conf.orig
snmpconf -g basic_setup
Start the snmpd service and enable start on boot.
# service snmpd start
# chkconfig snmpd on
Test It:
# snmpwalk -c public -v 2c localhost <-public is what I chose as the rocommunity. yours may differ.
Now you're ready to monitor network traffic and OS but not Asterisk.
##2. Asterisk SNMP Module Install:
I only use traffic monitoring for my deployments so I haven’t deployed and tested the full Asterisk functionality but it goes something like this… Please do contribute to this knowledge.
Install the Asterisk snmp module:
# yum install asterisk-snmp <–This command might not install the exact correct version. See below.
Important!
When you yum install asterisk-snmp package, it may not install the exact right version, especially if you are installing retrospectively and module version numbers advance… It’s not considered to be a bug as such so just be aware that you may need to target the exact version instead. If this happens, you may see an error like this when asterisk starts up…
Module ‘res_snmp.so’ was not compiled with the same compile-time options as this version of Asterisk
So… This command will tell you what version you need.
# rpm -qa | grep asterisk | grep core
—> asterisk13-core-13.12.1-1.shmz65.1.143.x86_64
If the version number returned is not the same as the yum asterisk-snmp package then you will need to manually install the correct version. For example:
# yum install asterisk13-snmp-13.12.1-1.shmz65.1.143.x86_64
Testing
You can confirm the module is loaded once you restart amportal / fwconsole and connect with “asterisk -r”
# module show like snmp
Module Description Use Count Status Support Level
res_snmp.so SNMP [Sub]Agent for Asterisk 0 Running extended
1 modules loaded
##3. Asterisk Sub-Agent Integration:
Install Dependancies…
# yum install lm_sensors lm_sensors-devel newt newt-devel bzip2 bzip2-devel
Asterisk monitoring requires the use of a sub-agent of snmp.
So… you need to load the sub-agent daemon AgentX then install Asterisk MIB definitions.
Enable agentX in snmp.
# nano /etc/snmp/snmpd.conf
#Enable AgentX support
master agentx
# Set permissions on AgentX socket and containing
# directory such that process in group 'asterisk'
# will be able to connect
agentXPerms 0660 0550 nobody asterisk
Enable sub-agent in Asterisk snmp module…
# nano /etc/asterisk/res_snmp.conf
[general]
subagent = yes
enabled = yes
Restart Services
# service snmp restart
# amportal restart <— This will later be deprecated and become fwconsole
You can confirm that AgentX is loaded by stopping Amportal/fwconsole and running “asterisk -cvvvvvvvvvv”
you should see the line “NET-SNMP version 5.5 AgentX subagent connected”
This also confirms that the module re_snmp is loaded.
Create an asterisk user for snmp v3
just append the following to /etc/snmp/snmpd.conf
# Asterisk user
rwuser asteriskUser priv
createUser asteriskUser SHA asteriskPasswd AES
mibs +ASTERISK-MIB
MIBS:
Lookup the Asterisk MIB defs at Home - Asterisk Documentation
Install the ASTERISK-MIB definitions into /usr/share/snmp/mibs/ASTERISK-MIB.txt
Install the DIGIUM-MIB definitions into /usr/share/snmp/mibs/DIGIUM-MIB.txt
Restart Amportal and SNMP
# amportal restart <— This will later be deprecated and become fwconsole
# service snmpd restart
Good MIB knowledge here…
http://net-snmp.sourceforge.net/wiki/index.php/Loading_your_own_MIBs
Now test it using snmp v3 with auth
snmpwalk -v 3 -u asteriskUser -l authPriv -a SHA -A asteriskPasswd -x AES -X asteriskPasswd localhost asterisk
So… I hope this helps clear things up or at least set you on the right path.
I will return here and update this for a modern Sangoma edition of Distro soon.
Cheers,
Nathan