Hi!
I ran into a problem - monitoring exact value, for example, number of voip
calls. I tried to monitor it by using "gauge" datapoint type, but instead of
round numbers (ie. 10, 20) i got float numbers which doesn't match probed
values (ie. 15.4 13.4).
After little investigation why is this happening, i found out that this is
because of the way RRD is storing values. RRD database is aligned on full
hour, and if step is 300sec, RRD generate range of time which begins in full
hour (10:00 ie), and then every 5 min (10:05 10:10).
RRD database is never updated in exact time (ie. 10:05), instead it is
somewhere in between two neighboring values. In this case, rrd database
_aproximates_ what walue was in exact time (10:05) and stores that value.
From this, it is clear why values in rrd database are almost always not round
numbers.
So, how to store round numbers in rrd database? By experimenting, i found out
that if rrd database is updated in exact time (ie. 10:05) then there is no
calculation of value, but instead, probed value is unchanged written to rrd!
Keeping in mind that zenoss does update in random times (it depends of a lot
of factors), it seems that it isn't possible to, using zenoss, store exact
values, and not calculated ones.
For this reason, i wrote small patch (attached), which is doing exactly what
was described - it updates rrd at adjusted modified time, so that value
stored is unchanged. This is accoplished by introducing new Datapoint type
called "VALUE", and when update is done, if type is "VALUE", then rrd is
updated in a special way.
I know, maybe there is a way to accomplish this in some other way, but this
was the quickiest for me. :-)
H.
--- zenoss/Products/ZenModel/RRDDataPoint.py.orig 2007-11-20 20:16:30.000000000 +0100
+++ zenoss/Products/ZenModel/RRDDataPoint.py 2007-11-20 20:15:28.000000000 +0100
@@ -59,7 +59,7 @@
meta_type = 'RRDDataPoint'
- rrdtypes = ('COUNTER', 'GAUGE', 'DERIVE', 'ABSOLUTE')
+ rrdtypes = ('COUNTER', 'GAUGE', 'DERIVE', 'ABSOLUTE', 'VALUE')
createCmd = ""
rrdtype = 'GAUGE'
--- zenoss/Products/ZenRRD/RRDUtil.py.orig 2007-11-20 20:16:52.000000000 +0100
+++ zenoss/Products/ZenRRD/RRDUtil.py 2007-11-20 21:04:51.000000000 +0100
@@ -26,15 +26,22 @@
self.defaultRrdCreateCommand = defaultRrdCreateCommand
self.defaultCycleTime = defaultCycleTime
- def save(self, path, value, rrdType, rrdCommand=None, cycleTime=None,
+ def save(self, path, value, in_rrdType, rrdCommand=None, cycleTime=None,
min='U', max='U'):
- import rrdtool, os
+ import rrdtool, os, time
if value is None: return None
if cycleTime is None:
cycleTime = self.defaultCycleTime
+ loc_time = int(time.time())
+ if in_rrdType == 'VALUE':
+ rrdType = 'GAUGE'
+ loc_time = loc_time - (loc_time%cycleTime)
+ else:
+ rrdType = in_rrdType
+
filename = performancePath(path) + '.rrd'
if not rrdCommand:
rrdCommand = self.defaultRrdCreateCommand
@@ -48,6 +55,7 @@
dataSource = 'DS:%s:%s:%d:%s:%s' % ('ds0', rrdType,
3*cycleTime, min, max)
rrdtool.create(filename,
+ "--start", str(loc_time-1),
"--step", str(cycleTime),
str(dataSource), *rrdCommand.split())
@@ -57,7 +65,7 @@
except (TypeError, ValueError):
return None
try:
- rrdtool.update(filename, 'N:%s' % value)
+ rrdtool.update(filename, '%s:%s' % (str(loc_time),value) )
log.debug('%s: %r', filename, value)
except rrdtool.error, err:
# may get update errors when updating too quickly
_______________________________________________
zenoss-users mailing list
[email protected]
http://lists.zenoss.org/mailman/listinfo/zenoss-users