Packetwatch.net

SNMP in Solaris



Last modified: Nov. 11, 2010

Contents
1 - Summary
2 - Dependencies
3 - Net-SNMP installation
4 - Service configuration
5 - Snmpget example
6 - Service check


1 - Summary

This guide will show how to install SNMP in Solaris. SNMP is a network protocol
used to monitor network devices. We will install Net-SNMP. This has been tested
in Solaris 9.


2 - Dependencies

Thet net-snmp package we will use is from http://www.sunfreeware.com/. The
following dependencies are needed. You can use either the libgcc or gcc
package. In this case, we will use the gcc package.
# cd ~
# mkdir net-snmp
# cd net-snmp/
# wget ftp://ftp.sunfreeware.com/pub/freeware/sparc/9/openssl-$rel-sol9-sparc-local.gz
# wget ftp://ftp.sunfreeware.com/pub/freeware/sparc/9/gcc-$rel-sol9-sparc-local.gz
# gunzip openssl-$rel-sol9-sparc-local.gz
# gunzip gcc-$rel-sol9-sparc-local.gz
# sudo pkgadd -d openssl-$rel-sol9-sparc-local.gz
Password:
# sudo pkgddd -d gcc-$rel-sol9-sparc-local.gz
Password:


3 - Net-SNMP installation

Download and install the net-snmp package.
# wget ftp://ftp.sunfreeware.com/pub/freeware/sparc/9/netsnmp-$rel-sol9-sparc-local.gz
# gunzip netsnmp-$rel-sol9-sparc-local.gz
# sudo pkgadd -d  netsnmp-$rel-sol9-sparc-local.gz
Password:
# cd ~
# rm -fr net-snmp/

  
4 - Service configuration

Find where the configuration file should be put.
# strings /usr/local/sbin/snmpd | grep .conf
  (config search path: %s)
display configuration file directives understood
read FILE(s) as configuration file(s)
do not read the default configuration files
Reconfiguring daemon

You can create your own configuration file. For this example, we will use a
read only community name of public. We will put the configuration in the
/usr/local/etc/ directory.
  rocommunity public
  syslocation "Test"
  syscontact "John Doe"
# sudo vim /usr/local/etc/snmpd.conf
Password:
# sudo chown root:root /usr/local/etc/snmpd.conf
Password:

Enable the net-snmp service so that it will start when the system starts up.
Here is a script I created to start and stop the net-snmp daemon.
  #!/bin/sh

  CONFIG=/usr/local/etc/snmpd.conf
  DAEMON=/usr/local/sbin/snmpd
  OPTIONS="-c $CONFIG -Lf /dev/null -p /var/run/snmpd.pid"

  case "$1" in
          start)
                  if [ -f $CONFIG -a -f $DAEMON ]; then
                          echo 'Starting snmpd.'
                          $DAEMON $OPTIONS
                  fi
                  ;;
          stop)
                  echo 'Stopping snmpd.'
                  pkill -TERM -x snmpd
                  ;;
          *)
                  echo "Usage: $0 { start | stop }"
                  exit 1
                  ;;
  esac
# sudo vim /etc/init.d/snmpd
Password:
# sudo chown root:sys /etc/init.d/snmpd
Password:
# sudo chmod 744 /etc/init.d/snmpd
Password:
# sudo cp /etc/init.d/snmpd /etc/rc3.d/S95snmpd
Password:
# sudo chown root:sys /etc/rc3.d/S95snmpd
Password:

Before starting the service, make sure that udp port 161 is open in case you
are running firewall software.

Start the net-snmp service.
# sudo /etc/init.d/snmpd start
Password:
Starting snmpd.
# sudo pgrep -d ' ' snmpd
Password:
2577


5 - Snmpget example

From another computer, run snmpget to view some SNMP information.
# sudo snmpget -Os -c public -v 2c server.test.com sysName.0 sysLocation.0 sysContact.0
Password:
sysName.0 = STRING: server
sysLocation.0 = STRING: "Test"
sysContact.0 = STRING: "John Doe"


6 - Service check

Reboot your computer. Log in like normal and check to see that the net-snmp
service is running. That's it, now you have snmp running in Solaris.
# sudo shutdown -y -g 0 -i 6
Password:
# sudo pgrep -d ' ' snmpd
Password:
267


Last modified: Thu Jan 1 00:00:00 1970 UTC
Packetwatch Research 2002-2017.