demonic.cc
  • About
  • 08/21/2009 (2:31 pm)

    Adding DataPoints to Performance Reports in Zenoss

    Filed under: Zenoss ::

    If you navigate to Reports -> Performance Reports and run the CPU Utilization report, or Memory Utilization report (for example), you may notice that there is limited/no data for devices which you have developed custom templates for.

    You can modify report plugins to use datapoints from your templates.

    Examples:

    I have device templates that I created to monitor performance on certain devices.  The values were not represented in the report, and instead I was simply seeing “N/A” for all values of these devices.

    • One is a template to monitor Windows devices via SNMP where the percentage of CPU in use is represented by the datapoint “Total” and the percentage of memory in use is represented by the datapoint “PercentMemoryUsed”.
    • Another template is a template to monitor Cisco routers and switches where the CPU usage is represented by a datapoint called “cpu5min” and memory usage is represented by datapoints called “mem5minFree” and “mem5minUsed”.

    CPU:

    I edited $ZENHOME/Products/ZenReports/plugins/cpu.py

    After lines:

    if cpuPercent is None:
        cpuPercent = d.getRRDValue('cpuPercentProcessorTime', **summary)

    I added:

    # This retrieves the percentage of CPU usage for the report.
    if cpuPercent is None:
        cpuPercent = d.getRRDValue('cpu5min', **summary)
    # This retrieves the percentage of CPU usage for the report.
    if cpuPercent is None:
        cpuPercent = d.getRRDValue('Total', **summary)

    Memory:

    I edited $ZENHOME/Products/ZenReports/plugins/memory.py

    After lines:

    percentUsed = None
    if totalReal and free:
        percentUsed = Utils.percent(totalReal - free, totalReal)

    I added:

    # This retrieves the percentage of memory usage for the report.
    if percentUsed is None:
        percentUsed = d.getRRDValue('PercentMemoryUsed', **summary)
    # This retrieves and calculates the percentage of memory
    # used from the amount of free and used memory.
    if percentUsed is None:
        CiscoMemFree = d.getRRDValue('mem5minFree', **summary)
        CiscoMemUsed = d.getRRDValue('mem5minUsed', **summary)
        if CiscoMemFree and CiscoMemUsed:
            percentUsed = round((CiscoMemUsed/(CiscoMemUsed + CiscoMemFree))*100.0)

    After any modification is made to a report plugin you should restart Zope by executing “zopectl restart” as the zenoss user.  In some rare cases restarting Zope can cause Zenoss to stop responding.  If this happens simply restart Zenoss by executing “zenoss stop”, wait a few seconds, then “zenoss start”.

    3 Responses to “Adding DataPoints to Performance Reports in Zenoss”

    1. mray Says:

      I’m a little unclear why this is used instead of Data Point Aliasing, introduced in Zenoss 2.4?
      http://www.zenoss.com/community/docs/zenoss-guide/2.4.2/ch06s02.html#d4e2721

      Or am I missing something?

      Matt Ray
      Zenoss Community Manager

    2. rmatte Says:

      I wasn’t aware of the aliases option. I read through the link you included, and the only report that apparently even supports aliases at the moment is the CPU report (according to the docs). I’d imagine they could be used for other reports as well though (testing would have to be done to determine this).

    3. mray Says:

      I talked to the developers and they said that the proper aliases are in Subversion trunk for the rest of the reports in King Crab. So while this is useful stuff now, hopefully in a few months you won’t have to hack on any more reports.

      -Matt

    Leave a Reply

    You must be logged in to post a comment.