Threshold with CDEF'd graphs, i.e. Disk space by percentage

Support questions about the Threshold plugin

Moderators: Developers, Moderators

benhanson
Posts: 43
Joined: Tue Feb 08, 2005 8:59 pm

Threshold with CDEF'd graphs, i.e. Disk space by percentage

Post by benhanson »

Would there be any way to have the threshold module alert on a CDEF value? I've just figured out how to graph my drive space based on percentage rather than bytes free, only to realize that now I can't alert on the percent value since it is not an actual data source in the RRD. If you could do this, you would gain all of the flexibility of CDEF's in alerting as well.

Example:

Disk bytes free has 2 Data Sources: hdd_total and hdd_used
I can set a threshold on these. I've changed my graphs by adding a new graph item with no source, but a CDEF - a,b,/,100,*
ABX
Cacti User
Posts: 68
Joined: Thu Mar 01, 2007 5:55 am

Post by ABX »

I'd like to see this too.

Cacti 0.8.7
ejensen
Cacti User
Posts: 55
Joined: Mon Jul 12, 2004 11:39 am

Post by ejensen »

can you share with us how to setup a CDEF to calculate the percentage?

an idea i have (forgive me if its stupid, i am kinda new to cacti)... could you just setup a new datasource that stores the percentage from the disk?
benhanson
Posts: 43
Joined: Tue Feb 08, 2005 8:59 pm

CDEF

Post by benhanson »

The CDEF formula is there in my first message, a,b,/,100,*

I was never able to set a threshold on this, but I haven't tried in quite a few versions.
looc
Cacti User
Posts: 110
Joined: Mon Aug 13, 2007 3:40 am

Re: CDEF

Post by looc »

benhanson wrote:The CDEF formula is there in my first message, a,b,/,100,*

I was never able to set a threshold on this, but I haven't tried in quite a few versions.
how defined a&b?
and how calculate this formula?
a/b*100?!
Cacti Version - 0.8.7 & spine
Plugin Architecture - 1.3
Server Info - Windows 2003 EP
Web Server -IIS6.0
PHP - 5.2.3
MySQL - 4.1.10
RRDTool - 1.2.15
SNMP - 5.4.1
--------------------------
plugins:
reportit 0.5.1|monitor 0.8.1|thold 0.3.8
looc
Cacti User
Posts: 110
Joined: Mon Aug 13, 2007 3:40 am

Post by looc »

you want to used these?
DEF:a="E\:/www/rra/localhost_hdd_used_9.rrd":hdd_total:AVERAGE \
DEF:b="E\:/www/rra/localhost_hdd_used_9.rrd":hdd_used:AVERAGE \
DEF:a&DEF:b?
custom string can define These two variables?
Cacti Version - 0.8.7 & spine
Plugin Architecture - 1.3
Server Info - Windows 2003 EP
Web Server -IIS6.0
PHP - 5.2.3
MySQL - 4.1.10
RRDTool - 1.2.15
SNMP - 5.4.1
--------------------------
plugins:
reportit 0.5.1|monitor 0.8.1|thold 0.3.8
llow
Cacti User
Posts: 170
Joined: Fri Oct 05, 2007 5:34 pm

Post by llow »

Here is a patch that will allow you to use the ALL_DATA_SOURCES_DUPS and ALL_DATA_SOURCES_NODUPS (they will perform the same since this is based on the data soruce and not the graph.

Example use:

Data source with mem_used and mem_free.
Create threshold on mem_used and use a CDEF of CURRENT_DATA_SOURCE,100,*,ALL_DATA_SOURCES_NODUPS,/ and you will get a percentage of mem_used.

There should only be a performance impact if this DS is used and it only pertains to an extra sql query.
Attachments
thold-alldatasources.patch
(764 Bytes) Downloaded 644 times
llow
Cacti User
Posts: 170
Joined: Fri Oct 05, 2007 5:34 pm

Post by llow »

Here is a better patch, will only perform one lookup of the data source. There is some problem I am having an odd problem with no data being returned from rrdtool_function_fetch on the hdd rrds.
Attachments
thold-alldatasources-v2.patch
(1.49 KiB) Downloaded 903 times
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

llow wrote:Here is a better patch, will only perform one lookup of the data source. There is some problem I am having an odd problem with no data being returned from rrdtool_function_fetch on the hdd rrds.
llow, did you solve your hdd problem? I have just tried your patch, and I'm seeing an issue too. Unfortunately, hdd's are all I care about at the moment :-)
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
llow
Cacti User
Posts: 170
Joined: Fri Oct 05, 2007 5:34 pm

Post by llow »

It will only work "properly" if the rras used are updated at the same time. I have about 600 routers where I pull % of memory and have no issue. I use the UCD-SNMP mib for all my Linux servers and have no issue.

The only problem is when I use the HOST-MIB with a script server that returns hdd_free and hdd_used and since the script server is called multiple times there is a problem with having the hdd_free and hdd_used updated by the time the thold poll is taken. This is especially more difficult in my setup where my HDD data is polled at 5 minutes but my poller runs every minute. The two data sources may not even be polled in the same poller interval.

I haven't come up with a good idea to solve this yet as I would like to have the script server be able to handle data like data input methods can.

I think this is more of something that needs to be solved in the base code instead of directly within Threshold.
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

OK. I think I have this working now.

First of all, I'm using a different query than llow for the CDEF part - I don't really understand the one they used - $ds is a field name - when would it ever be in the id field? I skipped the changes to get_current_value(), but I would say that I was getting type-related errors from your patch, one of which I fixed with:

Code: Select all

// NOT THIS ->   if (!is_array($ds)) $ds[0] = $ds;
       if (!is_array($ds)) { 
         $ds_tmp = $ds;
         $ds = array();
         $ds[0] = $ds_tmp;
      }
I then ended up rewriting the RPN code in thold to actually do RPN properly with a stack, since my valid CDEF had two operators in a row, which threw off thold.

So here's a different patch against the original thold_functions.php, with improved RPN handling and ALL_DATA_SOURCES implemented.

I don't use 1 minute polling on this particular install, so I doubt anything has changed there.
Attachments
hj.thold_functions.rpn.all_data_sources.patch
patch for threshold to allow ALL_DATA_SOURCES in CDEFs, and to allow more CDEFs to work correctly..
(6.5 KiB) Downloaded 642 times
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
llow
Cacti User
Posts: 170
Joined: Fri Oct 05, 2007 5:34 pm

Post by llow »

I'll have to check out your ideas. Any chance you could post a patch in unified format as it is much easier to read changes :)
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

llow wrote:I'll have to check out your ideas. Any chance you could post a patch in unified format as it is much easier to read changes :)
Sure here you go. It has a little more than it needs to have, because I cleaned up the indenting inside the case statement :oops:
Attachments
hj.thold_functions.rpn.all_data_sources.unifiedpatch.txt
(6.88 KiB) Downloaded 918 times
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
mcutting
Cacti Guru User
Posts: 1884
Joined: Mon Oct 16, 2006 5:57 am
Location: United Kingdom
Contact:

Post by mcutting »

Howie - do you have a patched php file for us windows uers ?

Thanks
Cacti Version 0.8.8b
Cacti OS Ubuntu LTS
RRDTool Version RRDTool 1.4.7
Poller Information
Type SPINE 0.8.8b
User avatar
cyrill
Cacti User
Posts: 271
Joined: Fri Jan 25, 2008 8:43 am
Location: California - USA

Post by cyrill »

Hello !

I'm a newbie with cacti and my english is bad. Can you help me ? A new CDEF should be created ???

Can you explain me how can I created it and how it work ?

thanks for your help
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests