stingh711 avatar stingh711 committed 4895bcf

add app

Comments (0)

Files changed (2)

config.properties

 app.statistics.10mins.name.7=bt
 app.statistics.10mins.traffic.7=123452
 
+app.statistics.3hours.number=7
+app.statistics.3hours.name.1=qq
+app.statistics.3hours.traffic.1=1000
+app.statistics.3hours.name.2=msn
+app.statistics.3hours.traffic.2=200
+app.statistics.3hours.name.3=http
+app.statistics.3hours.traffic.3=10000
+app.statistics.3hours.name.4=skype
+app.statistics.3hours.traffic.4=10
+app.statistics.3hours.name.5=pplive
+app.statistics.3hours.traffic.5=245670
+app.statistics.3hours.name.6=gtalk
+app.statistics.3hours.traffic.6=123456
+app.statistics.3hours.name.7=bt
+app.statistics.3hours.traffic.7=123452
+
+app.statistics.24hours.number=7
+app.statistics.24hours.name.1=qq
+app.statistics.24hours.traffic.1=1000
+app.statistics.24hours.name.2=msn
+app.statistics.24hours.traffic.2=200
+app.statistics.24hours.name.3=http
+app.statistics.24hours.traffic.3=10000
+app.statistics.24hours.name.4=skype
+app.statistics.24hours.traffic.4=10
+app.statistics.24hours.name.5=pplive
+app.statistics.24hours.traffic.5=245670
+app.statistics.24hours.name.6=gtalk
+app.statistics.24hours.traffic.6=123456
+app.statistics.24hours.name.7=bt
+app.statistics.24hours.traffic.7=123452
+
+app.statistics.all.number=7
+app.statistics.all.name.1=qq
+app.statistics.all.traffic.1=1000
+app.statistics.all.name.2=msn
+app.statistics.all.traffic.2=200
+app.statistics.all.name.3=http
+app.statistics.all.traffic.3=10000
+app.statistics.all.name.4=skype
+app.statistics.all.traffic.4=10
+app.statistics.all.name.5=pplive
+app.statistics.all.traffic.5=245670
+app.statistics.all.name.6=gtalk
+app.statistics.all.traffic.6=123456
+app.statistics.all.name.7=bt
+app.statistics.all.traffic.7=123452
+

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

     static final OID nsAppStatistics10MinApplication = new OID("1.3.6.1.4.1.890.1.5.17.1.5.1.1.1");
     static final OID nsAppStatistics10MinTraffic = new OID("1.3.6.1.4.1.890.1.5.17.1.5.1.1.2");
     
+    static final OID nsAppStatistics3hours = new OID("1.3.6.1.4.1.890.1.5.17.1.5.2.1");
+    static final OID nsAppStatistics3hoursApplication = new OID("1.3.6.1.4.1.890.1.5.17.1.5.2.1.1");
+    static final OID nsAppStatistics3hoursTraffic = new OID("1.3.6.1.4.1.890.1.5.17.1.5.2.1.2");
     
+    static final OID nsAppStatistics24hours = new OID("1.3.6.1.4.1.890.1.5.17.1.5.3.1");
+    static final OID nsAppStatistics24hoursApplication = new OID("1.3.6.1.4.1.890.1.5.17.1.5.3.1.1");
+    static final OID nsAppStatistics24hoursTraffic = new OID("1.3.6.1.4.1.890.1.5.17.1.5.3.1.2");
+
+    static final OID nsAppStatisticsAll = new OID("1.3.6.1.4.1.890.1.5.17.1.5.4.1");
+    static final OID nsAppStatisticsAllApplication = new OID("1.3.6.1.4.1.890.1.5.17.1.5.4.1.1");
+    static final OID nsAppStatisticsAllTraffic = new OID("1.3.6.1.4.1.890.1.5.17.1.5.4.1.2");
     private static long startTime = 0;
     
     //Topology devices table columns
     private DefaultMOTable deviceTable;
     //App Statistics 10 mins table
     private DefaultMOTable app10MinsTable;
-    private static MOTableSubIndex[] topologyDevicesIndexs =
+    private DefaultMOTable app3hoursTable;
+    private DefaultMOTable app24hoursTable;
+    private DefaultMOTable appAllTable;
+    
+    private MOTableSubIndex[] topologyDevicesIndexs =
         new MOTableSubIndex[] {
         new MOTableSubIndex(SMIConstants.SYNTAX_INTEGER, 1, 1)  };
-
-    private static MOTableIndex topologyDevicesIndex =
+    private MOTableIndex topologyDevicesIndex =
         new MOTableIndex(topologyDevicesIndexs, false);
 
-    private static MOTableSubIndex[] app10MinsTableIndexs =
+    private MOTableSubIndex[] app10MinsTableIndexs =
         new MOTableSubIndex[] {
         new MOTableSubIndex(SMIConstants.SYNTAX_INTEGER, 1, 1)  };
+    private MOTableIndex app10MinsTableIndex =
+        new MOTableIndex(app10MinsTableIndexs, false);
 
-    private static MOTableIndex app10MinsTableIndex =
-        new MOTableIndex(app10MinsTableIndexs, false);
+    private MOTableSubIndex[] app3hoursTableIndexs =
+        new MOTableSubIndex[] {
+        new MOTableSubIndex(SMIConstants.SYNTAX_INTEGER, 1, 1)  };
+    private MOTableIndex app3hoursTableIndex =
+        new MOTableIndex(app3hoursTableIndexs, false);
+
+    private MOTableSubIndex[] app24hoursTableIndexs =
+        new MOTableSubIndex[] {
+        new MOTableSubIndex(SMIConstants.SYNTAX_INTEGER, 1, 1)  };
+    private MOTableIndex app24hoursTableIndex =
+        new MOTableIndex(app24hoursTableIndexs, false);
+
+    private MOTableSubIndex[] appAllTableIndexs =
+        new MOTableSubIndex[] {
+        new MOTableSubIndex(SMIConstants.SYNTAX_INTEGER, 1, 1)  };
+    private MOTableIndex appAllTableIndex =
+        new MOTableIndex(appAllTableIndexs, false);
 
     private static String getCurrentTimeAsString() {
     	return new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date());
         server.register(new DateAndTimeScalar(nsSysDateTime, MOAccessImpl.ACCESS_READ_ONLY, new OctetString(getCurrentTimeAsString())), context);
         createTopologyTables();
         server.register(deviceTable, context);
-        createAppStatistics10MinsTable();
+        createAppStatisticsTables();
         server.register(app10MinsTable, context);
+        server.register(app3hoursTable, context);
+        server.register(app24hoursTable, context);
+        server.register(appAllTable, context);
 	}
 
 	@Override
         deviceTable.setVolatile(true);
 	}
 	
-	private void createAppStatistics10MinsTable() {
+	private void createAppStatisticsTables() {
+		app10MinsTable = createAppStatisticsTable(nsAppStatistics10Min, app10MinsTableIndex, "app.statistics.10mins.number", "app.statistics.10mins.name.", "app.statistics.10mins.traffic.");
+		app3hoursTable = createAppStatisticsTable(nsAppStatistics3hours, app3hoursTableIndex, "app.statistics.3hours.number", "app.statistics.3hours.name.", "app.statistics.3hours.traffic.");
+		app24hoursTable = createAppStatisticsTable(nsAppStatistics24hours, app24hoursTableIndex, "app.statistics.24hours.number", "app.statistics.24hours.name.", "app.statistics.24hours.traffic.");
+		appAllTable = createAppStatisticsTable(nsAppStatisticsAll, appAllTableIndex, "app.statistics.all.number", "app.statistics.all.name.", "app.statistics.all.traffic.");
+	}
+
+	private DefaultMOTable createAppStatisticsTable(OID oid, MOTableIndex index, String numberKey, String nameKey, String trafficKey) {
 		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_COUNTER32, MOAccessImpl.ACCESS_READ_ONLY);
-        app10MinsTable = new DefaultMOTable(nsAppStatistics10Min, app10MinsTableIndex, columns);
-        MOMutableTableModel model = (MOMutableTableModel)app10MinsTable.getModel();
+        DefaultMOTable table = new DefaultMOTable(oid, index, columns);
+        MOMutableTableModel model = (MOMutableTableModel)table.getModel();
         
-        int number = Integer.parseInt(Config.get("app.statistics.10mins.number"));
+        int number = Integer.parseInt(Config.get(numberKey));
         
         for (int i = 1; i <= number; i++) {
         	Variable[] v = new Variable[] {
-                    new OctetString(Config.get("app.statistics.10mins.name."+i)),
-                    new Counter32(Long.parseLong(Config.get("app.statistics.10mins.traffic."+i)))
+                    new OctetString(Config.get(nameKey+i)),
+                    new Counter32(Long.parseLong(Config.get(trafficKey+i)))
                 };
         	model.addRow(new DefaultMOMutableRow2PC(new OID(String.valueOf(i)), v));
         }
         
-        app10MinsTable.setVolatile(true);
+        table.setVolatile(true);
+        return table;
 	}
 	
 }
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.