/** * PollAPI's handle is obtained using the NmsUtil's getAPI() method. A schema to store the data * collected for the three dataIdentifieres namely IFINOCTETS,IFOUTOCTETS,IFERRORS of an agent for * a particular time in a single row of a table called 'WinNTtable' is created and added to the * database using the PollAPI. Then the table 'WintNTtable' is created corresponding to this * schema using the PollAPI's createTable() method. Finally this table is asscociated with all * PolledData whose policyName equals 'WindowsNT' */ public Vector applyPollFilter(ManagedObject obj, Vector pdatasVect) { Vector pvector = pdatasVect; PolledData pd = null; if (flag) { try { // PollAPI's handle is obtained using NmsUtil's // getAPI() method. api = (PollAPI) NmsUtil.getAPI("PollAPI"); } catch (Exception e) { System.out.println("Error occurred while getting PollAPI handle: " + e); e.printStackTrace(); } try { // form the schema and create the WinNTtable. // Note: This schema is created for mysql database. User should // modify this schema depending upon the database. String schema = "create table <> (AGENT varchar(100),IFINOCTETS BIGINT, IFOUTOCTETS BIGINT, IFERRORS BIGINT,TIMEOFCOL varchar(100))"; String tablename = "WinNTtable"; api.addCreateSchema(tablename, schema); api.createTable("WinNTtable"); } catch (Exception e) { System.out.println("Exception in creating Schema and adding table"); e.printStackTrace(); } // flag is set to false since table is created flag = false; } // The vector of PolledData objects is enumerated and checked for the // policyName. If it equals to 'WindowsNT, then the statsDataTableName // of the PolledData is set to "WinNTtable" so that all the data // collected for this PolledData would be stored in this table. for (Enumeration e = pvector.elements(); e.hasMoreElements(); ) { pd = (PolledData) e.nextElement(); if (pd.getPolicyName().equals("WindowsNT")) { pd.setStatsDataTableName("WinNTtable"); } } // finally return the PolledData vector after setting the table name // to all PolledData whose policyName equals "WindowsNT". return pvector; }
void refresh() { JPanel4.showCard("router"); // No Internationalisation if (routerobject != null) { ((com.adventnet.nms.examples.routermap.RouterDetails) JPanel4.getCard("router")) .setValues((Properties) routerobject.elementAt(0)); // No Internationalisation Properties prop = (Properties) routerobject.elementAt(0); RouterBtn.setBackground( SeverityInfo.getInstance() .getColor(Integer.parseInt(prop.getProperty("status")))); // No Internationalisation RouterBtn.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation JLabel1.setText( NmsClientUtil.GetString("Router details : ") + prop.getProperty("name")); // No Internationalisation } if (routerobject.size() >= 2) { one.setVisible(true); Properties prop = (Properties) routerobject.elementAt(1); one.setValues( SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))), prop.getProperty("ipAddress")); // No Internationalisation one.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation } if (routerobject.size() >= 3) { two.setVisible(true); Properties prop = (Properties) routerobject.elementAt(2); two.setValues( SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))), prop.getProperty("ipAddress")); // No Internationalisation two.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation } if (routerobject.size() >= 4) { three.setVisible(true); Properties prop = (Properties) routerobject.elementAt(3); three.setValues( SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))), prop.getProperty("ipAddress")); // No Internationalisation three.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation } if (routerobject.size() >= 5) { four.setVisible(true); Properties prop = (Properties) routerobject.elementAt(4); four.setValues( SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))), prop.getProperty("ipAddress")); // No Internationalisation four.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation } if (routerobject.size() >= 6) { five.setVisible(true); Properties prop = (Properties) routerobject.elementAt(5); five.setValues( SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))), prop.getProperty("ipAddress")); // No Internationalisation five.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation } if (routerobject.size() >= 7) { six.setVisible(true); Properties prop = (Properties) routerobject.elementAt(6); six.setValues( SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))), prop.getProperty("ipAddress")); // No Internationalisation six.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation } if (routerobject.size() >= 8) { seven.setVisible(true); Properties prop = (Properties) routerobject.elementAt(7); seven.setValues( SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))), prop.getProperty("ipAddress")); // No Internationalisation seven.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation } if (routerobject.size() >= 9) { eight.setVisible(true); Properties prop = (Properties) routerobject.elementAt(8); eight.setValues( SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))), prop.getProperty("ipAddress")); // No Internationalisation eight.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation } if (routerobject.size() >= 10) { nine.setVisible(true); Properties prop = (Properties) routerobject.elementAt(9); nine.setValues( SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))), prop.getProperty("ipAddress")); // No Internationalisation nine.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation } if (routerobject.size() >= 11) { ten.setVisible(true); Properties prop = (Properties) routerobject.elementAt(10); ten.setValues( SeverityInfo.getInstance().getColor(Integer.parseInt(prop.getProperty("status"))), prop.getProperty("ipAddress")); // No Internationalisation ten.setToolTipText(prop.getProperty("ipAddress")); // No Internationalisation } }