Mac OS X Server: How to Install, Enable, and Configure SNMP

This document explains how to set up the Simple Network Management Protocol (SNMP) on Mac OS X Server.
This article has been archived and is no longer updated by Apple.
Installing SNMP

To use SNMP for monitoring or data collection, an SNMP agent (snmpd) must be running on the monitored Mac OS X Server host (computer). Mac OS X Server 10.1.5 or later includes a version of SNMP (UCD-SNMP v. 4.2.3 or later).

If you do not have the file /usr/sbin/snmpd, then SNMP is not installed.

The following operating systems require that SNMP be built and installed:
  • Mac OS X Server 10.1.4 or earlier

If you have access to a Mac OS X Server 10.1.5 or later Admin CD , the SNMP package on the CD may be used to install UCD-SNMP 4.2.3 on these systems.

Note: Mac OS X Server 10.1.5 is available only with Xserve computers shipped before the release of Mac OS X Server 10.2.

If you do not have access to the CD, you may download current SNMP source from the NET-SNMP Project Home Page (http://www.net-snmp.org/).

Note: Apple only provides technical support for the SNMP tools on the Admin CD when they are used with Mac OS X Server 10.1.5 or later.

Warnings
    1. Once SNMP is active, anyone with a route to the SNMP host will be able to collect SNMP data from it. To learn more, consult the various SNMP information sources listed below.

    2. The default configuration of snmpd uses privileged port 161. For this reason and others, it must be executed by root or using setuid. You should only use setuid as root if you understand the ramifications. If you do not, seek assistance or additional information. There are flags available for snmpd that will change the uid and gid of the process after it starts. See the snmpd man page for more information.


Starting snmpd

Follow these steps for Mac OS X Server 10.1.5 or later:
    1. Open the file: /etc/hostconfig

    2. Locate the line:

    APPLETALK_HOSTNAME

    3. Immediately above, add this new line:

    SNMPSERVER:=-YES-

    4. Save the file.

Note: For further instruction on editing configuration files, including important precautionary statements, see technical document 106619, "Mac OS X Server: How to Edit Configuration Files".

This change to hostconfig causes snmpd to be executed during system startup, with no options, as dictated by the file /System/Library/StartupItems/SNMP/SNMP.

As an alternative, the snmp agent (/usr/sbin/snmpd) can be executed at the command line at any time.


Configuring snmpd

The configuration (conf) file for snmpd is typically at /usr/share/snmp/ and named "snmpd.conf" or "snmpd.local.conf". If you have an environment variable SNMPCONF, snmpd will read any files named "snmpd.conf" and "snmpd.local.conf" in these directories. The snmpd process can be started with a "-c" flag to indicate other conf files. See the snmpd man page for more information on which conf files can be used.

Configuration files can be created and installed more elegantly using the included script /usr/bin/snmpconf. As root, use this script with the "-i" flag to install the file at /usr/share/snmp/. Otherwise the default location for the file to be written is the user's home directory (~/). Note that only root has write permission for /usr/share/snmp/.

Since snmpd reads its conf files at startup, changes to the conf files require that the process be stopped and restarted. You may stop snmpd with ProcessViewer or at the command line (kill -HUP <pid>).


Example of SNMP Configuration

I. Customize data

To customize the data provided by snmpd, you may add an snmpd.conf file using /usr/bin/snmpconf. As root or using sudo, execute this command:

/usr/bin/snmpconf -i

You will then see a series of text menus. Make these choices in this order:
    1. Select File: 3 (snmpd.conf)
    2. Select section: 5 (System Information Setup)
    3. Select section: 1 (The [typically physical] location of the system.)
    4. The location of the system: type text string here -- such as "server_room"
    5. Select section: f (finish)
    6. Select section: f (finish)
    7. Select File: q (quit)

Notice you have created an snmpd.conf file with creation date of today: ls -l /usr/share/snmpd.conf

II. Start snmpd as root

To start snmpd, execute this as root:

/usr/sbin/snmpd

If snmpd is already running, HUP the process instead:

set x=`ps cax |grep snmpd |awk '{print $1}'` ; kill -HUP $x ;

Note that the snmpd process is now running:

ps ax |grep snmpd

III. Collect SNMP information from the host

To get the SNMP-available information you just added, execute this command from a host that has the SNMP tools installed:

/usr/sbin/snmpget hostname public system.sysLocation.0

Note: You would replace "hostname" with the actual name of the target host.

You should see location you provided. In this example, you would see:

system.sysLocation.0 = server_room

The other options in the menu you were working in are:

/usr/bin/snmpget hostname public system.sysContact.0
/usr/bin/snmpget hostname public system.sysServices.0

The final ".0" indicates you are looking for the index object. The word "public" is the name of the snmp community which you did not alter. If you need information on either of these or explanations of snmp syntax, there are tutorials available on net-snmp.sourceforge.net.


Additional tools

Other than snmpget, there are a variety of snmp based tools and suites both free and commercial with varying complexity and reporting:

Intermapper by Dartware
http://dartware.com/

HP OpenView mrtg and rrdtool
http://people.ee.ethz.ch/~oetiker/webtools/mrtg/

You may also search for perl modules.


Additional information

Man pages

man -k snmp will provide a list of the known man pages.

Web sites

The Net SNMP-Project
http://www.net-snmp.org/
http://net-snmp.sourceforge.net/

Cisco Connection Documentation (Cisco Systems)
http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/snmp.htm

Books

_Essential_SNMP_ by Douglas Mauro, Kevin Schmidt
Publisher: O'Reilly (First Edition July 2001)
ISBN: 0-596-00020-0, 326 pages

_Snmp,_Snmpv2,_Snmpv3,_and_Rmon_1and_2,
Publisher: Addison, Wesley. (Third Edition 1999)


Information about products not manufactured by Apple is provided for information purposes only, and does not constitute Apple's recommendation or endorsement. Please contact the vendor for additional information.
Published Date: Oct 10, 2016