Saturday, June 26, 2010

Montioring trixbox via snmp

One of the hard things when you have a system out there is how to make sure that you know when something goes wrong.  There are a number of ways this can be achieved, but Seeing that it's not likely to be the only system you need to monitor you will want to setup a monitoring server somewhere.  After much deliberation I decided to go with monitoring it via snmp because it's an general standard that works well for monitoring and most monitoring systems that use snmp collect some good data that I can use at a glance.  Personally I use opennms to monitor, but you probably already have your own, or else you wouldn't be here.
Let's get down to business, trixbox systems have the snmp support built in, they just need to be told how to do it.  To make sure that you have all the packages

yum -y install net-snmp net-snmp-devel net-snmp-utils bzip2-devel newt-devel lm_sensors-devel

Now that we have everything we need we just need to tell snmp how to get the info... The info I have is for snmp version 3,  which is the most secure.

echo "#trixbox user
rwuser trixboxsnmp priv
createUser trixboxsnmp SHA !ChangemE! AES" >> /etc/snmp/snmp.conf

This command adds the trixboxsnmp user to the snmp, don't forget to change the password.
Now we need to setup the snmp agent for asterisk:

echo "# trixbox configuration
master agentx
agentXSocket /var/agentx/master
agentXPerms 0660 0550 asterisk asterisk" >> /etc/snmp/snmpd.conf

Now we need to configure asterisk to use the snmp agent.  To do that we need to configure the asterisk file res_snmp.conf.  Below is the configuration you need in there, it's the whole file, so you can make sure that your file looks like this /etc/asterisk/res_snmp.conf

;
; Configuration file for res_snmp
;

[general]
; We run as a subagent per default -- to run as a full agent
; we must run as root (to be able to bind to port 161)
subagent = yes
; SNMP must be explicitly enabled to be active
enabled = yes


Now we are ready to go. all we have to do is restart asterisk and snmp

/etc/init.d/snmpd restart
/etc/init.d/snmptrapd restart
amportal restart


That is pretty much it, although there is a little permission issue with the agentx dir so we need to do the following so that asterisk can update the agent file, this is how to fix it and get it all

chmod 755 /var/agentx

Now we just need to setup our monitoring server to collect the data.  If you are using opennms, here is a link to get it going on there
http://www.opennms.org/blog/?p=227

No comments:

Post a Comment