DX Application Performance Management

Expand all | Collapse all

How to calculate introscope apm agent alive time

Jump to Best Answer
  • 1.  How to calculate introscope apm agent alive time

    Posted 01-29-2018 01:49 PM

    In the investigator tree i have the next metric

    • *SuperDomain*|plnxwas200|JBoss6.4|OSAdminTurnos:Launch Time

    I want to calculate using custom script the time elapsed to the current time in hours and print the result in another metric like "Alive Time"

     

    Launch Time seem date format

     

    Someone have an scripts that achieve it?

     

    Thanks,

    Richard



  • 2.  Re: How to calculate introscope apm agent alive time

    Posted 01-29-2018 02:28 PM

    Dear Team:

    Can someone particularly Richard's fellow CA Admins and partners help out?

    Thanks



  • 3.  Re: How to calculate introscope apm agent alive time

    Posted 01-30-2018 07:39 AM

    Since this is asking for a custom script making into a discussion. Can someone provide Richard some script examples or guidance?

    Thanks in advance

    Hal German



  • 4.  Re: How to calculate introscope apm agent alive time
    Best Answer

    Posted 01-31-2018 03:17 PM

    Hi Richard.

     

    In the examples directory under an enterprise manager home there is an example script called "HeapUsedPercentage.js", use this as your base frame for your script.

     

    This script is only a hundred lines with comments and blank lines, but from there you can get the method signatures and the four important methods:

       function execute(metricData,javascriptResultSetHelper)  - in this, you are going to replace the guts and reuse the addMetric function from the javascriptResultSetHelper.

       function getAgentRegex() 

       function getMetricRegex() 

       function runOnMOM() 

     

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

     

    On the expressions, you have to escape character out the \ so ...

    return "Queue Managers(.*)\\|Queues\\|GRAVEYARD\\|Status:Current Queue Depth";

     

    Use JavaScript Calculators - CA Application Performance Management - 10.0 - CA Technologies Documentation 

     

    Then you will need to figure out how to get the current time/date and do some math within JavaScript.  I would suggest doing a Google search for "date functions in javascript" 

     

    Hope this helps,

     

    Billy



  • 5.  Re: How to calculate introscope apm agent alive time

    Posted 03-12-2018 09:59 PM

    Hi Billy:

     

    Thank you for the sample, was very useful

    Can create a graph metric with live time in hours!

    Share here the execute function final look..

     

    function execute(metricData,javascriptResultSetHelper)
    {

    // for each input agent, compute a calculated metric named
    // "<metric>|<agentname>:Live Time (hours)" as
    // that agent's "Math.floor(diffInMilliseconds / 1000 / 60 / 60)".


    var i=0; // binding iterator
    var agentList = {}; // list of agents
    var agentLaunchTime = {}; // array of Launch Time values by agent
    var agentCurrentTime = {}; // array of Current Time values by agent
    var agentFrequency = {}; // array of frequency by agent
    var nowInMilliseconds = Math.floor(Date.now());

    for(i=0; i < metricData.length; i++)
    {
    var metric = metricData[i].agentMetric.attributeURL;
    var agent = metricData[i].agentName.processURL;
    var launchTime = 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 Launch Time in the right array
    var launchTimeInMilliseconds = new Date(launchTime);
    agentLaunchTime[agent] = launchTimeInMilliseconds;
    agentCurrentTime[agent] = nowInMilliseconds;
    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 + "|Live Time (hours)";
    var frequency = agentFrequency[agent];

    // perform the math
    var diffInMilliseconds = agentCurrentTime[agent] - agentLaunchTime[agent];
    var diffInHours = Math.floor(diffInMilliseconds / 1000 / 60 / 60);
    var liveTimeHours = Math.round(diffInHours);

    // add the calculated live time to the result set
    javascriptResultSetHelper.addMetric(metricName,
    liveTimeHours,
    javascriptResultSetHelper.kIntegerPercentage,
    frequency);

    }

    // return the result set
    return javascriptResultSetHelper;

    }