Simple Network Management Protocol

From freebsd.xn--wesstrm-f1a.se

Jump to: navigation, search

Contents

Overview

SNMP is a framework to monitor and manage various system components. You will need SNMP to collect some of the statistics for your router.

Instructions

As usual you install it from ports.

# cd /usr/ports/net-mgmt/net-snmp
# make
# make install clean
# rehash
Note: From version 5.4.2.1_5 you should enable the new config option MFD_REWRITES if you build net-snmp on a 64-bit platform. This will enable experimental support for 64-bit counters and remove errors like these in your snmpd.log:
truncating integer value > 32 bits

The output from the installation tells you what you have to add to /etc/rc.conf to make the SNMP daemon start at boot time. You have no need for the SNMP trap daemon so you can skip those lines. The output shows how to use multiple config files but this guide will only make use of one so you have to remove the second option.

snmpd_enable="YES"
snmpd_flags="-a"
snmpd_conffile="/usr/local/share/snmp/snmpd.conf"

There's a script to help you create the config file for the SNMP daemon. Adjust the contact and location information to match your own. You can also skip the configuration for SNMP version 3 since all you need for now is supported by version 1.

# snmpconf -ig basic_setup

Do you want to configure the information returned in the system MIB group (contact info, etc)? (default = y): y
The location of the system: North Pole
The contact information: Santa Claus
Do you want to properly set the value of the sysServices.0 OID (if you don't know, just say no)? (default = y): y
does this host offer physical services (eg, like a repeater) [answer 0 or 1]: 0
does this host offer datalink/subnetwork services (eg, like a bridge): 1
does this host offer internet services (eg, supports IP): 1
does this host offer end-to-end services (eg, supports TCP): 1
does this host offer application services (eg, supports SMTP): 1
Do you want to configure the agent's access control? (default = y): y
Do you want to allow SNMPv3 read-write user based access (default = y): n
Do you want to allow SNMPv3 read-only user based access (default = y): n
Do you want to allow SNMPv1/v2c read-write community access (default = y): y
Enter the community name to add read-write access for: private
The hostname or network address to accept this community name from [RETURN for all]:
The OID that this community should be restricted to [RETURN for no-restriction]:
Do another rwcommunity line? (default = y): n
Do you want to allow SNMPv1/v2c read-only community access (default = y): y
The community name to add read-only access for: public
The hostname or network address to accept this community name from [RETURN for all]:
The OID that this community should be restricted to [RETURN for no-restriction]:
Do another rocommunity line? (default = y): n
Do you want to configure where and if the agent will send traps? (default = y): n
Do you want to configure the agent's ability to monitor various aspects of your system? (default = y): n

The configuration is automatically copied to /usr/local/share/snmp and we can now start the daemon.

# /usr/local/etc/rc.d/snmpd start
Starting snmpd.

A small test that the daemon actually responds to queries can be made with snmpwalk

# snmpwalk -Os -c public -v 1 localhost system

The command should produce a nice cryptic output with at least a few recognizable values.

Logrotating is made like this:

# echo "/var/log/snmpd.log			644  3	   100  *     JC     /var/run/snmpd.pid" >> /etc/newsyslog.conf

Summary

  • /usr/local/share/snmp/snmpd.conf is the default configuration file for the SNMP daemon.
  • snmpconf -ig basic_setup can be used to create an initial config.
  • /var/log/snmpd.log is the log file.

Unresolved issues

  • The default location for the config file is puzzling since all ports usually store their configurations in /usr/local/etc. Be aware that this location might change with a future upgrade.

References

Personal tools