AnsweredAssumed Answered

EM Heap Used Percent

Question asked by mukesh_singh Employee on Dec 9, 2016
Latest reply on Dec 9, 2016 by mukesh_singh

Hi All,

 

I am trying to modify "HeapUsedPercentage.js" calculator in order to get heap utilization percentage of collectors and MOM in APM cluster but it is not working even though there are no exceptions in logs.

 

Really appreciate if anyone has already done it and can guide me where I am doing wrong. Below are the script content:

 

 

// Sample Javascript code for Wily Introscope
//
// Compute the Heap Used % metric based on the Heap Total and Heap In Use metrics
//
function execute(metricData,javascriptResultSetHelper)
{

// for each input agent, compute a calculated metric named
// "<metric>|<agentname>:Heap Used %" as
// that agent's "Math.round(Bytes in Use / Bytes Total *100)".


var i=0; // binding iterator
var agentList = {}; // list of agents
var agentBytesTotal = {}; // array of bytesTotal values by agent
var agentBytesUsed = {}; // array of bytesUsed values by agent
var agentFrequency = {}; // array of frequency by agent

for(i=0; i < metricData.length; i++)
{
var metric = metricData[i].agentMetric.attributeURL;
var agent = metricData[i].agentName.processURL;
var value = metricData[i].timeslicedValue.value;
var frequency = metricData[i].frequency;

// add to agentList if we haven't seen the agent yet
if (agentList[agent] == null)
{
agentList[agent] = agent;
}

// put the value in the right array
if (metric == "Enterprise Manager|GC Heap:Total (mb)")
{
agentBytesTotal[agent] = value;
}
else if (metric == "Enterprise Manager|GC Heap:In Use (mb)")
{
agentBytesUsed[agent] = value;
}

agentFrequency[agent] = frequency;
}


// now iterate found agents and report calculated metrics, build array of metrics
for (var agent in agentList)
{
// set up metric name
var metricName = agent + "|Enterprise Manager|GC Heap:Heap Used (%)";
var frequency = agentFrequency[agent];

// make sure we're not going to divide by zero
if (agentBytesTotal[agent] > 0)
{
// perform the math
var heapUsedValue = Math.round((agentBytesUsed[agent]/agentBytesTotal[agent])*100);

// add the calculated value to the result set
javascriptResultSetHelper.addMetric(metricName,
heapUsedValue,
javascriptResultSetHelper.kIntegerPercentage,
frequency);
}

}

// return the result set
return javascriptResultSetHelper;

}

// Tell the EM what agents we should match against
function getAgentRegex()
{
return "Custom(.*)";
}

// Tell the EM what agent metrics we should match against
function getMetricRegex()
{
return "Enterprise Manager|GC Heap.*";
}

// must return a multiple of default system frequency (currently 15 seconds)
function getFrequency()
{
return 15;
}

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

 

 

 

Regards,

Mukesh Singh

Attachments

Outcomes