stingh711 avatar stingh711 committed 4092bce

add mib for tools

Comments (0)

Files changed (4)

config.properties

 switch.2.interface.table.in.2=9859485
 switch.2.interface.table.out.2=934
 
+#data for tools
+ping.ip=192.168.1.1
+ping.result=PING 172.25.21.254 (172.25.21.254): 56 octets data\n64 octets from 172.25.21.254: icmp_seq=0 ttl=64 time=4.5 ms\n64 octets from 172.25.21.254: icmp_seq=1 ttl=64 time=0.3 ms\n64 octets from 172.25.21.254: icmp_seq=2 ttl=64 time=0.3 ms\n--- 172.25.21.254 ping statistics ---\n3 packets transmitted, 3 packets received, 0% packet loss\nround-trip min/avg/max = 0.3/1.7/4.5 ms
+tracert.ip=192.168.1.1
+tracert.result=1  172.25.21.254 (172.25.21.254)  0.496 ms  0.403 ms  0.370 ms\n2  172.25.6.251 (172.25.6.251)  1.422 ms  0.461 ms  0.944 ms\n3  172.25.6.253 (172.25.6.253)  1.983 ms  2.199 ms  1.941 ms
+
 #traps parameters
 server.ip=172.25.21.69
 nsTrapVarAdmin=sting

src/com/zyxel/enc/netbar/agent/NRrouterMib.java

 import com.zyxel.enc.netbar.agent.generator.WanInterfaceTableGenerator;
 import java.text.SimpleDateFormat;
 import java.util.Date;
-import java.util.List;
 
 import org.snmp4j.agent.DuplicateRegistrationException;
 import org.snmp4j.agent.MOGroup;
     private static final OID oidLanInterfaceTable = new OID("1.3.6.1.4.1.890.1.5.17.1.8.1.1");
     private static final OID oidSwitchInterfaceTable = new OID("1.3.6.1.4.1.890.1.5.17.1.11.2.1.1");
     private static final OID oidTopArpTable = new OID("1.3.6.1.4.1.890.1.5.17.1.10.1.1.1");
+    
+    private static final String oidToolPingPrefix = "1.3.6.1.4.1.890.1.5.17.1.13.1.";
+    private static final String oidToolTracertPrefix = "1.3.6.1.4.1.890.1.5.17.1.13.2.";
 
 
     private static long startTime = 0;
 
         new SwitchDataHelper(server, context).registerQsInfoData();
         server.register(new SwitchInterfaceTableGenerator().generateTable(oidSwitchInterfaceTable), context);
+        
+        registerPingResult(server, context);
+        registerTracerouteResult(server, context);
     }
 
     @Override
         DefaultMOTable appTable = new AppStatisticsTableGenerator("app.statistics.all.number", "app.statistics.all.name.", "app.statistics.all.traffic.").generateTable(nsAppStatisticsAll);
         server.register(appTable, context);
     }
+    
+    private void registerPingResult(MOServer server, OctetString context) throws DuplicateRegistrationException {
+    	String ip = Config.get("ping.ip");
+    	String result = Config.get("ping.result");
+    	OID oid = new OID(oidToolPingPrefix + ip);
+    	server.register(MOCreator.createReadOnly(oid, result), context);
+    }
+    
+    private void registerTracerouteResult(MOServer server, OctetString context) throws DuplicateRegistrationException {
+    	String ip = Config.get("tracert.ip");
+    	String result = Config.get("tracert.result");
+    	OID oid = new OID(oidToolTracertPrefix + ip);
+    	server.register(MOCreator.createReadOnly(oid, result), context);
+    }
 }

src/com/zyxel/enc/netbar/agent/TrapSender.java

 package com.zyxel.enc.netbar.agent;
 
 import java.io.IOException;
-import java.net.InetAddress;
 import java.util.HashMap;
 import java.util.Map;
+
 import org.apache.log4j.Logger;
-
 import org.snmp4j.CommunityTarget;
 import org.snmp4j.PDU;
-import org.snmp4j.PDUv1;
 import org.snmp4j.Snmp;
 import org.snmp4j.TransportMapping;
 import org.snmp4j.mp.SnmpConstants;
 import org.snmp4j.smi.Address;
 import org.snmp4j.smi.GenericAddress;
 import org.snmp4j.smi.Integer32;
-import org.snmp4j.smi.IpAddress;
 import org.snmp4j.smi.OID;
 import org.snmp4j.smi.OctetString;
 import org.snmp4j.smi.TimeTicks;

src/com/zyxel/enc/netbar/agent/generator/SwitchInterfaceTableGenerator.java

 
 package com.zyxel.enc.netbar.agent.generator;
 
-import com.zyxel.enc.netbar.agent.AbstractTableGenerator;
-import com.zyxel.enc.netbar.agent.Config;
-import java.util.ArrayList;
-import java.util.List;
 import org.snmp4j.agent.mo.DefaultMOMutableRow2PC;
-import org.snmp4j.agent.mo.DefaultMOTable;
 import org.snmp4j.agent.mo.MOAccessImpl;
 import org.snmp4j.agent.mo.MOColumn;
 import org.snmp4j.agent.mo.MOMutableTableModel;
-import org.snmp4j.agent.mo.MOTableIndex;
-import org.snmp4j.agent.mo.MOTableSubIndex;
 import org.snmp4j.smi.Counter32;
 import org.snmp4j.smi.Integer32;
 import org.snmp4j.smi.OID;
 import org.snmp4j.smi.SMIConstants;
 import org.snmp4j.smi.Variable;
 
+import com.zyxel.enc.netbar.agent.AbstractTableGenerator;
+import com.zyxel.enc.netbar.agent.Config;
+
 /**
  *
  * @author sting
  */
 public class SwitchInterfaceTableGenerator extends AbstractTableGenerator {
-    private static final String PREFIX = "1.3.6.1.4.1.890.1.5.17.1.11.2.1.1";
 
     public SwitchInterfaceTableGenerator() {
     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.