Ubuntu SNMP Client Setup

  1. Install SNMPD

    joe@cmlin02:/etc/snmp# sudo apt-get install snmp snmpd
    
  2. Backup original config

    joe@cmlin02:/etc/snmp# sudo mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig
    
  3. Create new config

    joe@cmlin02:/etc/snmp# sudo vi /etc/snmp/snmpd.conf
    rocommunity	mycommunity
    syslocation	"office rack, large server"
    syscontact	joe@smithinc.com
    
  4. Add this config file to be loaded. Comment out old line & add new.

    joe@cmlin02:/etc/snmp# sudo vi /etc/default/snmpd
    ...
    # snmpd options (use syslog, close stdin/out/err).
    #SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
    SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf'
    ...
    
  5. Restart

    joe@cmlin02:/etc/snmp# sudo /etc/init.d/snmpd restart
    
  6. Test

    joe@cmlin02:/etc/snmp# snmpwalk -v 1 -c mycommunity -O e cmlin02
    

OSX SNMP Client Setup

SNMP config
518  snmpconf -g basic_setup
  519  sudo vi /etc/snmp/snmpd.conf
  520  sudo launchctl load -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist 


buildmac-2:~ buildserver$ snmpconf -g basic_setup

The following installed configuration files were found:

   1:  /etc/snmp/snmpd.conf

Would you like me to read them in?  Their content will be merged with the
output files created by this session.

Valid answer examples: "all", "none","3","1,2,5"

Read in which (default = all): 
************************************************ 
*** Beginning basic system information setup ***
************************************************ 
Do you want to configure the information returned in the system MIB group (contact info, etc)? (default = y): 

Configuring: syslocation
Description:
  The [typically physical] location of the system.
    Note that setting this value here means that when trying to
    perform an snmp SET operation to the sysLocation.0 variable will make
    the agent return the "notWritable" error code.  IE, including
    this token in the snmpd.conf file will disable write access to
    the variable.
    arguments:  location_string

The location of the system: Beth's Desk

Finished Output: syslocation  "Beth's Desk"

Configuring: syscontact
Description:
  The contact information for the administrator
    Note that setting this value here means that when trying to
    perform an snmp SET operation to the sysContact.0 variable will make
    the agent return the "notWritable" error code.  IE, including
    this token in the snmpd.conf file will disable write access to
    the variable.
    arguments:  contact_string

The contact information: jsmith@mydomain.com

Finished Output: syscontact  jsmith@mydomain.com
Do you want to properly set the value of the sysServices.0 OID (if you don't know, just say no)? (default = y): n
************************************** 
*** BEGINNING ACCESS CONTROL SETUP ***
************************************** 
Do you want to configure the agent's access control? (default = 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): n
Do you want to allow SNMPv1/v2c read-only community access (default = y): y

Configuring: rocommunity
Description:
  a SNMPv1/SNMPv2c read-only access community name
    arguments:  community [default|hostname|network/bits] [oid]

The community name to add read-only access for: freerange
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]: 

Finished Output: rocommunity  freerange  
Do another rocommunity line? (default = y): n
**************************************** 
*** Beginning trap destination setup ***
**************************************** 
Do you want to configure where and if the agent will send traps? (default = y): n
**************************************** 
*** Beginning monitoring setup ***
**************************************** 
Do you want to configure the agent's ability to monitor various aspects of your system? (default = y): n


The following files were created:

  snmpd.conf  

These files should be moved to /usr/share/snmp if you
want them used by everyone on the system.  In the future, if you add 
the -i option to the command line I'll copy them there automatically for you.

Or, if you want them for your personal use only, copy them to
/Users/buildserver/.snmp .  In the future, if you add the -p option to the
command line I'll copy them there automatically for you.

buildmac-2:~ buildserver$ sudo cp snmpd.conf /usr/share/snmp/





sudo launchctl unload -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist
sudo launchctl load -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist

buildmac-2:~ buildserver$ snmpwalk -v 2c -c freerange localhost system
SNMPv2-MIB::sysDescr.0 = STRING: Darwin buildmac 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386
SNMPv2-MIB::sysObjectID.0 = OID: NET-SNMP-MIB::netSnmpAgentOIDs.255
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (26152) 0:04:21.52
SNMPv2-MIB::sysContact.0 = STRING: jsmith@mydomain.com
SNMPv2-MIB::sysName.0 = STRING: buildmac
SNMPv2-MIB::sysLocation.0 = STRING: "Beth's Desk"
SNMPv2-MIB::sysServices.0 = INTEGER: 76
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORID.1 = OID: SNMP-FRAMEWORK-MIB::snmpFrameworkMIBCompliance
SNMPv2-MIB::sysORID.2 = OID: SNMP-MPD-MIB::snmpMPDCompliance
SNMPv2-MIB::sysORID.3 = OID: SNMP-USER-BASED-SM-MIB::usmMIBCompliance
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.5 = OID: TCP-MIB::tcpMIB
SNMPv2-MIB::sysORID.6 = OID: IP-MIB::ip
SNMPv2-MIB::sysORID.7 = OID: UDP-MIB::udpMIB
SNMPv2-MIB::sysORID.8 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORDescr.1 = STRING: The SNMP Management Architecture MIB.
SNMPv2-MIB::sysORDescr.2 = STRING: The MIB for Message Processing and Dispatching.
SNMPv2-MIB::sysORDescr.3 = STRING: The management information definitions for the SNMP User-based Security Model.
SNMPv2-MIB::sysORDescr.4 = STRING: The MIB module for SNMPv2 entities
SNMPv2-MIB::sysORDescr.5 = STRING: The MIB module for managing TCP implementations
SNMPv2-MIB::sysORDescr.6 = STRING: The MIB module for managing IP and ICMP implementations
SNMPv2-MIB::sysORDescr.7 = STRING: The MIB module for managing UDP implementations
SNMPv2-MIB::sysORDescr.8 = STRING: View-based Access Control Model for SNMP.
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.6 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.7 = Timeticks: (3) 0:00:00.03
SNMPv2-MIB::sysORUpTime.8 = Timeticks: (3) 0:00:00.03



uildmac-2:~ buildserver$ snmpget -v 2c -c freerange localhost sysDescr.0
SNMPv2-MIB::sysDescr.0 = STRING: Darwin buildmac 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386




jameslaptop:blackberry jsmith$ snmpwalk -Os -c freerange -v 1 jamesosx system
sysDescr.0 = STRING: Darwin jameslaptop 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386
sysObjectID.0 = OID: netSnmpAgentOIDs.255
sysUpTimeInstance = Timeticks: (22142) 0:03:41.42
sysContact.0 = STRING: jsmith@mydomain.com
sysName.0 = STRING: jameslaptop
sysLocation.0 = STRING: "jamesosx"
sysServices.0 = INTEGER: 76
sysORLastChange.0 = Timeticks: (3) 0:00:00.03
sysORID.1 = OID: snmpFrameworkMIBCompliance
sysORID.2 = OID: snmpMPDCompliance
sysORID.3 = OID: usmMIBCompliance
sysORID.4 = OID: snmpMIB
sysORID.5 = OID: tcpMIB
sysORID.6 = OID: ip
sysORID.7 = OID: udpMIB
sysORID.8 = OID: vacmBasicGroup
sysORDescr.1 = STRING: The SNMP Management Architecture MIB.
sysORDescr.2 = STRING: The MIB for Message Processing and Dispatching.
sysORDescr.3 = STRING: The management information definitions for the SNMP User-based Security Model.
sysORDescr.4 = STRING: The MIB module for SNMPv2 entities
sysORDescr.5 = STRING: The MIB module for managing TCP implementations
sysORDescr.6 = STRING: The MIB module for managing IP and ICMP implementations
sysORDescr.7 = STRING: The MIB module for managing UDP implementations
sysORDescr.8 = STRING: View-based Access Control Model for SNMP.
sysORUpTime.1 = Timeticks: (3) 0:00:00.03
sysORUpTime.2 = Timeticks: (3) 0:00:00.03
sysORUpTime.3 = Timeticks: (3) 0:00:00.03
sysORUpTime.4 = Timeticks: (3) 0:00:00.03
sysORUpTime.5 = Timeticks: (3) 0:00:00.03
sysORUpTime.6 = Timeticks: (3) 0:00:00.03
sysORUpTime.7 = Timeticks: (3) 0:00:00.03
sysORUpTime.8 = Timeticks: (3) 0:00:00.03
jameslaptop:blackberry jsmith$ 

CentOS SNMP Client Setup

  1. Install

    root@cmlin03:/# yum install net-snmp-utils
    
  2. Backup original config

    joe@cmlin03:/etc/snmp# sudo mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.orig
    
  3. Create new config

    joe@cmlin03:/etc/snmp# sudo vi /etc/snmp/snmpd.conf
    rocommunity	mycommunity
    syslocation	"office rack, large server"
    syscontact	joe@smithinc.com
    
  4. Configure iptables to allow snmp connections

    sudo vi /etc/sysconfig/iptables
    -A INPUT -p tcp --dport 161 -j ACCEPT
    -A INPUT -p udp --dport 161 -j ACCEPT
    
  5. Start the service

    /etc/init.d/snmpd start
    
  6. Test

    joe@cmlin02:/etc/snmp# snmpwalk -v 1 -c mycommunity -O e localhost
    
  7. Configure to start snmpd on boot

    joe@cmlin02:/etc/snmp# sudo chkconfig snmpd on