SimpleGraph-SNMP


Wolfgang Fahl

SimpleGraphModule

Snmp.png

SimpleGraph SNMP module

The SimpleGraph SNMP module makes Simple Network Monitoring Protocol accessible via SNMP4J see SNMP4J Simple Network Monitoring Protocol SNMP Java API.

Sources

Example

SimpleGraphModule[edit]

Snmp.png

SimpleGraph SNMP module

The SimpleGraph SNMP module makes Simple Network Monitoring Protocol accessible via SNMP4J see SNMP4J Simple Network Monitoring Protocol SNMP Java API.

Sources

Example[edit]

Goal[edit]

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

JUnit TestCase[edit]

  String pageCount=".1.3.6.1.2.1.43.10.2.1.4.1";
  String[] printers = { "printer1", "printer2", "printer3"}; // replace with your printer's hostnames
  for (String printer:printers) {
    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));
    }
  }

Goal[edit]

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

JUnit TestCase[edit]

  String pageCount=".1.3.6.1.2.1.43.10.2.1.4.1";
  String[] printers = { "printer1", "printer2", "printer3"}; // replace with your printer's hostnames
  for (String printer:printers) {
    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));
    }
  }

Result[edit]

   printer1     46592 pages
   printer2     35713 pages
   printer3     16905 pages

Explanation[edit]

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.

🖨 🚪