Using NET-SNMP with A91750

1 downloads 169 Views 215KB Size Report
Creating the document. Michael Arp ... most likely have net-snmp in their application repository, so it's very easy to i
Using​ ​NET-SNMP​ ​with​ ​A91750 Application​ ​Note

Edition​ ​1.10 Issued​ ​May​ ​24th​ ​2011

Innocom-arcodan​ ​ApS​ ​-​ ​AN-A91750-01_Application_Note_Using_NET-SNMP_with_A91750​ ​-​ ​01

Document​ ​revision Date

Description

Author

20110524

Creating​ ​the​ ​document.

Michael​ ​Arp​ ​Sørensen

20110607

Added​ ​example​ ​with​ ​short​ ​output​ ​form

Michael​ ​Arp​ ​Sørensen

20130131

Adding​ ​examples​ ​to​ ​get​ ​and​ ​set​ ​informations

Michael​ ​Arp​ ​Sørensen

20130620

Adding​ ​examples​ ​and​ ​documentation​ ​on​ ​setting​ ​Trap Destination.

Michael​ ​Arp​ ​Sørensen

Innocom-arcodan​ ​ApS​ ​-​ ​AN-A91750-01_Application_Note_Using_NET-SNMP_with_A91750​ ​-​ ​01

Table​ ​of​ ​Content Introduction Description​ ​of​ ​NET-SNMP Prerequisites Configuring​ ​NET-SNMP Using​ ​NET-SNMP Example​ ​1​ ​Showing​ ​the​ ​Channel​ ​Info​ ​tabel Example​ ​2​ ​Get​ ​a​ ​value​ ​from​ ​an​ ​OID Example​ ​3​ ​Set​ ​Trap​ ​Destination​ ​IP​ ​address​ ​in​ ​table​ ​entry​ ​1 Example​ ​4​ ​Set​ ​Trap​ ​Destination​ ​Community​ ​string​ ​in​ ​table​ ​entry​ ​1 Example​ ​5​ ​Set​ ​Trap​ ​Destination​ ​RowStatus​ ​in​ ​table​ ​entry​ ​1 Example​ ​6​ ​Table​ ​of​ ​Trap​ ​Destination​ ​setting Description​ ​of​ ​Trap​ ​Destination​ ​OID’s Conclusion

Introduction This​ ​Application​ ​Note​ ​is​ ​about​ ​the​ ​use​ ​of​ ​net-snmp​ ​tool.​ ​Even​ ​though​ ​net-snmp​ ​is​ ​a​ ​multi-platform application,​ ​the​ ​examples​ ​shown​ ​in​ ​this​ ​document​ ​is​ ​from​ ​a​ ​Linux​ ​computer.​ ​Most​ ​Linux​ ​distributions​ ​will most​ ​likely​ ​have​ ​net-snmp​ ​in​ ​their​ ​application​ ​repository,​ ​so​ ​it’s​ ​very​ ​easy​ ​to​ ​install.​ ​On​ ​Windows​ ​you​ ​need to​ ​download​ ​and​ ​install​ ​it​ ​your​ ​self. For​ ​this​ ​document​ ​it​ ​is​ ​assumed​ ​that​ ​you​ ​know​ ​about​ ​SNMP​ ​already.

Description​ ​of​ ​NET-SNMP Net-snmp​ ​is​ ​a​ ​command​ ​line​ ​tool​ ​for​ ​retrieving​ ​and​ ​showing​ ​SNMP​ ​data​ ​from​ ​a​ ​remote​ ​agent.

Prerequisites Install​ ​NET-SNMP​ ​on​ ​your​ ​computer.​ ​Download​ ​the​ ​MIB​ ​files​ ​from​ ​Innocom​ ​Support​ ​homepage​ ​using​ ​this link:​ ​http://mibfiles.innocom.dk​.

Innocom-arcodan​ ​ApS​ ​-​ ​AN-A91750-01_Application_Note_Using_NET-SNMP_with_A91750​ ​-​ ​01

Configuring​ ​NET-SNMP The​ ​only​ ​configuration​ ​necessary​ ​is​ ​to​ ​put​ ​your​ ​MIB​ ​files​ ​in​ ​a​ ​folder​ ​that​ ​is​ ​in​ ​the​ ​search​ ​path​ ​of​ ​MIB​ ​files. On​ ​Linux​ ​the​ ​files​ ​is​ ​stored​ ​in: /home/USERNAME/.snmp/mibs/ For​ ​windows,​ ​please​ ​look​ ​through​ ​the​ ​official​ ​documentation​ ​here:​ h ​ ttp://www.net-snmp.org/wiki/​.

Using​ ​NET-SNMP List​ ​of​ ​commands​ ​in​ ​NET​ ​SNMP: ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ●

agentxtrap encode_keychange fixproc ipf-mod.pl mib2c mib2c-update net-snmp-cert net-snmp-config net-snmp-create-v3-user snmp-bridge-mib snmpbulkget snmpbulkwalk snmpcheck snmpconf snmpdelta snmpdf snmpget snmpgetnext snmpinform snmpnetstat snmpset snmpstatus snmptable snmptest snmptranslate snmptrap snmpusm snmpvacm snmpwalk tkmib traptoemail

For​ ​the​ ​most​ ​part,​ ​only​ ​a​ ​few​ ​of​ ​them​ ​is​ ​relevant.

Innocom-arcodan​ ​ApS​ ​-​ ​AN-A91750-01_Application_Note_Using_NET-SNMP_with_A91750​ ​-​ ​01

Example​ ​1​ ​Showing​ ​the​ ​Channel​ ​Info​ ​tabel

The​ ​command​ ​snmptable​​ ​is​ ​the​ ​one​ ​to​ ​use​ ​for​ ​this​ ​example.​ ​The​ ​full​ ​command​ ​is​ ​this: snmptable​ ​-Cbl​ ​-m​ ​all​ ​-v​ ​2c​ ​-c​ ​ro1user​ ​192.168.0.40​ ​.1.3.6.1.4.1.1482.20.3.3.4.2.1

Here’s​ ​a​ ​break​ ​down​ ​of​ ​all​ ​the​ ​used​ ​parameters: -Cbl

Shows​ ​only​ ​brief​ ​field​ ​names​ ​with​ ​left​ ​justify​ ​output.

-m​ ​all

Load​ ​all​ ​MIB​ ​files​ ​in​ ​the​ ​path.​ ​This​ ​could​ ​be​ ​overkill​ ​and​ ​give​ ​a​ ​lot of​ ​overhead​ ​in​ ​running​ ​the​ ​command.​ ​Especially​ ​if​ ​you​ ​have​ ​many MIB​ ​files.

-v​ ​2c

Specify​ ​SNMP​ ​version.​ ​In​ ​this​ ​example​ ​we​ ​use​ ​version​ ​2 community.​ ​This​ ​means​ ​that​ ​authentication​ ​is​ ​backward compatible​ ​with​ ​SNMP​ ​version​ ​1.

-c​ ​ro1user

Specify​ ​the​ ​READ​ ​Community.

192.168.0.40

The​ ​host/SNMP​ ​agent​ ​we​ ​want​ ​data​ ​from.

.1.3.6.1.4.1.1482.20.3.3.4.2.1

The​ ​OID​ ​for​ ​the​ ​ChannelInfoTable

The​ ​output​ ​of​ ​the​ ​command: As​ ​text​ ​(truncated​ ​to​ ​save​ ​space) snmptable​ ​-Cbl​ ​-m​ ​all​ ​-v​ ​2c​ ​-c​ ​ro1user​ ​192.168.0.40​ ​.1.3.6.1.4.1.1482.20.3.3.4.2.1 SNMP​ ​table:​ ​SA-EUROPE-A91750-MIB::cmChannelInfoTable Index​ ​Frequency​ ​TypeOfCarrier​ ​Name​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​Location​ ​ ​ ​ ​ ​ ​ ​Description​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​GroupTable MinorLower​ ​MinorUpper​ ​MajorLower​ ​MajorUpper​ ​BelowDynamicRange​ ​ExceedsDynamicRange​ ​Measure​ ​Alarm​ ​ ​ ​ ​Backup StatusAlarm​ ​ActualLevel​ ​CorrectedLevel​ ​CorrectionLevel​ ​ExpectedLevel​ ​LastMeasured 2​ ​ ​ ​ ​ ​900000​ ​ ​ ​ ​fm​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​"Sky​ ​Radio"​ ​ ​ ​ ​ ​ ​ ​ ​ ​"Primary​ ​site"​ ​"Public​ ​Service​ ​Radio."​ ​ ​ ​ ​ ​ ​ ​0 -20​ ​ ​ ​ ​ ​ ​ ​ ​20​ ​ ​ ​ ​ ​ ​ ​ ​ ​-100​ ​ ​ ​ ​ ​ ​ ​100​ ​ ​ ​ ​ ​ ​ ​ ​350​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​850​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​enabled​ ​disabled disabled​ ​noalarm​ ​ ​ ​ ​ ​655​ ​ ​ ​ ​ ​ ​ ​ ​ ​655​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​0​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​656​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​1306394156 31​ ​ ​ ​ ​6180000​ ​ ​ ​amvsb​ ​ ​ ​ ​ ​ ​ ​ ​ ​"CNN"​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​"Primary​ ​site"​ ​"News​ ​from​ ​around​ ​the​ ​world."​ ​0 -20​ ​ ​ ​ ​ ​ ​ ​ ​20​ ​ ​ ​ ​ ​ ​ ​ ​ ​-100​ ​ ​ ​ ​ ​ ​ ​100​ ​ ​ ​ ​ ​ ​ ​ ​390​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​890​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​enabled​ ​disabled disabled​ ​noalarm​ ​ ​ ​ ​ ​683​ ​ ​ ​ ​ ​ ​ ​ ​ ​683​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​0​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​682​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​1306394156

As​ ​text​ ​in​ ​a​ ​short​ ​form snmptable​ ​-Cl​ ​-CH​ ​-Cf​ ​";"​ ​-m​ ​all​ ​-v​ ​2c​ ​-c​ ​ro1user​ ​192.168.0.39​ ​.1.3.6.1.4.1.1482.20.3.3.4.2.1 2;900000;fm;"Sky​ ​Radio";"Primary​ ​site";"Public​ ​Service Radio.";0;-20;20;-100;100;350;850;enabled;disabled;disabled;noalarm;657;657;0;656;1307458693 10;2942500;amvsb;"BBC";"Primary site";"BBC";0;-20;20;-100;100;350;850;enabled;disabled;disabled;bdr;167;167;0;700;1307458694 11;4700000;unmodulated;"Pilot";"Primary​ ​site";"Reference level";0;-20;20;-100;100;350;850;enabled;disabled;disabled;noalarm;438;438;0;435;1307458694

As​ ​an​ ​image

Obviously,​ ​the​ ​output​ ​is​ ​to​ ​wide​ ​because​ ​of​ ​the​ ​many​ ​columns,​ ​that​ ​it​ ​can’t​ ​be​ ​shown​ ​here​ ​as​ ​characters​ ​but only​ ​as​ ​a​ ​picture. If​ ​you​ ​run​ ​this​ ​command​ ​on​ ​linux: Innocom-arcodan​ ​ApS​ ​-​ ​AN-A91750-01_Application_Note_Using_NET-SNMP_with_A91750​ ​-​ ​01

watch​ ​-d​ ​-n​ ​60​ ​snmptable​ ​-Cbl​ ​-m​ ​all​ ​-v​ ​2c​ ​-c​ ​ro1user​ ​192.168.0.40 .1.3.6.1.4.1.1482.20.3.3.4.2.1

watch​ ​-d​​ ​-n​ ​60​​ ​shows​ ​the​ ​output​ ​in​ ​60​ ​seconds​ ​interval​ ​and​ ​the​ ​changed​ ​values​ ​are​ ​highlighted.​ ​This​ ​is usefull​ ​for​ ​following​ ​changes.​ ​But​ ​it’s​ ​not​ ​suited​ ​for​ ​seeing​ ​changes​ ​over​ ​time.​ ​For​ ​that​ ​you​ ​need​ ​a​ ​Network Management​ ​System.

Example​ ​2​ ​Get​ ​a​ ​value​ ​from​ ​an​ ​OID

This​ ​example​ ​shows​ ​how​ ​to​ ​get​ ​a​ ​value​ ​from​ ​an​ ​OID.​ ​In​ ​this​ ​case​ ​we​ ​get​ ​the​ ​IP​ ​address​ ​for​ ​trap​ ​destination. snmpget​ ​-m​ ​all​ ​-v​ ​2c​ ​-c​ ​ro1user​ ​192.168.1.46​ ​.1.3.6.1.4.1.1482.20.1.9.1.1.2.3

Description: Object​ ​ID

Example​ ​3​ ​Set​ ​Trap​ ​Destination​ ​IP​ ​address​ ​in​ ​table​ ​entry​ ​1 This​ ​example​ ​shows​ ​how​ ​to​ ​set​ ​an​ ​IP​ ​address​ ​for​ ​the​ ​trap​ ​destination:

#​ ​snmpset​ ​-m​ ​all​ ​-v​ ​2c​ ​-c​ ​rw1user​ ​192.168.1.46​​ ​.1.3.6.1.4.1.1482.20.1.9.1.1.2.3​​ ​a 192.168.1.10

Description: Object​ ​ID Data​ ​type:​ ​a​ ​(IP​ ​address) Data:​ ​the​ ​data​ ​we​ ​want​ ​to​ ​store

Example​ ​4​ ​Set​ ​Trap​ ​Destination​ ​Community​ ​string​ ​in​ ​table entry​ ​1 This​ ​example​ ​shows​ ​how​ ​to​ ​set​ ​a​ ​Community​ ​string​ ​for​ ​the​ ​trap​ ​destination:

#​ ​snmpset​ ​-m​ ​all​ ​-v​ ​2c​ ​-c​ ​rw1user​ ​192.168.1.46​ ​.1.3.6.1.4.1.1482.20.1.9.1.1.3.1​​ ​s rw1user

Description: Object​ ​ID Data​ ​type:​ ​s​ ​(string) Data:​ ​the​ ​data​ ​we​ ​want​ ​to​ ​store

Innocom-arcodan​ ​ApS​ ​-​ ​AN-A91750-01_Application_Note_Using_NET-SNMP_with_A91750​ ​-​ ​01

Example​ ​5​ ​Set​ ​Trap​ ​Destination​ ​RowStatus​ ​in​ ​table​ ​entry​ ​1 This​ ​example​ ​shows​ ​how​ ​to​ ​set​ ​a​ ​RowStatus​ ​for​ ​the​ ​trap​ ​destination:

#​ ​snmpset​ ​-m​ ​all​ ​-v​ ​2c​ ​-c​ ​rw1user​ ​192.168.1.46​ ​.1.3.6.1.4.1.1482.20.1.9.1.1.3.1​​ ​i​ ​1

Description: Object​ ​ID Data​ ​type:​ ​i​ ​(integer) Data:​ ​the​ ​data​ ​we​ ​want​ ​to​ ​store.​ ​See​ ​description​ ​of​ ​TrapDestination​ ​below​ ​for​ ​meaning​ ​of​ ​integer​ ​values.

Example​ ​6​ ​Table​ ​of​ ​Trap​ ​Destination​ ​setting This​ ​example​ ​shows​ ​how​ ​display​ ​the​ ​table​ ​of​ ​Trap​ ​Destination​ ​settings:

#​ ​snmptable​ ​-Cbl​ ​-m​ ​all​ ​-v​ ​2c​ ​-c​ ​ro1user​ ​192.168.1.46​ ​.1.3.6.1.4.1.1482.20.1.9.1

Description: Object​ ​ID Output: SNMP​ ​table:​ ​SAEUROPE-TRAPDESTINATION-MIB::trapDestinationsTable Index​ 1​ ​ ​ ​ ​ 2​ ​ ​ ​ ​ 3​ ​ ​ ​ ​ 4​ ​ ​ ​ ​ 5​ ​ ​ ​ ​ 6​ ​ ​ ​ ​ 7​ ​ ​ ​ ​ 8​ ​ ​ ​ ​ 9​ ​ ​ ​ ​ 10​ ​ ​ ​

​IpAddr​ ​ ​ ​ ​ ​ ​ ​192.168.1.80​ ​192.168.1.24​ ​0.0.0.0​ ​ ​ ​ ​ ​ ​0.0.0.0​ ​ ​ ​ ​ ​ ​0.0.0.0​ ​ ​ ​ ​ ​ ​0.0.0.0​ ​ ​ ​ ​ ​ ​0.0.0.0​ ​ ​ ​ ​ ​ ​0.0.0.0​ ​ ​ ​ ​ ​ ​0.0.0.0​ ​ ​ ​ ​ ​ ​0.0.0.0​ ​ ​ ​ ​ ​

​CommunityString​ ​rw1user​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​

​RowStatus ​active ​notReady ​notInService ​notInService ​notInService ​notInService ​notInService ​notInService ​notInService ​notInService

Innocom-arcodan​ ​ApS​ ​-​ ​AN-A91750-01_Application_Note_Using_NET-SNMP_with_A91750​ ​-​ ​01

Description​ ​of​ ​Trap​ ​Destination​ ​OID’s .1​ ​tdIndex Type: Access: Status: Description: .2​ ​tdIpAddr Type: Access: Status: Description:

Integer32​ ​(1..10) read-only current Index​ ​of​ ​the​ ​trap​ ​destinations​ ​table. IpAddress read-write current The​ ​IP​ ​address​ ​of​ ​the​ ​trap​ ​destinations.

.3​ ​tdCommunityString Type: OCTET​ ​STRING​ ​(0..30) Access: read-write Status: current Description: Community​ ​string​ ​used​ ​to​ ​send​ ​traps.​ ​Blank​ ​characters​ ​are​ ​not allowed​ ​at​ ​the​ ​beginning​ ​or​ ​in​ ​the​ ​middle​ ​of​ ​the​ ​string.​ ​Blank​ ​characters​ ​at the​ ​end​ ​are​ ​ignored.​ ​If​ ​length​ ​of​ ​the​ ​community​ ​string​ ​is​ ​zero,​ ​traps​ ​are​ ​not sent​ ​to​ ​the​ ​particular​ ​destination,​ ​even​ ​if​ ​that​ ​destination​ ​is​ ​used. .4​ ​tdRowStatus Type: INTEGER​ ​{​ ​active(1),​ ​notInService(2),​ ​notReady(3), createAndGo(4),​ ​createAndWait(5),​ ​destroy(6)​ ​} Access: read-write Status: current Description: To​ ​be​ ​used​ ​for​ ​creating​ ​and​ ​deleting​ ​rows​ ​in​ ​this​ ​table. Source:​ ​https://mimir.fcom.ch/wwwbin/snmpnav.pl?oid=1.3.6.1.4.1.1482.20.1.9.1.1.1

Innocom-arcodan​ ​ApS​ ​-​ ​AN-A91750-01_Application_Note_Using_NET-SNMP_with_A91750​ ​-​ ​01

Conclusion NET-SNMP​ ​is​ ​a​ ​collection​ ​of​ ​simple​ ​tools​ ​to​ ​get​ ​or​ ​set​ ​SNMP​ ​data​ ​on​ ​a​ ​SNMP​ ​agent.​ ​Using​ ​these​ ​tools​ ​can come​ ​in​ ​handy​ ​if​ ​you’re​ ​working​ ​out​ ​in​ ​the​ ​fields​ ​or​ ​if​ ​you​ ​don’t​ ​have​ ​a​ ​more​ ​advanced​ ​SNMP​ ​browser​ ​or Network​ ​Management​ ​System​ ​like​ ​ROSA. By​ ​using​ ​command​ ​line​ ​tools​ ​it​ ​is​ ​possible​ ​to​ ​write​ ​scripts​ ​to​ ​do​ ​simple​ ​tasks​ ​for​ ​you.​ ​More​ ​examples​ ​will​ ​be included​ ​in​ ​the​ ​future.

Innocom-arcodan​ ​ApS​ ​-​ ​AN-A91750-01_Application_Note_Using_NET-SNMP_with_A91750​ ​-​ ​01