273 | | ==== From a manager device - snmpwalk ==== |
274 | | with snmpwalk from SB9: |
275 | | {{{ |
276 | | root@sb9:~# snmpwalk -v 2c -c NET 172.16.100.10 1.3.6.1.2.1.1 |
277 | | }}} |
278 | | {{{ |
279 | | SNMPv2-MIB::sysDescr.0 = STRING: ALAXALA AX3640S AX-3640-48T2XW-L [AX3640S-48T2XW] Switching software Ver. 10.7 [OS-L3L] |
280 | | SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.21839.1.2.11 |
281 | | DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (26201570) 3 days, 0:46:55.70 |
282 | | SNMPv2-MIB::sysContact.0 = STRING: |
283 | | SNMPv2-MIB::sysName.0 = STRING: sw-sb09 |
284 | | SNMPv2-MIB::sysLocation.0 = STRING: |
285 | | SNMPv2-MIB::sysServices.0 = INTEGER: 78 |
286 | | }}} |
287 | | ==== Using Ruby scripts ==== |
288 | | libsnmp reference: http://snmplib.rubyforge.org/doc/index.html |
289 | | |
290 | | Ruby has libsnmp-ruby, a library for SNMP, available. SB9 didn't come with it, so it was installed: |
291 | | {{{ |
292 | | apt-get install libsnmp-ruby |
293 | | }}} |
294 | | A messy irb test of the library: |
295 | | {{{ |
296 | | irb(main):002:0> require 'snmp' |
297 | | irb(main):004:0> agent_hostname = "172.16.100.10" |
298 | | => "172.16.100.10" |
299 | | irb(main):005:0> agent_comm = "NET" |
300 | | => "NET" |
301 | | irb(main):007:0> s = SNMP::Manager.new(:Host => agent_hostname, :Community =>agent_comm, :Port => 161) |
302 | | => #<SNMP::Manager:0xb79d5d98 @snmp_version=:SNMPv2c, @port=161, @transport=#<SNMP::UDPTransport:0xb79d5d5c @socket=#<UDPSocket:0xb79d5d34>>, @write_community="NET", @host="172.16.100.10", @retries=5, @community="NET", @mib=#<SNMP ... #this goes on for a while |
303 | | irb(main):009:0> response = s.get(["1.3.6.1.2.1.1.1.0"]) |
304 | | => #<SNMP::Response:0xb79c2d10 @error_index=0, @error_status=0, @request_id=856260869, @varbind_list=[#<SNMP::VarBind:0xb79c2900 @value="ALAXALA AX3640S AX-3640-48T2XW-L [AX3640S-48T2XW] Switching software Ver. 10.7 [OS-L3L]", @name=[1.3.6.1.2.1.1.1.0]>]> |
305 | | irb(main):035:0> rstring = "#{response.varbind_list.to_s}" |
306 | | => "[name=1.3.6.1.2.1.1.1.0, value=ALAXALA AX3640S AX-3640-48T2XW-L [AX3640S-48T2XW] Switching software Ver. 10.7 [OS-L3L] (OCTET STRING)]" |
307 | | }}} |
| 273 | |