Hiya gang! I've run into some trouble trying to use multiple datasources in one CDEF.
I've got squid cache I'm monitoring. One datasource is the number of http requests
and another datasource is the number of cache hits.
I figured I could make a graph, add a LINE1 element for the cache_hits datasource,
then apply a CDEF that divides it by the http_hits datasource, then multiples by 100,
yielding a nice percentage of hits that were found in the cache. But it doesn't work. I
can see why looking at the "Source" for the graph:
/usr/local/rrdtool/bin/rrdtool graph - \
--imgformat=PNG \
--start="-86400" \
--title="Squid Cache Hit Percentages" \
--rigid \
--base=1000 \
--height=200 \
--width=500 \
--upper-limit=100 \
--lower-limit=0 \
--vertical-label="Percent" \
DEF:a="/home/cacti/rra/squid_pa_us_hits.rrd":squid_pa_us_hits:AVERAGE \
DEF:b="/home/cacti/rra/squid_sv_us_hits.rrd":squid_sv_us_hits:AVERAGE \
DEF:c="/home/cacti/rra/squid_cache_hits.rrd":squid_cache_hits:AVERAGE \
DEF:d="/home/cacti/rra/squid_cache_hitsctr.rrd":squid_cache_hitsctr:AVERAGE \
CDEF:cdefbc=d,,/,100,* \
LINE2:cdefbc#F24AC8:""
Note that there is no DEF:e for the squid_http_hitsctr.rrd file, and also note the
d,,/ stuff in the CDEF line? The datasource I added to the CDEF is missing. Weird.
If I insert:
DEF:e="/home/cacti/rra/squid_http_hitsctr.rrd":squid_http_hitsctr:AVERAGE \
and change the CDEF to be d,e,/,100,*
then the rrdtool generates the graph just dandy.
Any ideas why cacti isn't generating DEF:e for my 2nd data source?
Brent
CDEF using multiple datasources not working
Moderators: Developers, Moderators
whoops... I just noticed that I cleaned up the "source" output a bit too much trying to make
it tidy and readable in a smaller number of columns. The reason there are DEF's for
a, b, and c, is that I have several other elements on this graph that are showing stats
for various peer caches my squid cache knows about. But they're unrelated to the
problem at hand.
'Just to set your mind at ease... (grin) The crux of the problem I've confirmed is that
cacti isn't creating an 'e' DEF and then using it in the CDEF line and I dunno why
(hopefully just because I'm missing something stupid - grin)
Brent
it tidy and readable in a smaller number of columns. The reason there are DEF's for
a, b, and c, is that I have several other elements on this graph that are showing stats
for various peer caches my squid cache knows about. But they're unrelated to the
problem at hand.
'Just to set your mind at ease... (grin) The crux of the problem I've confirmed is that
cacti isn't creating an 'e' DEF and then using it in the CDEF line and I dunno why
(hopefully just because I'm missing something stupid - grin)
Brent
I think I figured it out, though I still think it might be a bug. In my case, I was using a CDEF
to do math with two datasources and graph the result, BUT NOT GRAPH THE
DATASOURCES THEMSELVES. So, since I hadn't added an element to the graph
for both of the datasources I was trying to use in the CDEF, cacti didn't generate a
DEF e: line for one of the two datasources.
I just added another graph item for the 2nd data source and made it a LINE1 with a white
foreground (so it's basically invisible on a white background). The ONLY reason this
works, though, is because the values I'm dividing happen to be less than 100 (remember
this is a graph of percentages) and so they don't mess up the graph scaling. I'll prob'ly
change the graph scaling to be fixed between 0 and 100 just in case my squid cache
usage hits more than 100 hits per second (pretty likely, actually).
Brent
to do math with two datasources and graph the result, BUT NOT GRAPH THE
DATASOURCES THEMSELVES. So, since I hadn't added an element to the graph
for both of the datasources I was trying to use in the CDEF, cacti didn't generate a
DEF e: line for one of the two datasources.
I just added another graph item for the 2nd data source and made it a LINE1 with a white
foreground (so it's basically invisible on a white background). The ONLY reason this
works, though, is because the values I'm dividing happen to be less than 100 (remember
this is a graph of percentages) and so they don't mess up the graph scaling. I'll prob'ly
change the graph scaling to be fixed between 0 and 100 just in case my squid cache
usage hits more than 100 hits per second (pretty likely, actually).
Brent
Who is online
Users browsing this forum: No registered users and 4 guests