Search in sources :

Example 16 with ColumnDescriptor

use of com.yahoo.dba.perf.myperf.common.ColumnDescriptor in project mysql_perf_analyzer by yahoo.

the class SNMPQueryProcessor method queryMysqldData.

private ResultList queryMysqldData(SNMPClient client, QueryParameters qps) throws Exception {
    boolean diff = "1".equalsIgnoreCase(qps.getSqlParams().get("p_2"));
    List<SNMPTriple> snmpData = null;
    try {
        snmpData = client.getProcessData("mysqld");
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Failed to retrieve mysqld perf data", ex);
    }
    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) {
        if (diff) {
            try {
                BigDecimal bd = new BigDecimal(t.value);
            } catch (Exception ex) {
                continue;
            }
        }
        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) SQLException(java.sql.SQLException) BigDecimal(java.math.BigDecimal)

Example 17 with ColumnDescriptor

use of com.yahoo.dba.perf.myperf.common.ColumnDescriptor 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 18 with ColumnDescriptor

use of com.yahoo.dba.perf.myperf.common.ColumnDescriptor 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)

Example 19 with ColumnDescriptor

use of com.yahoo.dba.perf.myperf.common.ColumnDescriptor in project mysql_perf_analyzer by yahoo.

the class InnoController method buildTransactionList.

private static ResultList buildTransactionList(List<Transaction> txs) {
    ResultList rList = new ResultList();
    ColumnDescriptor desc = new ColumnDescriptor();
    int idx = 1;
    desc.addColumn("ID", false, idx++);
    desc.addColumn("STATE", false, idx++);
    desc.addColumn("TIME", false, idx++);
    desc.addColumn("PROCESS", false, idx++);
    desc.addColumn("THREAD", false, idx++);
    desc.addColumn("USER", false, idx++);
    desc.addColumn("HOST", false, idx++);
    desc.addColumn("QUERY_ID", false, idx++);
    //desc.addColumn("ACTION", false, idx++);
    desc.addColumn("SQL_STATE", false, idx++);
    desc.addColumn("SQL", false, idx++);
    desc.addColumn("LOCKS", false, idx++);
    //TODO lock strcuts
    rList.setColumnDescriptor(desc);
    for (Transaction tx : txs) {
        if ("not started".equalsIgnoreCase(tx.state) && (tx.sql == null || tx.sql.isEmpty()))
            //ignore idle one
            continue;
        ResultRow row = new ResultRow();
        rList.addRow(row);
        row.setColumnDescriptor(desc);
        List<String> cols = new ArrayList<String>(16);
        row.setColumns(cols);
        cols.add(tx.id);
        cols.add(tx.state);
        cols.add(tx.txTime);
        cols.add(tx.processNumber);
        cols.add(tx.threadId);
        cols.add(tx.user);
        cols.add(tx.host);
        cols.add(tx.queryId);
        //cols.add(tx.action);
        cols.add(tx.cmd);
        cols.add(tx.sql);
        if (tx.action != null && !tx.action.isEmpty() && tx.comments != null)
            cols.add(tx.action + "\n" + tx.comments);
        else if (tx.action != null && !tx.action.isEmpty() && tx.comments == null)
            cols.add(tx.action);
        else
            cols.add(tx.comments);
    }
    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) ArrayList(java.util.ArrayList)

Example 20 with ColumnDescriptor

use of com.yahoo.dba.perf.myperf.common.ColumnDescriptor in project mysql_perf_analyzer by yahoo.

the class TableMetaProcessor method queryMultiple.

@Override
public void queryMultiple(MyPerfContext context, DBInstanceInfo dbinfo, String appUser, DBConnectionWrapper connWrapper, QueryParameters qps, Map<String, ResultList> rListMap) throws java.sql.SQLException {
    for (int i = 0; i < TBL_QUERIES.length; i++) {
        QueryParameters qps2 = new QueryParameters();
        qps2.setSql(TBL_QUERIES[i]);
        qps2.getSqlParams().put("p_1", qps.getSqlParams().get("p_1"));
        qps2.getSqlParams().put("p_2", qps.getSqlParams().get("p_2"));
        ResultList rList = null;
        try {
            rList = context.getQueryEngine().executeQueryGeneric(qps2, connWrapper, qps.getMaxRows());
        } catch (Throwable th) {
            logger.log(Level.WARNING, "Error when retrieve meta data", th);
            if (th instanceof SQLException) {
                //check if the connection is still good
                if (!DBUtils.checkConnection(connWrapper.getConnection())) {
                    throw SQLException.class.cast(th);
                }
            }
            Sql sql = context.getSqlManager().getSql(qps2.getSql());
            if (sql != null && sql.isErrorInline()) {
                rList = new ResultList();
                ColumnDescriptor desc = new ColumnDescriptor();
                desc.addColumn("Status", false, 0);
                desc.addColumn("Message", false, 1);
                rList.setColumnDescriptor(desc);
                ResultRow row = new ResultRow();
                row.setColumnDescriptor(desc);
                row.addColumn("Error");
                row.addColumn(th.getMessage());
                rList.addRow(row);
            }
        }
        rListMap.put(TBL_QUERIES[i], rList);
    }
}
Also used : ResultRow(com.yahoo.dba.perf.myperf.common.ResultRow) ResultList(com.yahoo.dba.perf.myperf.common.ResultList) SQLException(java.sql.SQLException) ColumnDescriptor(com.yahoo.dba.perf.myperf.common.ColumnDescriptor) QueryParameters(com.yahoo.dba.perf.myperf.common.QueryParameters) Sql(com.yahoo.dba.perf.myperf.common.Sql)

Aggregations

ColumnDescriptor (com.yahoo.dba.perf.myperf.common.ColumnDescriptor)21 ResultList (com.yahoo.dba.perf.myperf.common.ResultList)21 ResultRow (com.yahoo.dba.perf.myperf.common.ResultRow)20 SQLException (java.sql.SQLException)9 ArrayList (java.util.ArrayList)9 Map (java.util.Map)8 SNMPTriple (com.yahoo.dba.perf.myperf.snmp.SNMPClient.SNMPTriple)7 BigDecimal (java.math.BigDecimal)5 List (java.util.List)5 DBInstanceInfo (com.yahoo.dba.perf.myperf.common.DBInstanceInfo)4 QueryParameters (com.yahoo.dba.perf.myperf.common.QueryParameters)4 HashMap (java.util.HashMap)4 ModelAndView (org.springframework.web.servlet.ModelAndView)4 HashSet (java.util.HashSet)3 ColumnInfo (com.yahoo.dba.perf.myperf.common.ColumnInfo)2 Connection (java.sql.Connection)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 LinkedHashMap (java.util.LinkedHashMap)2 AlertSubscribers (com.yahoo.dba.perf.myperf.common.AlertSubscribers)1