snmp kuri-232
1002 yum list > /tmp/yumlist 1004 cat /tmp/yumlist | grep snmp 1005 yum install net-snmp net-snmp-utils 1006 chkconfig snmpd on 1008 cd /etc/snmp/ 1009 ls -ltr 1010 cp -pr snmd.conf snmpd.conf.orig 1011 cp -pr snmptrapd.conf snmptrapd.conf.orig 1012 cat snmpd.conf | grep "public" | more 1014 cat snmpd.conf | grep "^[^#].*public" | more 1017 sed -i 's/\(^[^#].*\)public\(.*\)/\1hirasawa\2/' /etc/snmp/snmpd.conf 1018 diff /etc/snmp/snmpd.conf.orig /etc/snmp/snmpd.conf 1019 /etc/init.d/snmpd start 1020 pgrep snmpd 1021 service snmpd
- snmpwalkコマンド
OIDまたはMIBシンボルを入力すると、そのOIDツリー以下を展開して表示
[root@localhost ~]# snmpwalk -On -c hirasawa -v 1 localhost .1.3 .1.3.6.1.2.1.1.1.0 = STRING: Linux localhost.localdomain 2.6.32-279.14.1.el6.i686 #1 SMP Tue Nov 6 21:05:14 UTC 2012 i686 .1.3.6.1.2.1.1.2.0 = OID: .1.3.6.1.4.1.8072.3.2.10 .1.3.6.1.2.1.1.3.0 = Timeticks: (95036) 0:15:50.36 .1.3.6.1.2.1.1.4.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf) .1.3.6.1.2.1.1.5.0 = STRING: localhost.localdomain .1.3.6.1.2.1.1.6.0 = STRING: Unknown (edit /etc/snmp/snmpd.conf) .1.3.6.1.2.1.1.8.0 = Timeticks: (31) 0:00:00.31 .1.3.6.1.2.1.1.9.1.2.1 = OID: .1.3.6.1.6.3.11.2.3.1.1 .1.3.6.1.2.1.1.9.1.2.2 = OID: .1.3.6.1.6.3.15.2.1.1 .1.3.6.1.2.1.1.9.1.2.3 = OID: .1.3.6.1.6.3.10.3.1.1 .1.3.6.1.2.1.1.9.1.2.4 = OID: .1.3.6.1.6.3.1 .1.3.6.1.2.1.1.9.1.2.5 = OID: .1.3.6.1.2.1.49 .1.3.6.1.2.1.1.9.1.2.6 = OID: .1.3.6.1.2.1.4 .1.3.6.1.2.1.1.9.1.2.7 = OID: .1.3.6.1.2.1.50 .1.3.6.1.2.1.1.9.1.2.8 = OID: .1.3.6.1.6.3.16.2.2.1 .1.3.6.1.2.1.1.9.1.3.1 = STRING: The MIB for Message Processing and Dispatching. .1.3.6.1.2.1.1.9.1.3.2 = STRING: The MIB for Message Processing and Dispatching. .1.3.6.1.2.1.1.9.1.3.3 = STRING: The SNMP Management Architecture MIB. .1.3.6.1.2.1.1.9.1.3.4 = STRING: The MIB module for SNMPv2 entities .1.3.6.1.2.1.1.9.1.3.5 = STRING: The MIB module for managing TCP implementations .1.3.6.1.2.1.1.9.1.3.6 = STRING: The MIB module for managing IP and ICMP implementations .1.3.6.1.2.1.1.9.1.3.7 = STRING: The MIB module for managing UDP implementations .1.3.6.1.2.1.1.9.1.3.8 = STRING: View-based Access Control Model for SNMP. .1.3.6.1.2.1.1.9.1.4.1 = Timeticks: (30) 0:00:00.30 .1.3.6.1.2.1.1.9.1.4.2 = Timeticks: (30) 0:00:00.30 .1.3.6.1.2.1.1.9.1.4.3 = Timeticks: (30) 0:00:00.30 .1.3.6.1.2.1.1.9.1.4.4 = Timeticks: (30) 0:00:00.30 .1.3.6.1.2.1.1.9.1.4.5 = Timeticks: (31) 0:00:00.31 .1.3.6.1.2.1.1.9.1.4.6 = Timeticks: (31) 0:00:00.31 .1.3.6.1.2.1.1.9.1.4.7 = Timeticks: (31) 0:00:00.31 .1.3.6.1.2.1.1.9.1.4.8 = Timeticks: (31) 0:00:00.31 .1.3.6.1.2.1.25.1.1.0 = Timeticks: (98711) 0:16:27.11 End of MIB [root@localhost ~]#
- snmpgetコマンド
OIDまたはMIBシンボルを入力すると、そのOIDツリーに相当するオブジェクトの値を表示
OIDをもつオブジェクトが(配列ではなく)単一値をとるときには、後ろに「.0」を付けてアクセスする決まり
[root@localhost ~]# snmpget -On -c hirasawa -v 1 localhost .1.3.6.1.2.1.1.4.0 .1.3.6.1.2.1.1.4.0 = STRING: Root <root@localhost> (configure /etc/snmp/snmp.local.conf)
- snmptranslate
[root@localhost ~]# snmptranslate -Td .1.3.6 SNMPv2-SMI::dod dod OBJECT-TYPE -- FROM SNMPv2-SMI, RFC1155-SMI ::= { iso(1) org(3) 6 } [root@localhost ~]# snmptranslate -Td .1.3.6.1.2.1 SNMPv2-SMI::mib-2 mib-2 OBJECT-TYPE -- FROM SNMPv2-SMI, RFC1213-MIB ::= { iso(1) org(3) dod(6) internet(1) mgmt(2) 1 } [root@localhost ~]# snmptranslate -Td .1.3.6.1.2.1.1 SNMPv2-MIB::system system OBJECT-TYPE -- FROM SNMPv2-MIB, RFC1213-MIB ::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) 1 } [root@localhost ~]# snmptranslate -Td .1.3.6.1.2.1.1.4 SNMPv2-MIB::sysContact sysContact OBJECT-TYPE -- FROM SNMPv2-MIB, RFC1213-MIB -- TEXTUAL CONVENTION DisplayString SYNTAX OCTET STRING (0..255) DISPLAY-HINT "255a" MAX-ACCESS read-write STATUS current DESCRIPTION "The textual identification of the contact person for this managed node, together with information on how to contact this person. If no contact information is known, the value is the zero-length string." ::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) system(1) 4 } [root@localhost ~]# snmptranslate -Td .1.3.6.1.2.1.1.4.1 SNMPv2-MIB::sysContact.1 sysContact OBJECT-TYPE -- FROM SNMPv2-MIB, RFC1213-MIB -- TEXTUAL CONVENTION DisplayString SYNTAX OCTET STRING (0..255) DISPLAY-HINT "255a" MAX-ACCESS read-write STATUS current DESCRIPTION "The textual identification of the contact person for this managed node, together with information on how to contact this person. If no contact information is known, the value is the zero-length string." ::= { iso(1) org(3) dod(6) internet(1) mgmt(2) mib-2(1) system(1) sysContact(4) 1 } [root@localhost ~]#