Derived Metric Help

Hello,

     I am trying to setup a derived metric.  We have several LPAR's ad the Unix team likes to look at CPU usage in number of CPU's used not in % Utilization.  My thought is to take the virtualCPUs count from the CPUCounts and the Utilization from the HostCPUs.  Multiply these together and I should get the number of CPU's currently in use. so for example

CPUCounts.virtualCPUs = 4

HostCPUs.utilization = 50%

sum( 4 * 50%) = 2

Current CPU's in use is 2.

However I am not able to get the syntax correct for hte derived metric.  Any help would be greatly appreciated.  And if there is a better way to do this then I am up for that as well.

Thanks

     Matt

  • Hi Matt,

    Are you using the Infrastructure UnixAgent to monitor the OS of these AIX LPAR's?

    If so, I can find no references to "CPUCounts.virtualCPUs" in the common Host model.

    If you are using the UnixAgent, you should have metrics for the utilization of each CPU.

    If that's available, a more accurate indicator of the current CPUs in use is to count all the processors where the processor utilization is greater than 0% (or appropriate threshold).

    Does that make sense?

    Regards,

    Brian Wheeldon

  • I am using the IC Agent.  I can see the virtualCPU count if I look CPUCounts in the script console.

    cpucount.png

  • Thank you!

    I learn something new about Foglight every day and this is one of today's lessons.

    A Host's HostCPUs object has a CPUCounts object in the "details" field, if populated from an Infrastructure (and possibly other) agent.

    Your derived metric could use something like the following:

    // scope is an instance of  HostCPUs

    cpuCounts = #!CPUCounts: cpus=$scope#.topologyObjects

    cpuCount=cpuCounts.iterator().next()

    //logical = cpuCount.logicalCPUs

    //physical = cpuCount.physicalCPUs

    virtual = cpuCount.virtualCPUs

    Regards,

    Brian Wheeldon

  • Hey Brian,

         I apoligize for needing it spelled out ......But I tried to setup a derived metric with CPUCounts as the topology type.  And Pasted in the above as the expression and I get an error when i try to execute it.  Also I dont see anything about the CPU Utilization in the expression above?

  • Hi Matt,

    The snippet above is designed for use where the scope is HostCPUs.

    In the context of that scope, the current CPU utilization is simply:

    #utilization#

    As I mentioned, I think it's better to use the processor utilization metrics to derive the "current CPUs in use", but you can use (HostCPUs.CPUCounts.virtualCPUs x HostCPUs.utilization) if you wish.

    Regards,

    Brian Wheeldon

  • try this:

    cpuCount = scope?.cpus?.processors?.size()

    utilization = (#utilization from HostCPUs where host = $scope#)?.div(100)

    inUse = cpuCount * utilization

  • Ok,

    When I try Brian's code I get the correct CPU count for the host but im unsure how to modify it to get from there to the used count.

    John,

         When I try your code I get the following .....with HostCPUs set as the topology type

    com.quest.nitro.service.sl.interfaces.scripting.ScriptingException: com.quest.nitro.service.sl.interfaces.scripting.ScriptAbortException: java.lang.IllegalArgumentException: Type 'foglight-5:HostCPUs:6' does not have a property with the name 'cpus' ----script start------ cpuCount = scope?.cpus?.processors?.size() utilization = #utilization from HostCPUs where host = $scope# inUse = cpuCount * utilization ---- script end ------

  • The code I sent was based on using the Host as the scope.  If you want to use the HostCPUs as the scope, change the code to this:

    cpuCount = scope?.processors?.size()

    utilization = (#utilization#)?.div(100)

    inUse = cpuCount * utilization

    Forgot to adjust the above for the /100, to get the ratio correct

  • That seemed to work!!!   I get 0.9505732655405951  ....is there any way to truncate it to to 2 digits after the decimal  so 0.95?

    Thanks everyone for the help.

  • cpuCount = scope?.processors?.size()

    utilization = (#utilization#)?.div(100)

    inUse = (cpuCount * utilization)?.round(2)