Enabling SNMP on Centos / RHEL
Quick method, immediately after install:
yum install net-snmp
yum install net-snmp-utils
snmpconf -g basic_setup
Pick reasonable values. I enable one of each kind of monitor so I have some examples, and only enable snmp 1 / 2c READONLY communities with a community string specific to my setup. I enable one rocommunity for localhost testing and then create another with the same community name reachable from my cacti server.
This ends up looking like this in /etc/snmp/snmpd.conf (use your settings)
rocommunity MYCOMMUNITY1234 cactiserver.localdomain.com
rocommunity MYCOMMUNITY1234 localhost
I use localhost rather than hostname so the config is portable across machines.
FOR those like me that are too lazy to walk to the console and use the GUI, otherwise enable snmp/UDP in the GUI.
iptables --insert RH-Firewall-1-INPUT 9 --protocol udp --dport 161 -j ACCEPT
note – rule 9 in the chain is about right if you have ssh and http enabled. Just want it to be before the final rule.
Do an iptables –list and count down to right before the final REJECT rule – use that number (one less than reject) instead of 9.
chkconfig snmpd on
service snmpd start
lsof -i UDP:snmp
#confirm its listening on port
snmpwalk -Os -c MYCOMMUNITY1234 -v 1 localhost system
#confirm its up locally
snmpwalk -On -c MYCOMMUNITY1234 -v 1 localhost prTable
#look at process monitor you setup during config, get MIB number
snmpwalk -On -c MYCOMMUNITY1234 -v 1 localhost dskTable
#look at disk monitor you setup during config, get MIB number
Etc. You can read the whole list in /usr/share/snmp/mibs/UCD-SNMP-MIB.txt in the section called ‘Current UCD core mib table entries’.
#Test again from cactiserver
snmpwalk -Os -c MYCOMMUNITY1234 -v 1 TARGETMACHINE system
It works? —
iptables-save > /etc/sysconfig/iptables
(or it won’t work after you reboot!)
DONE!