net-snmp Installation and Configuration Method

Tadashi Shigeoka ·  Sat, June 23, 2012

I’ll introduce the steps to install net-snmp with yum and configure it.

Installing net-snmp

First, check if net-snmp is installed.

yum list installed | grep net-snmp
yum -y install net-snmp
yum -y install net-snmp-utils

Edit net-snmp Configuration File

Edit the net-snmp configuration file, snmpd.conf.

/etc/snmp/snmpd.conf

#       sec.name  source          community
com2sec notConfigUser  default       my-community

group   notConfigGroup v1           notConfigUser
group   notConfigGroup v2c           notConfigUser

view    systemview    included   .1
access  notConfigGroup ""      any       noauth    exact  systemview none none

disk / 10000
disk /boot 10000

proc httpd
proc postmaster

exec .1.3.6.1.4.1.2021.54 hdNum /usr/local/bin/snmpdiskio hdNum
exec .1.3.6.1.4.1.2021.55 hdIndex /usr/local/bin/snmpdiskio hdIndex
exec .1.3.6.1.4.1.2021.56 hdDescr /usr/local/bin/snmpdiskio hdDescr
exec .1.3.6.1.4.1.2021.57 hdInBlocks /usr/local/bin/snmpdiskio hdInBlocks
exec .1.3.6.1.4.1.2021.58 hdOutBlocks /usr/local/bin/snmpdiskio hdOutBlocks

・disk / 10000

Notify syscontact when it reaches a minimum of 10MB. If you want to notify when it reaches a minimum of 10%, modify the 10000 part to 10%.

Starting net-snmp

Start net-snmp.

service snmpd start

Confirmation is done using the following command:

snmpwalk -v1 -c community_name localhost

The community name corresponds to what was set in snmpd.conf. In my case, it’s my-community.

After executing this command, if various displays appear, the installation, configuration, and startup should have been performed correctly.

Enable automatic startup of net-snmp

chkconfig  --list snmpd
snmpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off
chkconfig snmpd on
chkconfig  --list snmpd
snmpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off

This time, since I’m using net-snmp for Nagios monitoring, I’ll open port 161.

-A INPUT -p udp --dport 161 -j ACCEPT

Let’s restart to apply the iptables settings.

service iptables restart

That’s all.

Reference Information

That’s all from the Gemba.