Archive for May, 2013

How can i leave trap ..hun
NOW, lets try to configure snmp manager to receive trap and agent to send it

Agent side: cat /etc/snmp/snmpd.conf
rwuser pu_v3_rw noauth
rouser pu_v3_ro noauth
rouser public
rwcommunity private
rwcommunity pu_v12_rw
trapcommunity public
trapsink localhost public
trap2sink localhost pu_v12_rw
syslocation pushpa_location
syscontact pushpa_contact
trapsink for SNMPv1 traps
trap2sink for SNMPv2 traps
I am still in my way to configure SNMPv3 traps (hope for best)

Restart snmpd (aka snmp-agent)
/etc/init.d/snmpd restart
Manager side: cat /etc/snmp/snmptrapd.conf
authCommunity log pu_r12_rw
authCommunity log public

Restart snmptrapd
sudo snmptrapd -f -Lo -c /etc/snmp/snmptrapd.conf

We are all set to go …. where??  sit sit try traps  as given below 😛


SNMPv1 traps:

 snmptrap -v 1 -c public localhost NET-SNMP-EXAMPLES-MIB::netSnmpExampleNotification “” 6 17 “”  netSnmpExampleInteger i 123456

snmptrapd shows:

2013-05-23 15:16:53 pushpa.Mysorecalsoft.org [] (via UDP: []:34115->[]) TRAP, SNMP v1, community public
NET-SNMP-EXAMPLES-MIB::netSnmpExampleNotification Enterprise Specific Trap (17) Uptime: 5:55:47.83
NET-SNMP-EXAMPLES-MIB::netSnmpExampleInteger = INTEGER: 123456
SNMPv2 traps:

snmptrap -v 2c -c public localhost “” NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatNotification netSnmpExampleHeartbeatRate i 123456

snmptrapd shows:

2013-05-23 15:18:28 localhost [UDP: []:34619->[]]:
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (2144276) 5:57:22.76 SNMPv2-MIB::snmpTrapOID.0 = OID: NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatNotification NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatRate = INTEGER: 123456

snmpinform -v 2c -c public “” NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatNotification netSnmpExampleHeartbeatRate i 777

2013-05-23 15:19:25 pushpa.Mysorecalsoft.org [UDP: []:41729->[]]:
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (2149978) 5:58:19.78 SNMPv2-MIB::snmpTrapOID.0 = OID: NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatNotification NET-SNMP-EXAMPLES-MIB::netSnmpExampleHeartbeatRate = INTEGER: 777


cat  ~/.snmp/mibs/TRAP-TEST-MIB  (create TRAP-TEST-MIB)


demotraps OBJECT IDENTIFIER ::= { ucdExperimental 990 }

demo-trap TRAP-TYPE
STATUS current
ENTERPRISE demotraps
VARIABLES { sysLocation }
DESCRIPTION “This is just a demo”
::= 17



Dont forget to restart agent and trapd when respective configuration got modified

snmptrap -v 1 -c public localhost TRAP-TEST-MIB::demotraps localhost 6 17 ” SNMPv2-MIB::sysLocation.0 s “Just here”

snmptrapd shows:

2013-05-23 15:23:30 localhost [] (via UDP: []:35535->[]) TRAP, SNMP v1, community public
UCD-SNMP-MIB::ucdExperimental.990 Enterprise Specific Trap (17) Uptime: 6:02:25.43
SNMPv2-MIB::sysLocation.0 = STRING: Just here

Read Full Post »

I worked on SNMP but forgot  and want to be familiar with it …….same for you too …then stop stopp here 🙂
I can refer following link to understand SNMP concepts . http://www.net-snmp.org/wiki/index.php/
Tired of reading…I assume i have red/know concepts and theory part of SNMP protocol.
Okay…Lets jump into pool and learn swimming tactics

AIM: configure SNMP agent and SNMP manager on same Ubuntu system

part 0:

Platform:linux (32bit)
OS: ubuntu 12.04
step1: download snmpagent and tool

sudo apt-get install snmpd (this is THE ;~ SNMP agent)
sudo apt-get install snmp ( want to use snmp commands isn’t?)
sudo apt-get install snmp-mibs-downloader (yes, have to download iana, ietf mibs separately)

PS: let installtion check dependencies n report me if it need any 😉


step2: I should know/remember few stuffs too
mibs location :
ls -l /usr/share/mibs/
total 4
lrwxrwxrwx 1 root root 18 Jun 7 2010 iana -> /var/lib/mibs/iana
lrwxrwxrwx 1 root root 18 Jun 7 2010 ietf -> /var/lib/mibs/ietf
drwxr-xr-x 2 root root 4096 Apr 26 10:54 netsnmp
I forgot the script(snmp) name in which we can set the mib directories to search for. okay move-on
But, there is shortcut atleast to know what are the location being searched for mib
snmptranslate -Dinit_mib .1.3 2>&1
No log handling enabled – turning on stderr logging
registered debug token init_mib, 1
init_mib: Seen MIBDIRS: Looking in ‘/home/(user_name)/.snmp/mibs:/usr/share/mibs/site:/usr/share/snmp/mibs:/usr/share/mibs/iana:/usr/share/mibs/ietf:/usr/share/mibs/netsnmp’ for mib dirs …
init_mib: Seen PREFIX: Looking in ‘.’ for prefix …

Note: I have kept sample MIBs in ~/.snmp/mibs (create directories if it is not there)

conf location:
ls /etc/snmp
snmp.conf, snmpd.conf, snmptrapd.conf, snmpd.conf.org
Whenever i try experimenting. keep reminding myself to save original files as .org.

step 3:
configure agent: used ‘snmpconf -g basic_setup’ to create config file

cat /etc/snmpd/snmpd.conf
rwuser pu_v3_rw noauth
rouser pu_v3_ro noauth
rouser public (added manually)
rwcommunity private (added manually)
rwcommunity pu_v12_rw
trapcommunity public (added manually)
trapsink localhost public (added manually)
linkUpDownNotifications yes (added manually)
syslocation pushpa_location
syscontact pushpa_contact

Following are the place where snmp dir present

part 1:
step 4:
(Tp = Print a graphical tree, rooted at the specified OID)
snmptranslate -Tp SNMPv2-MIB::system
+– -R– String sysDescr(1)
| Textual Convention: DisplayString
| Size: 0..255
+– -R– ObjID sysObjectID(2)
+– -R– TimeTicks sysUpTime(3)
| |
| +–sysUpTimeInstance(0)
+– -RW- String sysContact(4)
| Textual Convention: DisplayString
| Size: 0..255
+– -RW- String sysName(5)
| Textual Convention: DisplayString
| Size: 0..255
+– -RW- String sysLocation(6)
| Textual Convention: DisplayString
| Size: 0..255
+– -R– INTEGER sysServices(7)
| Range: 0..127
+– -R– TimeTicks sysORLastChange(8)
| Textual Convention: TimeStamp
| Index: sysORIndex
+– —- INTEGER sysORIndex(1)
| Range: 1..2147483647
+– -R– ObjID sysORID(2)
+– -R– String sysORDescr(3)
| Textual Convention: DisplayString
| Size: 0..255
+– -R– TimeTicks sysORUpTime(4)
Textual Convention: TimeStamp

(-On = Displays the OID numerically)
snmptranslate -On SNMPv2-MIB::system

(Td = description)
snmptranslate -Td .
::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) 1 }

snmptranslate -Td .

(IR = enable random access, no need to give full OID path)
snmptranslate -On -IR sysDescr

Refer: link to know more about common options http://www.linuxcommand.org/man_pages/snmpcmd1.html
snmpget -c public -v 1 localhost sysUpTime.0
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (1280231) 3:33:22.31

snmpgetnext -c public -v 1 localhost sysUpTime.0
SNMPv2-MIB::sysContact.0 = STRING: root

snmpgetnext -c public -v 1 localhost sysContact.0
SNMPv2-MIB::sysName.0 = STRING: user_name

snmpget -c public -v 1 localhost ipForwarding.0
IP-MIB::ipForwarding.0 = INTEGER: notForwarding(2)
Part 2:
Now one step-up, it is using externel mib (example)
Download CISCO-RHINO-MIB and store in ~/.snmp/mibs/

restart snmp-agent /etc/init.d/snmpd restart
and try following and ve fun
snmptranslate -Tp CISCO-RHINO-MIB::ciscoLS1010ChassisGroup
snmptranslate -m +CISCO-RHINO-MIB -IR -On ciscoLS1010ChassisFanLed
snmptranslate -On -IR CISCO-RHINO-MIB::ciscoLS1010ChassisSysType

snmpget and snmpset wont work for this mib since no snmp-handler . This is when we
need to use mib2c and fill up the stuff

Note: check snmp version number used and host name if i get error. because that is silly mistake i might have done.

Read Full Post »