private MachinePerformanceData getCurrentMachinePerformanceData(MachinePolicy mp) { MachinePerformanceData ret = new MachinePerformanceData(); Connection con = null; rs = com.executeQuery(); if (rs.next()) { ret.setBytesusedMemory(rs.getLong("memoryused")); ret.setId(rs.getString("id")); ret.setNumberofActiveThreads(rs.getLong("threads")); ret.setPercentusedCPU(rs.getDouble("percentCPU")); ret.setUri(rs.getString("uri")); GregorianCalendar gcal = new GregorianCalendar(); gcal.setTimeInMillis(rs.getLong("utcdatetime")); ret.setTimestamp((gcal)); ret.getDriveInformation().addAll(this.getCurrentDriveInformation(mp)); ret.getNetworkAdapterPerformanceData().addAll(GetCurrentNicInfo(mp)); try { StatusHelper sh = getStatus(mp.getURL()); if (sh != null) { ret.setOperationalstatus(sh.running); ret.setStatusmessage(sh.msg); } else { ret.setStatusmessage("Unknown"); ret.setOperationalstatus(false); ret.setStatusmessage("Unknown"); log.log(Level.WARN, "trouble getting status info", ex);
@Override public boolean CheckTransactionalRule(MachinePerformanceData req, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg) { if (nullableFaultMsg == null) { nullableFaultMsg = new AtomicReference<String>(); } if (req.getBytesusedMemory() == null) { return false; } NameValuePair GetNameValuePairByName = Utility.getNameValuePairByName(params, "value"); long rate = Long.parseLong(GetNameValuePairByName.getValue()); long faultrate = req.getBytesusedMemory().longValue(); if (faultrate < rate) { nullableFaultMsg.set("The measured CPU Usage of " + faultrate + " is higher than " + rate + ", " + nullableFaultMsg.get()); return true; } return false; }
@Override public boolean CheckTransactionalRule(MachinePerformanceData req, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg) { if (nullableFaultMsg != null) { nullableFaultMsg = new AtomicReference<String>(); } NameValuePair value = Utility.getNameValuePairByName(params, "value"); int x = 0; if (value.isEncrypted()) { x = Integer.parseInt(Utility.DE(value.getValue())); } else { x = Integer.parseInt(value.getValue()); } if (req.getNumberofActiveThreads() != null && x > req.getNumberofActiveThreads().longValue()) { nullableFaultMsg.set("The number of active threads, " + req.getNumberofActiveThreads() + " is higher than the threshold of " + x + ", " + nullableFaultMsg.get()); return true; } return false; }
if (Utility.stringIsNullOrEmpty(req.getMachineData().getUri())) { throw new IllegalArgumentException("The element MachineData must specify a uri representing the system, typically in the format urn:hostname:system"); + "(uri, memoryused, percentcpu, id, utcdatetime, threads, startedat) " + "VALUES (?, ?, ?, ?, ? ,?, ?);"); com.setString(1, Utility.truncate(req.getMachineData().getUri(), MAXTEXT)); if (req.getMachineData().getBytesusedMemory() == null) { com.setNull(2, java.sql.Types.BIGINT); } else { com.setLong(2, req.getMachineData().getBytesusedMemory()); if (req.getMachineData().getPercentusedCPU() == null) { com.setNull(3, java.sql.Types.INTEGER); } else { com.setLong(3, req.getMachineData().getPercentusedCPU().intValue()); req.getMachineData().setId(id.toString()); com.setString(4, id.toString()); if (req.getMachineData().getTimestamp() == null) { com.setLong(5, now); } else { com.setLong(5, req.getMachineData().getTimestamp().getTimeInMillis()); if (req.getMachineData().getNumberofActiveThreads() == null) { com.setNull(6, java.sql.Types.BIGINT); } else { com.setLong(6, req.getMachineData().getNumberofActiveThreads()); if (req.getMachineData().getStartedAt() == null) {
for (int i = 0; i < res.getMachinePerformanceData().size(); i++) { for (int k = 0; k < res.getMachinePerformanceData().get(i).getDriveInformation().size(); k++) { TransactionLogTimeStampStruct t2 = new TransactionLogTimeStampStruct(); t2.cal = res.getMachinePerformanceData().get(i).getTimestamp(); t2.ResponseTime = res.getMachinePerformanceData().get(i).getDriveInformation().get(k).getFreespace(); if (dataRX.Contains(res.getMachinePerformanceData().get(i).getDriveInformation().get(k).getPartition())) { dataRX.get(res.getMachinePerformanceData().get(i).getDriveInformation().get(k).getPartition()).add(t2); } else { RateStruct t3 = new RateStruct(); t3.item = res.getMachinePerformanceData().get(i).getDriveInformation().get(k).getPartition(); t3.data = new ArrayList<TransactionLogTimeStampStruct>(); t3.data.add(t2);
public Object produceDataset(Map params) throws DatasetProduceException { TimeSeriesCollection col = new TimeSeriesCollection(); try { //Logger.getAnonymousLogger().log(Level.INFO, "fgsmsWEB debug, size" + params.size()); GetMachinePerformanceLogsByRangeResponseMsg res = (GetMachinePerformanceLogsByRangeResponseMsg) params.get("fgsms.data"); if (res != null && res.getMachinePerformanceData() != null && !res.getMachinePerformanceData().isEmpty()) { TimeSeries s = new TimeSeries("CPU %", org.jfree.data.time.Millisecond.class); for (int i = 0; i < res.getMachinePerformanceData().size(); i++) { Millisecond m = new Millisecond(res.getMachinePerformanceData().get(i).getTimestamp().getTime()); // TimeSeriesDataItem t = new TimeSeriesDataItem(m, // recordset.stuff.get(i).data.get(k).ResponseTime); // s.add(t); if (res.getMachinePerformanceData().get(i).getPercentusedCPU()!=null) s.addOrUpdate(m, res.getMachinePerformanceData().get(i).getPercentusedCPU()); } col.addSeries(s); } } catch (Exception ex) { LogHelper.getLog().log(Level.ERROR, "ProcessPerfLogsOverTime produce chart data " + ex.getLocalizedMessage()); } return col; }
public Object produceDataset(Map params) throws DatasetProduceException { TimeSeriesCollection col = new TimeSeriesCollection(); try { //Logger.getAnonymousLogger().log(Level.INFO, "fgsmsWEB debug, size" + params.size()); GetMachinePerformanceLogsByRangeResponseMsg res = (GetMachinePerformanceLogsByRangeResponseMsg) params.get("fgsms.data"); if (res != null && res.getMachinePerformanceData() != null && !res.getMachinePerformanceData().isEmpty()) { TimeSeries s = new TimeSeries("Active Threads", org.jfree.data.time.Millisecond.class); for (int i = 0; i < res.getMachinePerformanceData().size(); i++) { Millisecond m = new Millisecond(res.getMachinePerformanceData().get(i).getTimestamp().getTime()); // TimeSeriesDataItem t = new TimeSeriesDataItem(m, // recordset.stuff.get(i).data.get(k).ResponseTime); // s.add(t); if (res.getMachinePerformanceData().get(i).getNumberofActiveThreads() != null) { s.addOrUpdate(m, res.getMachinePerformanceData().get(i).getNumberofActiveThreads()); } } col.addSeries(s); } } catch (Exception ex) { LogHelper.getLog().log(Level.ERROR, "ProcessPerfLogsOverTimeThreads produce chart data " + ex.getLocalizedMessage()); } return col; }
public Object produceDataset(Map params) throws DatasetProduceException { TimeSeriesCollection col = new TimeSeriesCollection(); try { //Logger.getAnonymousLogger().log(Level.INFO, "fgsmsWEB debug, size" + params.size()); GetMachinePerformanceLogsByRangeResponseMsg res = (GetMachinePerformanceLogsByRangeResponseMsg) params.get("fgsms.data"); if (res != null && res.getMachinePerformanceData() != null && !res.getMachinePerformanceData().isEmpty()) { TimeSeries s = new TimeSeries("Memory (bytes)", org.jfree.data.time.Millisecond.class); for (int i = 0; i < res.getMachinePerformanceData().size(); i++) { Millisecond m = new Millisecond(res.getMachinePerformanceData().get(i).getTimestamp().getTime()); // TimeSeriesDataItem t = new TimeSeriesDataItem(m, // recordset.stuff.get(i).data.get(k).ResponseTime); // s.add(t); if (res.getMachinePerformanceData().get(i).getBytesusedMemory()!=null) s.addOrUpdate(m, res.getMachinePerformanceData().get(i).getBytesusedMemory()); } col.addSeries(s); } } catch (Exception ex) { LogHelper.getLog().log(Level.ERROR, "ProcessPerfLogsOverTimeMem produce chart data " + ex.getLocalizedMessage()); } return col; }
for (int i = 0; i < res.getMachinePerformanceData().size(); i++) { for (int k = 0; k < res.getMachinePerformanceData().get(i).getNetworkAdapterPerformanceData().size(); k++) { TransactionLogTimeStampStruct t2 = new TransactionLogTimeStampStruct(); t2.ResponseTime = res.getMachinePerformanceData().get(i).getNetworkAdapterPerformanceData().get(k).getKilobytespersecondNetworkReceive(); t2.cal = res.getMachinePerformanceData().get(i).getTimestamp(); if (dataRX.Contains(res.getMachinePerformanceData().get(i).getNetworkAdapterPerformanceData().get(k).getAdapterName())) { dataRX.get(res.getMachinePerformanceData().get(i).getNetworkAdapterPerformanceData().get(k).getAdapterName()).add(t2); } else { RateStruct t3 = new RateStruct(); t3.item = res.getMachinePerformanceData().get(i).getNetworkAdapterPerformanceData().get(k).getAdapterName(); t3.data = new ArrayList<TransactionLogTimeStampStruct>(); t3.data.add(t2); t2.ResponseTime = res.getMachinePerformanceData().get(i).getNetworkAdapterPerformanceData().get(k).getKilobytespersecondNetworkTransmit(); t2.cal = res.getMachinePerformanceData().get(i).getTimestamp(); if (dataTX.Contains(res.getMachinePerformanceData().get(i).getNetworkAdapterPerformanceData().get(k).getAdapterName())) { dataTX.get(res.getMachinePerformanceData().get(i).getNetworkAdapterPerformanceData().get(k).getAdapterName()).add(t2); } else { RateStruct t3 = new RateStruct(); t3.item = res.getMachinePerformanceData().get(i).getNetworkAdapterPerformanceData().get(k).getAdapterName(); t3.data = new ArrayList<TransactionLogTimeStampStruct>(); t3.data.add(t2);
public static MachinePolicy ProcessMachineLevelSLAs(AddMachineAndProcessDataRequestMsg req, boolean pooled) { MachinePolicy mp = loadMachinePolicyPooled(req.getHostname()); AuxHelper.TryUpdateStatus(req.getMachineData().isOperationalstatus(), req.getMachineData().getUri(), req.getMachineData().getStatusmessage(), pooled, PolicyType.MACHINE, req.getDomainname(), req.getHostname()); processMachineSLAs(req, mp, pooled); return mp; }
@Override public boolean CheckTransactionalRule(MachinePerformanceData req, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg) { if (nullableFaultMsg == null) { nullableFaultMsg = new AtomicReference<String>(); } NameValuePair partition = Utility.getNameValuePairByName(params, "partition"); NameValuePair value = Utility.getNameValuePairByName(params, "value"); long val = 0; String part = partition.getValue(); if (partition.isEncrypted()) { part = Utility.DE(partition.getValue()); } if (value.isEncrypted()) { val = Long.parseLong(Utility.DE(value.getValue())); } else { val = Long.parseLong((value.getValue())); } for (int i = 0; i < req.getDriveInformation().size(); i++) { if (req.getDriveInformation().get(i).getPartition().equalsIgnoreCase(part)) { if (req.getDriveInformation().get(i).getFreespace() < val) { nullableFaultMsg.set("The partion's freespace, " + req.getDriveInformation().get(i).getFreespace() + " is less than the threshold of " + val + ". " + nullableFaultMsg.get()); } return true; } } return false; }
@Override public boolean CheckTransactionalRule(MachinePerformanceData req, List<NameValuePair> params, AtomicReference<String> nullableFaultMsg) { if (nullableFaultMsg == null) { nullableFaultMsg = new AtomicReference<String>(); } if (req.getPercentusedCPU() == null) { return false; } NameValuePair GetNameValuePairByName = Utility.getNameValuePairByName(params, "value"); long rate = -1; if (GetNameValuePairByName.isEncrypted()) { rate = Long.parseLong(Utility.DE(GetNameValuePairByName.getValue())); } else { rate = Long.parseLong(GetNameValuePairByName.getValue()); } long faultrate = req.getPercentusedCPU().longValue(); if (faultrate < rate) { nullableFaultMsg.set("The measured CPU Usage of " + faultrate + " is higher than " + rate + ", " + nullableFaultMsg.get()); return true; } return false; }
/** * Create an instance of {@link MachinePerformanceData } * */ public MachinePerformanceData createMachinePerformanceData() { return new MachinePerformanceData(); }
for (int i = 0; i < res.getMachinePerformanceData().size(); i++) { for (int k = 0; k < res.getMachinePerformanceData().get(i).getDriveInformation().size(); k++) { TransactionLogTimeStampStruct t2 = new TransactionLogTimeStampStruct(); t2.ResponseTime = res.getMachinePerformanceData().get(i).getDriveInformation().get(k).getKilobytespersecondDiskRead(); t2.cal = res.getMachinePerformanceData().get(i).getTimestamp(); if (dataRX.Contains(res.getMachinePerformanceData().get(i).getDriveInformation().get(k).getPartition())) { dataRX.get(res.getMachinePerformanceData().get(i).getDriveInformation().get(k).getPartition()).add(t2); } else { RateStruct t3 = new RateStruct(); t3.item = res.getMachinePerformanceData().get(i).getDriveInformation().get(k).getPartition(); t3.data = new ArrayList<TransactionLogTimeStampStruct>(); t3.data.add(t2); t2.ResponseTime = res.getMachinePerformanceData().get(i).getDriveInformation().get(k).getKilobytespersecondDiskWrite(); t2.cal = res.getMachinePerformanceData().get(i).getTimestamp(); if (dataTX.Contains(res.getMachinePerformanceData().get(i).getDriveInformation().get(k).getPartition())) { dataTX.get(res.getMachinePerformanceData().get(i).getDriveInformation().get(k).getPartition()).add(t2); } else { RateStruct t3 = new RateStruct(); t3.item = res.getMachinePerformanceData().get(i).getDriveInformation().get(k).getPartition(); t3.data = new ArrayList<TransactionLogTimeStampStruct>(); t3.data.add(t2);
rs = com.executeQuery(); while (rs.next()) { p = new MachinePerformanceData(); p.setUri(uri); p.setBytesusedMemory(rs.getLong("memoryused")); p.setId(rs.getString("id")); p.setPercentusedCPU(rs.getDouble("percentCPU")); p.setNumberofActiveThreads(rs.getLong("threads")); StatusHelper h = getStatus(uri); p.setStatusmessage(h.msg); p.setTimestamp((gcal)); Long l = rs.getLong("startedat"); if (l != null) { gcal = new GregorianCalendar(); gcal.setTimeInMillis(l); p.setStartedAt((gcal)); p.getDriveInformation().addAll(this.getDriveLogsByRange(TranslateURItoPair.hostname, TranslateURItoPair.domainname, rs.getLong("utcdatetime"))); p.getNetworkAdapterPerformanceData().addAll(this.getNICLogsByRange(TranslateURItoPair.hostname, TranslateURItoPair.domainname, rs.getLong("utcdatetime"))); ret.getMachinePerformanceData().add(p);