Difference between revisions of "SimpleGraph-SNMP"

From BITPlan Wiki
Jump to navigation Jump to search
Line 7: Line 7:
 
|viewmode=hidden
 
|viewmode=hidden
 
}}
 
}}
 +
= Example =
 +
== Goal ==
 +
You'd like to find out the pageCounters of some printers in your network.
 +
== JUnit TestCase ==
 +
<source lang='java'>
 +
  String pageCount=".1.3.6.1.2.1.43.10.2.1.4.1";
 +
  String printer="printer.bitplan.com"; // replace with your printer's hostname
 +
  SNMPSystem ss=new SNMPSystem();
 +
  ss.connect(printer);
 +
  SimpleNode snmpNode=ss.moveTo(pageCount);
 +
  if (snmpNode != null) {
 +
        String pages = snmpNode.property("value").toString();
 +
        System.out.println(String.format("%40s %8s pages", printer, pages));
 +
  }
 +
</source>
 +
== Explanation ==
 +
The moveTo function will perform an SNMP walk on the given oid (and it's subtree) and make available
 +
the values converted as objects with the proper datatype.
 
= Links =
 
= Links =
 
* https://en.wikipedia.org/wiki/Simple_Network_Management_Protocol
 
* https://en.wikipedia.org/wiki/Simple_Network_Management_Protocol
Line 13: Line 31:
 
* http://www.snmp4j.org/html/download.html
 
* http://www.snmp4j.org/html/download.html
 
* https://mvnrepository.com/artifact/org.snmp4j/snmp4j/2.5.11
 
* https://mvnrepository.com/artifact/org.snmp4j/snmp4j/2.5.11
 +
 
[[Category:frontend]]
 
[[Category:frontend]]

Revision as of 21:05, 20 February 2018

Snmp.png

SimpleGraph SNMP module

The SimpleGraph SNMP module makes Simple Network Monitoring Protocol accessible via SNMP4J see [ ].

Sources

Example

Goal

You'd like to find out the pageCounters of some printers in your network.

JUnit TestCase

  String pageCount=".1.3.6.1.2.1.43.10.2.1.4.1";
  String printer="printer.bitplan.com"; // replace with your printer's hostname
  SNMPSystem ss=new SNMPSystem();
  ss.connect(printer);
  SimpleNode snmpNode=ss.moveTo(pageCount);
  if (snmpNode != null) {
        String pages = snmpNode.property("value").toString();
        System.out.println(String.format("%40s %8s pages", printer, pages));
  }

Explanation

The moveTo function will perform an SNMP walk on the given oid (and it's subtree) and make available the values converted as objects with the proper datatype.

Links