DX Application Performance Management

Expand all | Collapse all

suMetric supposed to be in Percent becomes in Megabyte?

  • 1.  suMetric supposed to be in Percent becomes in Megabyte?

    Posted 09-26-2014 02:05 AM
      |   view attached

    Hi All CA Experts,

     

    Good day!

     

    How can remediate on the websphere agent metric ( Process Proportion Load(%)) that the value become megabytes?

    It is supposed to be in Percentage but it outputs a Megabyte measure.

     

    I dont have any clue on how can i solve this but with your help, i know i can fix this.

    You can look at the attached file for your reference.

     

    Thanks in Advance

     

    Arwin.

    Attachment(s)

    docx
    ReferenceDoc.docx   149K 1 version


  • 2.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 09-26-2014 02:26 AM

    Hi Arwin,

     

    As the metric "Process Load Proportion (%)" is a calculated metric from the CPUAverage.js javascript calculators (running on the Collectors), can you please attach a screenshot of the values for "CPU:Host Average CPU (%)", "CPU:Utilization % (process)", and "Processor Count"? of the same timeframe?

     

    Thanks and regards,

    Stefan



  • 3.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 09-26-2014 02:31 AM
      |   view attached

    Hi Stefan,

     

    Please see attahced file, They have the same reading.

     

    Thanks,

    Arwin

    Attachment(s)

    docx
    ReferenceDoc2.docx   265K 1 version


  • 4.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 09-26-2014 02:33 AM
      |   view attached

    Hi Stefan,

     

    Attaching the file with the CPU Utilization (%) Process.

     

    Thanks,

    Arwin

    Attachment(s)

    docx
    ReferenceDoc2.docx   423K 1 version


  • 5.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 09-26-2014 03:31 AM

    Hi Arwin,

     

    Thanks for the docs. Seems like this is happening in case there is no utilization on your CPUs. I've checked the JavaScript calculator and found a place where a division by zero might not be handled.

    In case you have a test environment, can you please try to make the following change and check if it solves the problem:

     

    Change line 71 from CPUAverage.js script from:

     

                            var processVal = Math.round((agentProcessCPU[agent]/averageCPU)*100);

     

    to:

     

                var processVal = 0;

                if (averageCPU > 0) {

                    processVal = Math.round((agentProcessCPU[agent]/averageCPU)*100);

                }

     

    In case the agentSystemLoad is zero (sum of all 4 core aggregate values is zero), then the averageCPU gets zero, too. In this case you'll do a division by zero in the calculation (NaN) and might therefore see this extremely high metric numbers as a faulty result.

     

    You would need to test this JS on your Collectors in a test env, a restart is not required as JavaScripts are hot-deploy (60 sec. polling interval). Please backup the original script so you can revert easily in case of problems.

     

    Regards,

    Stefan



  • 6.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 09-26-2014 03:50 AM

    Hi Stefan,

     

     

    Good day!

     

    I will try this one but i need to have the confirmation of my Manager to do this.

    By the way where can i find that script?

     

    Thanks,

    Arwin



  • 7.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 09-26-2014 04:08 AM

    Hi Arwin,

     

    The script (CPUAverage.js) can be found in <EM-Home>/examples/scripts by default and for deployment it needs to be copied to <EM-Home>/scripts.

     

    Cheers

    Stefan



  • 8.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 09-26-2014 04:39 AM


    This is what i found in my lower environment CPUAverage,js

     

    var processVal = 0;

        if(averageCPU > 0 && averageCPU >= agentProcessCPU[agent]) {

         processVal = Math.round((agentProcessCPU[agent]/averageCPU)*100);

        }

     

     

    Should i go ahead and make the change in my production?



  • 9.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 09-26-2014 05:04 AM

    Hi Stefan,

     

    How is that possible? the other agent with a same metrics displays data as percent(%) but the other one is Megabytes? i have same configuration of CPUAverage.js in the scripts folder?

    Is there something wrong on the EM? or in the server itself where the agent is installed?

     

    Thanks,

    Arwin



  • 10.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 09-26-2014 05:15 AM

    Hi Arwin,

     

    Can you please share your JavaScript? What is your EM version?

    The calculation itself is being done on the EMs only.

     

    Regards,

    Stefan



  • 11.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 09-26-2014 05:19 AM

    Hi Stefan,

     

    We are using Introscope Version 9.5.

     

    Below are the CPUAverage.js.

     

    // 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
        var agentList = {};    // list of agents we touch
        var agentProcessCPU = {};   // how much cpu is used by the process by agent
        var agentSystemLoad = {};   // how much cpu is used by the host (cumulative, all cpus)
        var agentNumProcessors = {}; // number of cpus (needed for averaging)
        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;

            // if we haven't seen this agent yet add it to the list of known agents
            if (agentList[agent] == null)
            {
                agentList[agent] = agent;
            }
     
        // prep arrays for this agent, if necessary
        if (agentSystemLoad[agent] == null)
        {
       agentSystemLoad[agent] = 0;
       agentNumProcessors[agent] = 0;
       agentProcessCPU[agent] = 0;
      }
      
        // stick the value in the right array -- if this is a CPU metric rather than the process metric,
      // increase the CPU count for the host as well.
            if (metric == "CPU:Utilization % (process)")
            {
                agentProcessCPU[agent] =  value;
            }
            else
            {
                if (metric.indexOf("aggregate") > 0)
                {
           agentSystemLoad[agent] +=  value;
        agentNumProcessors[agent] += 1;
          }
            }
            agentFrequency[agent] =  frequency;
        }
       
        // now iterate found agents and report calculated metrics
        for (var agent in agentList) {
       
            var averageCPUMetricName = agent + "|CPU:Host Average CPU (%)";
      var processMetricName = agent + "|CPU:Process Load Proportion (%)";
            var frequency = agentFrequency[agent];


      // report a metric if we were aren't going to divide by zero
            if (agentNumProcessors[agent] > 0)
            {
             var averageCPU = Math.round(agentSystemLoad[agent] / agentNumProcessors[agent]);

          // add the calculated value to the result set
        javascriptResultSetHelper.addMetric(averageCPUMetricName,
         averageCPU,
        javascriptResultSetHelper.kIntegerPercentage,
         javascriptResultSetHelper.kDefaultFrequency)

       var processVal = Math.round((agentProcessCPU[agent]/averageCPU)*100);

        javascriptResultSetHelper.addMetric(processMetricName,
         processVal,
        // the result type
        javascriptResultSetHelper.kIntegerPercentage,
         javascriptResultSetHelper.kDefaultFrequency)
      }
        }
       
        // return the result set
        return javascriptResultSetHelper;
    }

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

    // The the EM what metrics we should match against
    function getMetricRegex()
    {
        return "CPU.*";
    }

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



  • 12.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 09-27-2014 02:23 AM

    Hi Arwin,

     

    Thanks for attaching your script - this is the default (OOTB) JavaScript.

     

    The snippet you've posted from your lower environment is doing the same check as the snipped I proposed to insert. This is checking the condition if the averageCPU metric that was calculated is greater than zero. If not, strange things can happen like the million-metrics (random numbers!) you've seen but only in case the input metrics go to zero, too. I've checked this with your screenshots provided and you can see that in the specific timeframes with crazy numbers there are input values equal to zero.

     

    So what to do now:

    You can either insert your snippet or my snippet in your final script - they should act the same as they set a default value for processVal of zero in case the input metrics are zero, too and don't try to do any math on the zero numbers.

    If I understood correctly, you already have a "fixed" version in your lower environment where I expect everything to run fine, right? So you should adopt this change to production. Please remind I can just try to help on a community base, this is not an official CA recommendation and there is no responsibility in case it doesn't work. Nevertheless in case it doesn't solve the situation, you can easily revert to the state before by getting back to the old, current, OOTB javascript calculator.

    So finally, your script should look like that:

     

     

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

        var agentList = {}; // list of agents we touch

        var agentProcessCPU = {}; // how much cpu is used by the process by agent

        var agentSystemLoad = {}; // how much cpu is used by the host (cumulative, all cpus)

        var agentNumProcessors = {}; // number of cpus (needed for averaging)

        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;

     

            // if we haven't seen this agent yet add it to the list of known agents

            if (agentList[agent] == null)

            {

                agentList[agent] = agent;

            }

     

        // prep arrays for this agent, if necessary

        if (agentSystemLoad[agent] == null)

        {

      agentSystemLoad[agent] = 0;

      agentNumProcessors[agent] = 0;

      agentProcessCPU[agent] = 0;

      }

      

        // stick the value in the right array -- if this is a CPU metric rather than the process metric,

      // increase the CPU count for the host as well.

            if (metric == "CPU:Utilization % (process)")

            {

                agentProcessCPU[agent] =  value;

            }

            else

            {

                if (metric.indexOf("aggregate") > 0)

                {

          agentSystemLoad[agent] +=  value;

      agentNumProcessors[agent] += 1;

          }

            }

            agentFrequency[agent] =  frequency;

        }

       

        // now iterate found agents and report calculated metrics

        for (var agent in agentList) {

       

            var averageCPUMetricName = agent + "|CPU:Host Average CPU (%)";

      var processMetricName = agent + "|CPU:Process Load Proportion (%)";

            var frequency = agentFrequency[agent];

     

     

      // report a metric if we were aren't going to divide by zero

            if (agentNumProcessors[agent] > 0)

            {

              var averageCPU = Math.round(agentSystemLoad[agent] / agentNumProcessors[agent]);

     

          // add the calculated value to the result set

      javascriptResultSetHelper.addMetric(averageCPUMetricName,

      averageCPU,

      javascriptResultSetHelper.kIntegerPercentage,

      javascriptResultSetHelper.kDefaultFrequency)

     

                var processVal = 0;

                if (averageCPU > 0) {

                    processVal = Math.round((agentProcessCPU[agent]/averageCPU)*100);

                }

               

     

      javascriptResultSetHelper.addMetric(processMetricName,

      processVal,

      // the result type

      javascriptResultSetHelper.kIntegerPercentage,

      javascriptResultSetHelper.kDefaultFrequency)

      }

        }

       

        // return the result set

        return javascriptResultSetHelper;

    }

     

    // Tell the EM what Agents we should match against

    function getAgentRegex()

    {

        return ".*";

    }

     

    // The the EM what metrics we should match against

    function getMetricRegex()

    {

        return "CPU.*";

    }

     

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

    }

     

     

    Cheers

    Stefan



  • 13.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 09-29-2014 04:21 AM

    Hi Stefan,

     

    It is so strange, i just change the codes with the codes you ve modified and still the metrics value for the same agent is still in Gigabyte/Megabyte

    Thanks,

    Arwin



  • 14.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 09-29-2014 05:14 AM

    Hi Stefan,

     

    I just deploy the same CPUAverage.js same as Development but still i got that Megabyte measurement if i get back to get a historical data.

     

    Please advice whats goin on in here.

     

    Thanks,

    Arwin



  • 15.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 09-29-2014 05:19 AM

    Shall i restart the service if i do that?



  • 16.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 10-13-2014 03:49 AM

    Hi Arwin,

     

    Sorry for late reply, I've just been back from vacation.

    You do not need to restart the service after updating the script, this is hot deploy.

     

    The new script calculates new values only, historical metrics are (never!) being updated.

    After applying the fix, did you see new calculations still being high or did the strange behavior stop?

     

    Regards,

    Stefan



  • 17.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 10-13-2014 05:09 AM


    Hi Stefan,

     

    Same metrics was calculated. Still have the Megabytes reading 

     

    Thanks,

    Arwin



  • 18.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 10-13-2014 11:06 AM
      |   view attached

    Hi Stefan,

     

    Now the problem is, when i go on an have a  30 days metrics data. its says that the process load proportion in Megabytes and not in Percentage.


    Please see attached file for your reference, it seems like everything goes weird in this part.

    Your immiate response is highly appreciated.

     

    Thanks,

    Arwin

    Attachment(s)

    docx
    MetricsMB.docx   157K 1 version


  • 19.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 10-13-2014 11:11 AM

    Hi Arwin,

     

    From the attached picture it looks to me like there was no high value calculated since 29th/30th September, correct?

     

    A Javascript calculator creates a calculated metric every 15 second (like an Agent does) and saves it to the SmartStor. That's why the historical metrics (when you query 30 days) come from the saved SmartStor data - for both metrics and calculated metrics. So you won't get rid of the high numbers in the past but hopefully just get valid values since the change and in the future.

     

    Can you please check and maybe confirm that the problem of high Process Load Proportion metrics did not happen since your change that was assumably around 30th of September?

     

    Regards,

    Stefan



  • 20.  Re: suMetric supposed to be in Percent becomes in Megabyte?

    Posted 10-13-2014 11:20 AM

    Hi Stefan,

     

     

    Everythings seems to be fine in a time range of 60 hours.but when i go ahead and make it 7 day, that will make all measurement as Megabyte.

     

    Thanks,

    Arwin