Search in sources :

Example 6 with SNMPTriple

use of com.yahoo.dba.perf.myperf.snmp.SNMPClient.SNMPTriple in project mysql_perf_analyzer by yahoo.

the class SNMPQueryProcessor method querySingleSNMP.

private ResultList querySingleSNMP(SNMPClient client, QueryParameters qps) throws Exception {
    //p2 will be oid
    String oid = qps.getSqlParams().get("p_2");
    List<SNMPTriple> snmpData = client.querySingleSNMPEntryByOID(oid);
    if (snmpData == null)
        return null;
    ColumnDescriptor desc = new ColumnDescriptor();
    desc.addColumn("NAME", false, 0);
    desc.addColumn("OID", false, 1);
    desc.addColumn("VALUE", false, 2);
    ResultList rList = new ResultList();
    rList.setColumnDescriptor(desc);
    for (SNMPTriple t : snmpData) {
        ResultRow row = new ResultRow();
        row.addColumn(t.name);
        row.addColumn(t.oid);
        row.addColumn(t.value);
        row.setColumnDescriptor(desc);
        rList.addRow(row);
    }
    return rList;
}
Also used : ResultRow(com.yahoo.dba.perf.myperf.common.ResultRow) ResultList(com.yahoo.dba.perf.myperf.common.ResultList) ColumnDescriptor(com.yahoo.dba.perf.myperf.common.ColumnDescriptor) SNMPTriple(com.yahoo.dba.perf.myperf.snmp.SNMPClient.SNMPTriple)

Example 7 with SNMPTriple

use of com.yahoo.dba.perf.myperf.snmp.SNMPClient.SNMPTriple in project mysql_perf_analyzer by yahoo.

the class SNMPQueryProcessor method queryStorage.

private ResultList queryStorage(SNMPClient client, QueryParameters qps) throws Exception {
    boolean diff = "1".equalsIgnoreCase(qps.getSqlParams().get("p_2"));
    Map<String, List<SNMPTriple>> snmpData = client.getStorageData(null);
    if (snmpData == null)
        return null;
    ColumnDescriptor desc = new ColumnDescriptor();
    desc.addColumn("NAME", false, 0);
    desc.addColumn("OID", false, 1);
    desc.addColumn("VALUE", false, 2);
    ResultList rList = new ResultList();
    rList.setColumnDescriptor(desc);
    for (Map.Entry<String, List<SNMPTriple>> e : snmpData.entrySet()) {
        String net = e.getKey();
        for (SNMPTriple t : e.getValue()) {
            if (diff) {
                try {
                    BigDecimal bd = new BigDecimal(t.value);
                } catch (Exception ex) {
                    continue;
                }
            }
            ResultRow row = new ResultRow();
            row.addColumn(net + "." + t.name);
            row.addColumn(t.oid);
            row.addColumn(t.value);
            row.setColumnDescriptor(desc);
            rList.addRow(row);
        }
    }
    return rList;
}
Also used : ResultRow(com.yahoo.dba.perf.myperf.common.ResultRow) ResultList(com.yahoo.dba.perf.myperf.common.ResultList) ColumnDescriptor(com.yahoo.dba.perf.myperf.common.ColumnDescriptor) SNMPTriple(com.yahoo.dba.perf.myperf.snmp.SNMPClient.SNMPTriple) List(java.util.List) ResultList(com.yahoo.dba.perf.myperf.common.ResultList) Map(java.util.Map) BigDecimal(java.math.BigDecimal) SQLException(java.sql.SQLException)

Aggregations

ColumnDescriptor (com.yahoo.dba.perf.myperf.common.ColumnDescriptor)7 ResultList (com.yahoo.dba.perf.myperf.common.ResultList)7 ResultRow (com.yahoo.dba.perf.myperf.common.ResultRow)7 SNMPTriple (com.yahoo.dba.perf.myperf.snmp.SNMPClient.SNMPTriple)7 BigDecimal (java.math.BigDecimal)5 SQLException (java.sql.SQLException)5 List (java.util.List)3 Map (java.util.Map)3