// Sample Javascript code for Wily Introscope // // Compute the HOST CPU Load and percentage of Load that attributable to the process // function execute(metricData,javascriptResultSetHelper) { var i=0; // binding iterator for(i=0; i < metricData.length; i++) { var metric = metricData[i].agentMetric.attributeURL; var agent = metricData[i].agentName.processURL; var value = metricData[i].timeslicedValue.getValueAsString(); var frequency = metricData[i].frequency; if(!endsWith(metric+"","value")){ var processMetricName = agent + "|"+metric+"Value"; var numValue=0; if(value == "down") numValue = new java.lang.Integer(0); if(value == "up") numValue = new java.lang.Integer(1); javascriptResultSetHelper.addMetric(processMetricName, numValue, javascriptResultSetHelper.kIntegerFluctuatingCounter, javascriptResultSetHelper.kDefaultFrequency) } } // return the result set return javascriptResultSetHelper; } function endsWith(str, suffix) { return str.indexOf(suffix, str.length - suffix.length) !== -1; } // Tell the EM what Agents we should match against function getAgentRegex() { return "(.*)\|DatapowerMonitor\|DatapowerMonitor Agent"; } // The the EM what metrics we should match against function getMetricRegex() { return "(.*):Op State"; } // Return false if the script should not run on the MOM. // Scripts that create metrics on agents other than the Custom Metric Agent // should not run on the MOM because the agents exist only in the Collectors. // Default is true. //function runOnMOM() //{ // return false; //}