Commits

stingh711 committed 45794d1

update topology

Comments (0)

Files changed (7)

-agent.ip=172.25.21.47/161
+agent.ip=172.25.21.16/161
 
 mac=00:a0:c5:00:00:11
 cpu.usage=60
 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.47
+server.ip=172.25.21.16
 nsTrapVarAdmin=sting
 nsTrapVarPort=10
 nsTrapVarBandwidth=134234

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

+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.zyxel.enc.netbar.agent.data;
+
+/**
+ *
+ * @author sting
+ */
+public class Device {
+    public static Device buildAhost(String ip, String mac) {
+        Device d = new Device(ip, mac);
+        d.type = "Host";
+        d.model = "";
+        d.vender = "dell";
+        d.firmware = "";
+        d.hardware = "";
+        d.portNumber = 0;
+        d.hostname = ip;
+        return d;
+    }
+    public static Device buildAswitch(String ip, String mac, String model, int portNumber) {
+        Device d = new Device(ip, mac);
+        d.type = "Switch";
+        d.model = model;
+        d.vender = "zyxel";
+        d.firmware = "3.90";
+        d.hardware = "2.1";
+        d.portNumber = portNumber;
+        d.hostname = ip;
+        return d;
+    }
+    public String hostname;
+    public String ip;
+    public String mac;
+    public String type;
+    public String model;
+    public String vender;
+    public String firmware;
+    public String hardware;
+    public int portNumber;
+
+    public Device(String ip, String mac) {
+        this.ip = ip;
+        this.hostname = ip;
+        this.mac = mac;
+    }
+}

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

+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.zyxel.enc.netbar.agent.data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @author sting
+ */
+public class Interface {
+    public static List<Interface> buildRouterInterfaces() {
+        List<Interface> result = new ArrayList<Interface>();
+        for (int i = 1; i <= 4; i++) {
+            //build wan interfaces
+            Interface in = new Interface();
+            in.index = i;
+            in.name = "wan" + i;
+            in.status = 1;
+            in.wanType = 1;
+            in.gateway = "1.1.1.1";
+            in.dns = "8.8.8.8";
+            in.iswan = 1;
+            result.add(in);
+        }
+        for (int i = 5; i <= 8; i++) {
+            //build lan interfaces
+            Interface in = new Interface();
+            in.index = i;
+            in.name = "lan" + (i-4);
+            in.mac = "00:a0:c5:00:00:0" + i;
+            in.mtu = 1000;
+            in.ip = "192.168.1." + i;
+            in.iswan = 2;
+            result.add(in);
+        }
+        for (Interface in : result) {
+            in.mask = "255.255.255.0";
+            in.sent = 1000;
+            in.recv = 20000;
+            in.description = in.name;
+            in.type = 2;
+        }
+        return result;
+    }
+
+    public String name;
+    public int status;
+    public int wanType;
+    public String mask;
+    public String gateway;
+    public String dns;
+    public int recv;
+    public int sent;
+
+    public int index;
+    public String description;
+    public int iswan;
+
+    public String ip;
+    public int enableNat;
+    public String mac;
+    public int mtu;
+    public int type;
+}

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

+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.zyxel.enc.netbar.agent.data;
+
+/**
+ *
+ * @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;
+    }
+}

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

+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.zyxel.enc.netbar.agent.data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @author sting
+ */
+public class Switch {
+    public static List<SwitchInterface> buildInterfaces(int portNumber, String ip) {
+        List<SwitchInterface> result = new ArrayList<SwitchInterface>();
+        for (int i = 1; i <= portNumber; i++) {
+            String prefix = "switch." + ip + ".interface." + i + ".";
+            SwitchInterface in = new SwitchInterface();
+            in.index = i;
+            in.description = "port" + i;
+            in.status = 1;
+            in.speed = 2;
+            in.mac = Config.get(prefix + "mac");
+            in.in = Config.getInt(prefix + "in");
+            in.out = Config.getInt(prefix + "out");
+            result.add(in);
+        }
+        return result;
+    }
+    public String ip;
+    public int cpuUsage;
+    public int memUsage;
+    public int broadcast;
+    public int voltage;
+    public int temperature;
+    public int portNumber;
+    public List<SwitchInterface> interfaces;
+
+    public static void main(String[] args) {
+        List<SwitchInterface> ins = buildInterfaces(48, "192.168.1.33");
+        System.out.println(ins);
+    }
+}

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

+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.zyxel.enc.netbar.agent.data;
+
+/**
+ *
+ * @author sting
+ */
+public class SwitchInterface {
+    public int index;
+    public String description;
+    public int status;
+    public int speed;
+    public String mac;
+    public int in;
+    public int out;
+}

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

+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.zyxel.enc.netbar.agent.data;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ *
+ * @author sting
+ */
+public class TopologyBuilder {
+    public static List<Device> buildDevices() {
+        List<Device> devices = new ArrayList<Device>();
+        int number = Integer.parseInt(Config.get("device.number"));
+        for (int i = 1; i <= number; i++) {
+            String prefix = "device." + i + ".";
+            String type = Config.get(prefix + "type");
+            String ip = Config.get(prefix + "ip");
+            String mac = Config.get(prefix + "mac");
+
+            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);
+            } else if (type.equals("Host")) {
+                d = Device.buildAhost(ip, mac);
+            }
+            devices.add(d);
+        }
+        return devices;
+    }
+
+    public static List<Link> buildLinks() {
+        List<Link> links = new ArrayList<Link>();
+        int number = Config.getInt("link.number");
+
+        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);
+            links.add(l);
+        }
+        return links;
+    }
+}