Archive for the ‘SNMP’ Category

SNMP Basic Configuration

August 27, 2008

The following link contains the very basic configuration for snmp to work……

Installing Net-SNMP

Set your PATH.

$ export PATH=$PATH:/usr/ccs/bin:/usr/local/bin:/usr/sfw/bin
Stop and disable Sun’s SNMP.

svcadm disable svc:/application/management/snmpdx:default

svcadm disable svc:/application/management/sma:default

svcadm disable svc:/application/management/dmi:default
# mv /etc/rc3.d/K76snmpdx /etc/rc3.d/S76snmpdx

Edit the /etc/services file and change the existing SNMP entry to reflect the following:

net-snmpd 161/udp
Download and install Net-SNMP.

$ wget http://umn.dl.sourceforge.net/sourceforge/net-snmp/net-snmp-5.3.1.tar.gz

$ gunzip -c net-snmp-5.3.1.tar.gz | tar -xvf –

$ cd net-snmp-5.3.1

$ ./configure –with-mib-modules=”host disman/event-mib ucd-snmp/diskio smux agentx mibII/mta_sendmail” –with-cc=gcc
You will be prompted with series of questions when you run the configure. Use SNMP version 1 when prompted and you can use the defaults for the rest of the questions. Once you have answered all the questions and completed the configure, complete the Net-SNMP install.

$ make

# make install

Now Create the /usr/local/share/snmp/snmpd.conf Net-SNMP configuration file running snmpconf command.
Add Net-SNMP to the Service Management Facility (SMF) by creating the /var/svc/manifest/network/net-snmp.xml Net-SNMP manifest, which defines what services are required for Net-SNMP to run.[collect the net-snmp.xml file from any host where SNMP already configured]

# chown root:sys /var/svc/manifest/network/net-snmp.xml
# chmod 444 /var/svc/manifest/network/net-snmp.xml

Finally, Create the /lib/svc/method/svc-net-snmp SMF method file, which is used to start the Net-SNMP service.

      #!/usr/bin/bash
       . /lib/svc/share/smf_include.sh
      # Start processes required for snmpd
      if [ -x /usr/local/sbin/snmpd ]; then
        /usr/local/sbin/snmpd
      else
          echo "snmpd is missing or not executable."
          exit $SMF_EXIT_ERR_CONFIG
      fi
      exit $SMF_EXIT_OK

Set the appropriate ownership and permissions on the method file.

# chown root:bin /lib/svc/method/svc-net-snmp
# chmod 555 /lib/svc/method/svc-net-snmp

Validate the manifest file and import the new net-snmp service.

# svccfg validate /var/svc/manifest/network/net-snmp.xml
# svccfg import /var/svc/manifest/network/net-snmp.xml

Verify the service is installed.

# svcs net-snmp
STATE          STIME    FMRI
disabled       11:02:56 svc:/system/net-snmp:default

Start the Net-SNMP ervice.

# svcadm enable net-snmp
# svcs net-snmp
STATE          STIME    FMRI
online         11:05:38 svc:/system/net-snmp:default
 Created a /etc/rc3.d/S78net-snmp startup script
 with the following in it:
  #!/sbin/sh 
  #
  # /etc/rc3.d/S78net-snmp
  #
  # pkill has moved over the years so we need to find it
  #
  X=`which pkill`
  #!/sbin/sh
  #
  # /etc/rc3.d/S78net-snmp
  #
  # pkill has moved over the years so we need to find it
  #
  X=`which pkill`
  case "$1" in
  'start')
        /usr/local/net-snmp/sbin/snmpd
        ;;
  'stop')
        $X -TERM -x -u 0 snmpd
        ;;
  *)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
  esac
  exit 0
Then I did a "chmod 744 /etc/rc3.d/S78net-snmp"
I killed the running instance of snmpd and then ran
   "/etc/rc3.d/S78net-snmp start"
to start it up again.

SNMP quick commands-
Testing your Configuration
snmpwalk localhost -c public -v1

Testing Remote host Configuration
snmpwalk -v 2c -c public remotemachineipaddress system

Testing SNMP status of localhost
snmpstatus -c public localhost -v2c

Testing SNMP tables
snmptable -v 2c -c public -Os localhost sysORTable