osvaldog

My js doesn't show metrics

Discussion created by osvaldog on Jan 15, 2018
Latest reply on Jan 15, 2018 by Hiko_Davis

And I don't know why perhaps you be able to help me.

I want to add a new metric, I have this structure

 

 

And I need to add a % metric calculating between Max Size and Current Size

 

This is my code

 

function execute(metricData,javascriptResultSetHelper) {

var total;
var usado;
var frequency = Packages.com.wily.introscope.spec.metric.Frequency.getFrequencyInSeconds(15);
var agent;
var metric;
var nombreMetrica="";
var rawvalue =0;

for(i=0; i < metricData.length; i++) {

metric = metricData[i].agentMetric.attributeURL;
agent = metricData[i].agentName.processURL;
rawvalue = metricData[i].timeslicedValue.value;
frequency = metricData[i].frequency;
var isAbsent = metricData[i].timeslicedValue.dataIsAbsent();

if (metric.indexOf("Current")> -1) {
usado = rawvalue;
}
if (metric.indexOf("Max")> -1){
total = rawvalue;
}



}

var result= (usado / total) * 100;
var valorRta = Math.round(result);
var metrica1=agent + "|WebMethods|Adapter Connection Pools|DS_BPM1:Porcentaje Uso %";
javascriptResultSetHelper.addMetric
(metrica1,valorRta,Packages.com.wily.introscope.spec.metric.MetricTypes.kLongFluctuatingCounter,frequency );

 

// return the result set
return javascriptResultSetHelper;
}

function getAgentRegex() {
return "(.*)\|BPM\-IS\-DEV\-v97\|IntegrationServerAgent\|";


}
function getMetricRegex() {
return "WebMethods\|Adapter Connection Pools\|DS_BPM1:(.*)";


}

// must return a multiple of default system frequency (currently 15 seconds)
function getFrequency() {
return 1 * Packages.com.wily.introscope.spec.metric.Frequency.kDefaultSystemFrequencyInSeconds;
}

//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;
}

 

It doesn't make errors but don't show metrics too. Actually metricData.length = 0. Do you see some error or mistake in this code?

 

Thanks!

Outcomes