stingh711 avatar stingh711 committed 0cfb050

update topology

Comments (0)

Files changed (7)

 cpu.temperature=80
 host.active=100
 
-device.number=2
+device.number=3
 device.1.ip=192.168.1.33
 device.1.type=Switch
 device.1.model=GS2200-24
 device.1.mac=00:a0:c5:00:00:33
 device.1.portnumber=24
+device.1.parentPort=5
+device.1.rootPort=1
+device.1.serial=123456
 device.2.ip=192.168.1.100
 device.2.type=Host
 device.2.mac=00:a0:c5:00:00:35
+device.2.parentPort=2
+device.3.serial=
+device.3.ip=192.168.1.101
+device.3.type=Host
+device.3.mac=00:a0:c5:00:00:36
+device.3.parentPort=6
+device.3.serial=
+
+link.number=2
+link.1.node=00:a0:c5:00:00:11
+link.1.child=00:a0:c5:00:00:33 00:a0:c5:00:00:35
+link.2.node=00:a0:c5:00:00:33
+link.2.child=00:a0:c5:00:00:36
+
 #switch QS info data
 switch.number = 1
 switch.1.ip=192.168.1.33
 switch.192.168.1.33.interface.48.in=0
 switch.192.168.1.33.interface.48.out=0
 
-link.number=2
-link.1.srcip=192.168.1.5
-link.1.srcport=5
-link.1.dstip=192.168.1.33
-link.1.dstport=1
-link.2.srcip=192.168.1.5
-link.2.srcport=1
-link.2.dstip=192.168.1.100
-link.2.dstport=0
-
 app.statistics.10mins.number=7
-app.statistics.10mins.name.1=qq
+app.statistics.10mins.name.1=1
 app.statistics.10mins.traffic.1=1000
-app.statistics.10mins.name.2=msn
+app.statistics.10mins.name.2=2
 app.statistics.10mins.traffic.2=200
-app.statistics.10mins.name.3=http
+app.statistics.10mins.name.3=3
 app.statistics.10mins.traffic.3=10000
-app.statistics.10mins.name.4=skype
+app.statistics.10mins.name.4=4
 app.statistics.10mins.traffic.4=10
-app.statistics.10mins.name.5=pplive
+app.statistics.10mins.name.5=5
 app.statistics.10mins.traffic.5=245670
-app.statistics.10mins.name.6=gtalk
+app.statistics.10mins.name.6=6
 app.statistics.10mins.traffic.6=123456
-app.statistics.10mins.name.7=bt
+app.statistics.10mins.name.7=7
 app.statistics.10mins.traffic.7=123452
 
 app.statistics.3hours.number=7
-app.statistics.3hours.name.1=qq
+app.statistics.3hours.name.1=1
 app.statistics.3hours.traffic.1=1000
-app.statistics.3hours.name.2=msn
+app.statistics.3hours.name.2=2
 app.statistics.3hours.traffic.2=200
-app.statistics.3hours.name.3=http
+app.statistics.3hours.name.3=3
 app.statistics.3hours.traffic.3=10000
-app.statistics.3hours.name.4=skype
+app.statistics.3hours.name.4=4
 app.statistics.3hours.traffic.4=10
-app.statistics.3hours.name.5=pplive
+app.statistics.3hours.name.5=5
 app.statistics.3hours.traffic.5=245670
-app.statistics.3hours.name.6=gtalk
+app.statistics.3hours.name.6=6
 app.statistics.3hours.traffic.6=123456
-app.statistics.3hours.name.7=bt
+app.statistics.3hours.name.7=7
 app.statistics.3hours.traffic.7=123452
 
 app.statistics.24hours.number=7
-app.statistics.24hours.name.1=qq
+app.statistics.24hours.name.1=1
 app.statistics.24hours.traffic.1=1000
-app.statistics.24hours.name.2=msn
+app.statistics.24hours.name.2=2
 app.statistics.24hours.traffic.2=200
-app.statistics.24hours.name.3=http
+app.statistics.24hours.name.3=3
 app.statistics.24hours.traffic.3=10000
-app.statistics.24hours.name.4=skype
+app.statistics.24hours.name.4=4
 app.statistics.24hours.traffic.4=10
-app.statistics.24hours.name.5=pplive
+app.statistics.24hours.name.5=5
 app.statistics.24hours.traffic.5=245670
-app.statistics.24hours.name.6=gtalk
+app.statistics.24hours.name.6=6
 app.statistics.24hours.traffic.6=123456
-app.statistics.24hours.name.7=bt
+app.statistics.24hours.name.7=7
 app.statistics.24hours.traffic.7=123452
 
 app.statistics.all.number=7
-app.statistics.all.name.1=qq
+app.statistics.all.name.1=1
 app.statistics.all.traffic.1=1000
-app.statistics.all.name.2=msn
+app.statistics.all.name.2=2
 app.statistics.all.traffic.2=200
-app.statistics.all.name.3=http
+app.statistics.all.name.3=3
 app.statistics.all.traffic.3=10000
-app.statistics.all.name.4=skype
+app.statistics.all.name.4=4
 app.statistics.all.traffic.4=10
-app.statistics.all.name.5=pplive
+app.statistics.all.name.5=5
 app.statistics.all.traffic.5=245670
-app.statistics.all.name.6=gtalk
+app.statistics.all.name.6=6
 app.statistics.all.traffic.6=123456
-app.statistics.all.name.7=bt
+app.statistics.all.name.7=7
 app.statistics.all.traffic.7=123452
 
 #data for current session

src/com/zyxel/enc/netbar/agent/data/Device.java

  * @author sting
  */
 public class Device {
-    public static Device buildAhost(String ip, String mac) {
+    public static Device buildAhost(String ip, String mac, int parentPort) {
         Device d = new Device(ip, mac);
-        d.type = "Host";
+        d.type = 2;
         d.model = "";
         d.vender = "dell";
         d.firmware = "";
         d.hardware = "";
         d.portNumber = 0;
         d.hostname = ip;
+        d.parentPort = parentPort;
+        d.rootPort = 0;
+        d.serial = "";
         return d;
     }
-    public static Device buildAswitch(String ip, String mac, String model, int portNumber) {
+    public static Device buildAswitch(String ip, String mac, String model, int portNumber, int parentPort, int rootPort) {
         Device d = new Device(ip, mac);
-        d.type = "Switch";
+        d.type = 1;
         d.model = model;
         d.vender = "zyxel";
         d.firmware = "3.90";
         d.hardware = "2.1";
         d.portNumber = portNumber;
         d.hostname = ip;
+        d.parentPort = parentPort;
+        d.rootPort = rootPort;
         return d;
     }
     public String hostname;
     public String ip;
     public String mac;
-    public String type;
+    public int type;
     public String model;
     public String vender;
     public String firmware;
     public String hardware;
     public int portNumber;
+    public int parentPort;
+    public int rootPort;
+    public String serial;
+
 
     public Device(String ip, String mac) {
         this.ip = ip;
         this.hostname = ip;
         this.mac = mac;
     }
+
+    @Override
+    public String toString() {
+        return "Device{" + "hostname=" + hostname + ", ip=" + ip + ", mac=" + mac + ", type=" + type + ", model=" + model + ", vender=" + vender + ", firmware=" + firmware + ", hardware=" + hardware + ", portNumber=" + portNumber + ", parentPort=" + parentPort + ", rootPort=" + rootPort + ", serial=" + serial + '}';
+    }
 }

src/com/zyxel/enc/netbar/agent/data/Link.java

  * @author sting
  */
 public class Link {
-    public String srcIp;
-    public int srcPort;
-    public String dstIp;
-    public int dstPort;
-    public int type = 3;
-    public Link(String srcIp, int srcPort, String dstIp, int dstPort) {
-        this.srcIp = srcIp;
-        this.srcPort = srcPort;
-        this.dstIp = dstIp;
-        this.dstPort = dstPort;
+    public String node;
+    public String childNode;
+
+    public Link(String n, String c) {
+        node = n;
+        childNode = c;
     }
 }

src/com/zyxel/enc/netbar/agent/data/TopologyBuilder.java

             String type = Config.get(prefix + "type");
             String ip = Config.get(prefix + "ip");
             String mac = Config.get(prefix + "mac");
+            int parentPort = Config.getInt(prefix + "parentPort");
 
             Device d = null;
             if (type.equals("Switch")) {
                 String model = Config.get(prefix + "model");
                 int portNumber = Config.getInt(prefix + "portnumber");
-                d = Device.buildAswitch(ip, mac, model, portNumber);
+                int rootPort = Config.getInt(prefix + "rootPort");
+                d = Device.buildAswitch(ip, mac, model, portNumber, parentPort, rootPort);
+                String serial = Config.get(prefix + "serial");
+                d.serial = serial;
             } else if (type.equals("Host")) {
-                d = Device.buildAhost(ip, mac);
+                d = Device.buildAhost(ip, mac, parentPort);
             }
+
+
             devices.add(d);
         }
         return devices;
 
         for (int i = 1; i <= number; i++) {
             String prefix = "link." + i + ".";
-            String srcIp = Config.get(prefix + "srcip");
-            int srcPort = Config.getInt(prefix + "srcport");
-            String dstIp = Config.get(prefix + "dstip");
-            int dstPort = Config.getInt(prefix + "dstport");
-            Link l = new Link(srcIp, srcPort, dstIp, dstPort);
+            String node = Config.get(prefix + "node");
+            String child = Config.get(prefix + "child");
+            Link l = new Link(node, child);
             links.add(l);
         }
         return links;

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

 import org.snmp4j.agent.mo.MOColumn;
 import org.snmp4j.agent.mo.MOMutableTableModel;
 import org.snmp4j.smi.Counter32;
+import org.snmp4j.smi.Integer32;
 import org.snmp4j.smi.OID;
 import org.snmp4j.smi.OctetString;
 import org.snmp4j.smi.SMIConstants;
     @Override
     public MOColumn[] defineColumns() {
         MOColumn[] columns = new MOColumn[2];
-        columns[0] = new MOColumn(1, SMIConstants.SYNTAX_OCTET_STRING, MOAccessImpl.ACCESS_READ_ONLY);
+        columns[0] = new MOColumn(1, SMIConstants.SYNTAX_INTEGER, MOAccessImpl.ACCESS_READ_ONLY);
         columns[1] = new MOColumn(2, SMIConstants.SYNTAX_COUNTER32, MOAccessImpl.ACCESS_READ_ONLY);
         return columns;
     }
 
         for (int i = 1; i <= number; i++) {
             Variable[] v = new Variable[]{
-                new OctetString(Config.get(nameKey + i)),
+                new Integer32(Config.getInt(nameKey + i)),
                 new Counter32(Long.parseLong(Config.get(trafficKey + i)))
             };
             model.addRow(new DefaultMOMutableRow2PC(new OID(String.valueOf(i)), v));

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

 
         for (int i = 1; i <= number; i++) {
             Device d = devices.get(i-1);
+            System.out.println(d);
             Variable[] v = new Variable[]{
                 new OctetString(d.hostname),
                 new IpAddress(d.ip),
                 new OctetString(d.mac),
-                new OctetString(d.type),
+                new Integer32(d.type),
+                new Integer32(d.parentPort),
+                new Integer32(d.rootPort),
                 new OctetString(d.model),
                 new OctetString(d.vender),
                 new OctetString(d.firmware),
                 new OctetString(d.hardware),
-                new Integer32(d.portNumber)
+                new Integer32(d.portNumber),
+                new OctetString(d.serial)
             };
             model.addRow(new DefaultMOMutableRow2PC(new OID(String.valueOf(i)), v));
         }
 
     @Override
     public MOColumn[] defineColumns() {
-        MOColumn[] columns = new MOColumn[9];
+        MOColumn[] columns = new MOColumn[12];
         columns[0] = new MOColumn(1, SMIConstants.SYNTAX_OCTET_STRING, MOAccessImpl.ACCESS_READ_ONLY);
         columns[1] = new MOColumn(2, SMIConstants.SYNTAX_IPADDRESS, MOAccessImpl.ACCESS_READ_ONLY);
         columns[2] = new MOColumn(3, SMIConstants.SYNTAX_OCTET_STRING, MOAccessImpl.ACCESS_READ_ONLY);
-        columns[3] = new MOColumn(4, SMIConstants.SYNTAX_OCTET_STRING, MOAccessImpl.ACCESS_READ_ONLY);
-        columns[4] = new MOColumn(5, SMIConstants.SYNTAX_OCTET_STRING, MOAccessImpl.ACCESS_READ_ONLY);
-        columns[5] = new MOColumn(6, SMIConstants.SYNTAX_OCTET_STRING, MOAccessImpl.ACCESS_READ_ONLY);
+        columns[3] = new MOColumn(4, SMIConstants.SYNTAX_INTEGER, MOAccessImpl.ACCESS_READ_ONLY);
+        columns[4] = new MOColumn(5, SMIConstants.SYNTAX_INTEGER, MOAccessImpl.ACCESS_READ_ONLY);
+        columns[5] = new MOColumn(6, SMIConstants.SYNTAX_INTEGER, MOAccessImpl.ACCESS_READ_ONLY);
         columns[6] = new MOColumn(7, SMIConstants.SYNTAX_OCTET_STRING, MOAccessImpl.ACCESS_READ_ONLY);
         columns[7] = new MOColumn(8, SMIConstants.SYNTAX_OCTET_STRING, MOAccessImpl.ACCESS_READ_ONLY);
-        columns[8] = new MOColumn(9, SMIConstants.SYNTAX_INTEGER, MOAccessImpl.ACCESS_READ_ONLY);
+        columns[8] = new MOColumn(9, SMIConstants.SYNTAX_OCTET_STRING, MOAccessImpl.ACCESS_READ_ONLY);
+        columns[9] = new MOColumn(10, SMIConstants.SYNTAX_OCTET_STRING, MOAccessImpl.ACCESS_READ_ONLY);
+        columns[10] = new MOColumn(11, SMIConstants.SYNTAX_INTEGER, MOAccessImpl.ACCESS_READ_ONLY);
+        columns[11] = new MOColumn(12, SMIConstants.SYNTAX_OCTET_STRING, MOAccessImpl.ACCESS_READ_ONLY);
 
         return columns;
     }

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

 import org.snmp4j.smi.Integer32;
 import org.snmp4j.smi.IpAddress;
 import org.snmp4j.smi.OID;
+import org.snmp4j.smi.OctetString;
 import org.snmp4j.smi.SMIConstants;
 import org.snmp4j.smi.Variable;
 
 
     @Override
     public MOColumn[] defineColumns() {
-        MOColumn[] columns = new MOColumn[5];
-        columns[0] = new MOColumn(1, SMIConstants.SYNTAX_IPADDRESS, MOAccessImpl.ACCESS_READ_ONLY);
-        columns[1] = new MOColumn(2, SMIConstants.SYNTAX_INTEGER32, MOAccessImpl.ACCESS_READ_ONLY);
-        columns[2] = new MOColumn(3, SMIConstants.SYNTAX_IPADDRESS, MOAccessImpl.ACCESS_READ_ONLY);
-        columns[3] = new MOColumn(4, SMIConstants.SYNTAX_INTEGER32, MOAccessImpl.ACCESS_READ_ONLY);
-        columns[4] = new MOColumn(5, SMIConstants.SYNTAX_INTEGER32, MOAccessImpl.ACCESS_READ_ONLY);
+        MOColumn[] columns = new MOColumn[2];
+        columns[0] = new MOColumn(1, SMIConstants.SYNTAX_OCTET_STRING, MOAccessImpl.ACCESS_READ_ONLY);
+        columns[1] = new MOColumn(2, SMIConstants.SYNTAX_OCTET_STRING, MOAccessImpl.ACCESS_READ_ONLY);
         return columns;
     }
 
         for (int i = 1; i <= number; i++) {
             Link l = links.get(i-1);
             Variable[] v = new Variable[]{
-                new IpAddress(l.srcIp),
-                new Integer32(l.srcPort),
-                new IpAddress(l.dstIp),
-                new Integer32(l.dstPort),
+                new OctetString(l.node),
+                new OctetString(l.childNode)
             };
             model.addRow(new DefaultMOMutableRow2PC(new OID(String.valueOf(i)), v));
         }
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.