CDEFs not working

Support questions about the Threshold plugin

Moderators: Developers, Moderators

wwolkers
Posts: 24
Joined: Thu Sep 14, 2006 6:44 am

CDEFs not working

Post by wwolkers »

Just tried to get a percentage from diskspace values, by generating a CDEF as follows:

cdef=CURRENT_DATA_SOURCE,CURRENT_GRAPH_MAXIMUM_VALUE,/,100,*

this works for normal cacti, but not for the thold plugin :(
in the plugin I get a division by zero error.

after looking at the thold source, is looks like the plugin never grabs the values from the rrd file :(
cigamit
Developer
Posts: 3367
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Re: CDEFs not working

Post by cigamit »

wwolkers wrote:Just tried to get a percentage from diskspace values, by generating a CDEF as follows:

cdef=CURRENT_DATA_SOURCE,CURRENT_GRAPH_MAXIMUM_VALUE,/,100,*

this works for normal cacti, but not for the thold plugin :(
in the plugin I get a division by zero error.

after looking at the thold source, is looks like the plugin never grabs the values from the rrd file :(
The thold plugin currently only does the basic CDEF functions, so anything with CURRENT_GRAPH_MAXIMUM_VALUE doesn't work (basically only CURRENT_DATA_SOURCE and simple math equations). I have to calculate the CDEF manually for now, which I can tell you is a big pain.
wwolkers
Posts: 24
Joined: Thu Sep 14, 2006 6:44 am

CDEF patch

Post by wwolkers »

the attached patch will add CDEF support in a better way than it is now :)

at least this gives you the CURRENT_DATA_SOURCE etc support.
Attachments
thold-functions.php.patch
thold-functions.php patch1
(2.12 KiB) Downloaded 789 times
cigamit
Developer
Posts: 3367
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

GREAT! I'll get that patch in ASAP!
cigamit
Developer
Posts: 3367
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

Well, after a few minor modifications, this patch is now in the SVN version.

The modifications aren't because of problems with your code, but I had to adapt it to the new way that thold checks (it now grabs the current data from the poller output instead of directly from the rrd file).

So far so good!
wwolkers
Posts: 24
Joined: Thu Sep 14, 2006 6:44 am

Post by wwolkers »

Nice job, that it grabs the output from the poller, should be a bit faster, and more stable.
Tekk
Posts: 34
Joined: Wed Aug 16, 2006 11:01 am
Location: France

Post by Tekk »

cigamit wrote:Well, after a few minor modifications, this patch is now in the SVN version.

The modifications aren't because of problems with your code, but I had to adapt it to the new way that thold checks (it now grabs the current data from the poller output instead of directly from the rrd file).

So far so good!
Hi cigamit,

Where can I get this patch please ?

Thanks.
cigamit
Developer
Posts: 3367
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

Tekk wrote:Hi cigamit,

Where can I get this patch please ?

Thanks.
The new version will be released in about a week, so don't fret. There are still a few wrinkles to iron out, but so far everything is working fairly well.
Tekk
Posts: 34
Joined: Wed Aug 16, 2006 11:01 am
Location: France

Post by Tekk »

cigamit wrote:The new version will be released in about a week, so don't fret. There are still a few wrinkles to iron out, but so far everything is working fairly well.
OK Thanks.
daemon
Cacti User
Posts: 61
Joined: Tue Jun 21, 2005 12:16 pm

Post by daemon »

I need to do the same sort of thing for interface traffic. the 0.3.0 version I just downloaded has files with a timestamp of july 25th, which leads me to believe the answer is "yes". I already have a bandwidth percentage CDEF I'm using for the graphs, so once I apply the patch can I just put "90" in for the high threshold and it will alert me when the traffic goes above 90%?

edited to add: well, I decided to go ahead and try it just for fun, and I got a divide by zero after applying the patch.

Warning: Division by zero in /www/htdocs/cacti-0.8.6h/plugins/thold/thold-functions.php on line 108

here's my percentage CDEF:

Attachments
thold-problem.jpg
thold-problem.jpg (59.48 KiB) Viewed 13428 times
Last edited by daemon on Thu Nov 02, 2006 3:56 pm, edited 1 time in total.
cacti 0.8.6h | cactid 0.8.6g
mysql 4.1.16 | net-snmp 5.1.2-11 | rrdtool 1.0.50 | apache 2.2.0 | php 5.1.2 | RHEL AS rel. 4 kernel 2.6.9-22.ELsmp
daemon
Cacti User
Posts: 61
Joined: Tue Jun 21, 2005 12:16 pm

Post by daemon »

I took a wild guess and decided to change |query_ifspeed| to CURRENT_DS_MAXIMUM_VALUE, and now it isn't getting divide by zero errors but the current value is always 800 for almost all the interfaces. since the formula is (current value/ifspeed)*8*100, it's almost as if (current value/ifspeed) is getting rounded up to 1 or something. if I graph the values using the same CDEF they show up fine, so I'm at a bit of a loss here.

I'm also curious, if I use CURRENT_DS_MAXIMUM_VALUE, and the speed of the interface changes, will this value update or do I have to refresh the indexes using the green circle thingie?
cacti 0.8.6h | cactid 0.8.6g
mysql 4.1.16 | net-snmp 5.1.2-11 | rrdtool 1.0.50 | apache 2.2.0 | php 5.1.2 | RHEL AS rel. 4 kernel 2.6.9-22.ELsmp
daemon
Cacti User
Posts: 61
Joined: Tue Jun 21, 2005 12:16 pm

Post by daemon »

I've done some more digging and after examining thold-functions.php I think I found where the problem lies. here's an excerpt of some print statements I threw into the file:

Code: Select all

CURRENT_DATA_SOURCE
CDEF value: 276.656
CURRENT_DS_MAXIMUM_VALUE
CDEF value: 276.656
oldvalue: 276.656
value: 276.656
id: 17
rra: 2354
ds: traffic_in
cdef[value]: 3
entering thold_rpn...x is 276.656, y is 276.656, z is 4
returning 276.656 / 276.656
entering thold_rpn...x is 1, y is 100, z is 3
returning 1 * 100
entering thold_rpn...x is 100, y is 8, z is 3
returning 100 * 8
for some reason, in the case statement for CURRENT_DS_MAXIMUM_VALUE it's coming back with CURRENT_DATA_SOURCE, which is where the 800 is coming from (CURRENT_DATA_SOURCE / CURRENT_DATA_SOURCE * 800). any idea why $cdef['value'] = get_current_value($rra, 'rrd_maximum', 0); would be returning the same number as $cdef['value'] = get_current_value($rra, $ds, 0);?
cacti 0.8.6h | cactid 0.8.6g
mysql 4.1.16 | net-snmp 5.1.2-11 | rrdtool 1.0.50 | apache 2.2.0 | php 5.1.2 | RHEL AS rel. 4 kernel 2.6.9-22.ELsmp
F.Ultra
Posts: 3
Joined: Mon Nov 06, 2006 11:15 am

Post by F.Ultra »

I think that you made the same mistake that I did daemon, you used the CURRENT_DS_MAXIMUM_VALUE when you should have used the CURRENT_GRAPH_MAXIMUM_VALUE.

At least that is what I belevide that I did wrong since I have one machine that also triggers at 100% I recently changed the CDEF and will see in a few minutes if that was the cause :)
F.Ultra
Posts: 3
Joined: Mon Nov 06, 2006 11:15 am

Post by F.Ultra »

Seams like I cheered prematurelly, this is really strange. The CDEF works for all other devices except just this one which has 8.65 G used of 31.43 G total and the CDEF according to Thold tells me that it is using 100%
daemon
Cacti User
Posts: 61
Joined: Tue Jun 21, 2005 12:16 pm

Post by daemon »

yea, CURRENT_GRAPH_MAXIMUM_VALUE didn't work for me either. the thing that really confuses me is that CURRENT_DS_MAXIMUM_VALUE works just fine when it comes to getting the values on a graph.
cacti 0.8.6h | cactid 0.8.6g
mysql 4.1.16 | net-snmp 5.1.2-11 | rrdtool 1.0.50 | apache 2.2.0 | php 5.1.2 | RHEL AS rel. 4 kernel 2.6.9-22.ELsmp
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests