Archived community.zenoss.org | full text search
Skip navigation
24928 Views 2 Replies Latest reply: Jan 20, 2010 5:09 AM by chintak110 RSS
chintak110 Rank: White Belt 8 posts since
Sep 16, 2009
Currently Being Moderated

Jan 19, 2010 5:45 AM

accessing RRD values in object files

Hi ,

 

I have a requirement to show the RRD values in an object file. I was able to access the RRD values  from object file using "cacheRRDValue" method. But the problem is the values in RRD file are not the exact values that my snmp agent returned.

 

I used the following command to create an RRD file

 

RRA:AVERAGE:0.5:1:600

RRA:AVERAGE:0.5:6:600

RRA:AVERAGE:0.5:24:600

RRA:AVERAGE:0.5:288:600

RRA:MAX:0.5:6:600

RRA:MAX:0.5:24:600

RRA:MAX:0.5:288:600

 

When there is a time dealy of 30 or 40 seconds in collecting the perfromance data, RRD is averaging the value and storing the modified new value in a RRA. But still I could see the last collected value in RRD file. ( I used rrdtool dump command to see the content in the file ).

 

<!-- Round Robin Database Dump --><rrd> <version> 0003 </version>
        <step> 300 </step> <!-- Seconds -->
        <lastupdate> 920809800 </lastupdate> <!-- 1999-03-07 07:30:00 EST -->

        <ds>
                <name> speed </name>
                <type> GAUGE </type>
                <minimal_heartbeat> 600 </minimal_heartbeat>
                <min> NaN </min>
                <max> NaN </max>

                <!-- PDP Status -->
                <last_ds> 1850 </last_ds>
                <value> 0.0000000000e+00 </value>
                <unknown_sec> 0 </unknown_sec>
        </ds>

-----

 

<last_ds> 1850 <last_ds> is the value that I am looking to display in an object file. Is there any api that can return the <last_ds> value? or is there a way to create an RRD file in which there won't be any calculations and store exact values that an snmp agent returns?

 

I spent around 3 days to find a solution for this but could not find any clues. I have gone through the RRDView.py but could not find any api to access the last datasource value.

 

Thanks in advance.

  • j053ph4 Rank: Green Belt 290 posts since
    Dec 19, 2008
    Currently Being Moderated
    1. Jan 19, 2010 11:16 AM (in response to chintak110)
    Re: accessing RRD values in object files

    I've been using something like the following with some success:

     

    #!/usr/bin/env python
    from __future__ import division
    import os,sys
    import re
    import time
    import math
    import Globals
    from Products.ZenUtils.ZenScriptBase import ZenScriptBase

     

    # device name in Zenoss
    devicename = "localhost"
    # stand-in for metrics
    metric = 'laLoadInt5'
    # polling interval in seconds
    interval = 300
    # sample period in seconds
    period = 86400
    # first determine current time in epoch
    now = int(time.time())
    # subtract 24 hours from current time in epoch
    yesterday = now - period
    samples = int(period/interval)

     

    # array to hold today's data
    todaysData=[]

     

    # find the device
    dmd = ZenScriptBase(connect=True).dmd
    devices = dmd.Devices.getSubDevices()

     

    for device in devices:
        print device.id
        if str(device.id) == devicename:
            print "found",device.id
            rrdsource = device

     

    # for each interval in the day, pull the RRD data

     

    alpha = yesterday
    while samples > 0 :
        omega = alpha + interval
        value = rrdsource.getRRDValue(metric, start=alpha, end=omega, function="LAST")
        todaysData.append(value)
        alpha = yesterday + interval
        samples = samples - 1
       
       
    print "samples:",len(todaysData)

     

    for data in todaysData:
        print data

More Like This

  • Retrieving data ...

Legend

  • Correct Answers - 4 points
  • Helpful Answers - 2 points