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

Support questions about the Threshold plugin

Moderators: Developers, Moderators

User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

cyrill wrote: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
I would wait until a few more people have tested it, if you are unfamiliar with Cacti.
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!)
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

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

Thanks
Here you go... :-)

Anyone like it in french? or COBOL? ;-)
Attachments
thold_functions.php.txt
(36.69 KiB) Downloaded 1297 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!)
User avatar
cyrill
Cacti User
Posts: 271
Joined: Fri Jan 25, 2008 8:43 am
Location: California - USA

Post by cyrill »

Howie wrote: I would wait until a few more people have tested it, if you are unfamiliar with Cacti.
ha okey.
ejensen
Cacti User
Posts: 55
Joined: Mon Jul 12, 2004 11:39 am

Post by ejensen »

ok Howie, sorry for such a newbish question, but how do i use this new functionality to alert on free space? i have replaced the original functions.php file with yours, but im unclear in how to create a threshold on free space now.

can you explain the steps i need to take? thanks so much! :D
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

ejensen wrote:ok Howie, sorry for such a newbish question, but how do i use this new functionality to alert on free space? i have replaced the original functions.php file with yours, but im unclear in how to create a threshold on free space now.

can you explain the steps i need to take? thanks so much! :D
You do it as llow suggested above...

There are a couple of different DS that do disk space, one does used+total and another does free+total... it works the same way though.

Create a new CDEF called "Used/Total -> Percentage" and use the following formula:

Code: Select all

CURRENT_DATA_SOURCE,100,*,ALL_DATA_SOURCES_NODUPS,CURRENT_DATA_SOURCE,-,/
Now you create thesholds on hdd_used, with the above CDEF applied. So what that does is: (hdd_used/((hdd_used+hdd_total)-hdd_used)) * 100

If you have a DS containing hdd_free and hdd_total, then you need to create a thold on hdd_free, and the result will be against percentage FREE instead of used.
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!)
ejensen
Cacti User
Posts: 55
Joined: Mon Jul 12, 2004 11:39 am

Post by ejensen »

Thanks Howie, I tried those steps and Im not seeing the new CDEF when i create a threshold. I looked in the cacti log and i see the following error.

Code: Select all

02/07/2008 10:55:40 AM - CMDPHP: Poller[0] ERROR: SQL Assoc Failed!, Error:'1064', SQL:"select thold_data.cdef, thold_data.rra_id, thold_data.data_id, thold_data.lastread, thold_data.oldvalue, data_template_rrd.data_source_name as name, data_template_rrd.data_source_type_id from thold_data LEFT JOIN data_template_rrd on (data_template_rrd.id = thold_data.data_id) WHERE data_template_rrd.data_source_name != '' AND "
I will search the forums for a solution to this, but i wondered if it has to do with the new thold_functions file you created.
thanks, Eric
mcutting
Cacti Guru User
Posts: 1884
Joined: Mon Oct 16, 2006 5:57 am
Location: United Kingdom
Contact:

Post by mcutting »

I tried this also with Howie's patched thold_functions.php. My CDEF has been created as

cdef=CURRENT_DATA_SOURCE,100,*,ALL_DATA_SOURCES_NODUPS,CURRENT_DATA_SOURCE,-,/

When I attempt to set the hdd_used DS for any of my servers, I get a "Division by zero in c:\wamp\www\cacti\plugins\thold\thold_plugins.php line 386"

Any ideas ?
Cacti Version 0.8.8b
Cacti OS Ubuntu LTS
RRDTool Version RRDTool 1.4.7
Poller Information
Type SPINE 0.8.8b
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

mcutting wrote:I tried this also with Howie's patched thold_functions.php. My CDEF has been created as

cdef=CURRENT_DATA_SOURCE,100,*,ALL_DATA_SOURCES_NODUPS,CURRENT_DATA_SOURCE,-,/

When I attempt to set the hdd_used DS for any of my servers, I get a "Division by zero in c:\wamp\www\cacti\plugins\thold\thold_plugins.php line 386"

Any ideas ?
That kind of implies that there's only one DS in the template, because otherwise ALL_DATA_SOURCES_NODUPS-CURRENT_DATA_SOURCE wouldn't be zero... either that or my code is really broken, but that exact CDEF works for me with the HOST-MIB hard drive template.
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 »

Hmmm - that's the template I'm applying it against. I have this working anyway in another format. There is a post by lordzik which I used. In the end, Jimmy added the hack to the THOLD plugin, so from around 0.3.5 onwards, you only need to create the CDEF itself.

This seems to work fine.

The CDEF itself is

CURRENT_DATA_SOURCE,VALUE_OF_HDD_TOTAL,/,100,*
Cacti Version 0.8.8b
Cacti OS Ubuntu LTS
RRDTool Version RRDTool 1.4.7
Poller Information
Type SPINE 0.8.8b
myfreeke
Cacti User
Posts: 82
Joined: Tue Dec 04, 2007 10:24 pm

Post by myfreeke »

anyone working ok now ? can anyone solution do it
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

My solution is working for me. :-?
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!)
new
Posts: 23
Joined: Mon Dec 10, 2007 10:37 am

Post by new »

Howie wrote:
ejensen wrote:ok Howie, sorry for such a newbish question, but how do i use this new functionality to alert on free space? i have replaced the original functions.php file with yours, but im unclear in how to create a threshold on free space now.

can you explain the steps i need to take? thanks so much! :D
You do it as llow suggested above...

There are a couple of different DS that do disk space, one does used+total and another does free+total... it works the same way though.

Create a new CDEF called "Used/Total -> Percentage" and use the following formula:

Code: Select all

CURRENT_DATA_SOURCE,100,*,ALL_DATA_SOURCES_NODUPS,CURRENT_DATA_SOURCE,-,/
Now you create thesholds on hdd_used, with the above CDEF applied. So what that does is: (hdd_used/((hdd_used+hdd_total)-hdd_used)) * 100

If you have a DS containing hdd_free and hdd_total, then you need to create a thold on hdd_free, and the result will be against percentage FREE instead of used.

Sorry, it the solution working only for the disc space? What it is necessary to do if I want to create thresholds that check for example percent of IP Usage (SNMP based data)?
I created a CDEF as it is described, added the lines corresponding to the ALL_DATA_SOURCES from Howie's patch to thold-functions.php file, then created a theshold template, applied it to the corresponding devices and it does not work. I tried to use ALL_DATA_SOURCES_NODUPS and ALL_DATA_SOURCES_DUPS and SIMILAR_DATA_SOURCES_NODUPS that seems to be added after I hve applied the patch. What else should be done?

Many thanks in advance!
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

new wrote: Sorry, it the solution working only for the disc space? What it is necessary to do if I want to create thresholds that check for example percent of IP Usage (SNMP based data)?
I created a CDEF as it is described, added the lines corresponding to the ALL_DATA_SOURCES from Howie's patch to thold-functions.php file, then created a theshold template, applied it to the corresponding devices and it does not work. I tried to use ALL_DATA_SOURCES_NODUPS and ALL_DATA_SOURCES_DUPS and SIMILAR_DATA_SOURCES_NODUPS that seems to be added after I hve applied the patch. What else should be done?
What are you trying to calculate? For interface traffic, that formula would give you something strange like 'percentage of total traffic that is inbound'.
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!)
new
Posts: 23
Joined: Mon Dec 10, 2007 10:37 am

Post by new »

Howie wrote:
new wrote: Sorry, it the solution working only for the disc space? What it is necessary to do if I want to create thresholds that check for example percent of IP Usage (SNMP based data)?
I created a CDEF as it is described, added the lines corresponding to the ALL_DATA_SOURCES from Howie's patch to thold-functions.php file, then created a theshold template, applied it to the corresponding devices and it does not work. I tried to use ALL_DATA_SOURCES_NODUPS and ALL_DATA_SOURCES_DUPS and SIMILAR_DATA_SOURCES_NODUPS that seems to be added after I hve applied the patch. What else should be done?
What are you trying to calculate? For interface traffic, that formula would give you something strange like 'percentage of total traffic that is inbound'.
No, it is not an interface traffic, some dhcp server gives IP adresses from the poll, I need to have threshold of percentage of given from the total.

This is from the rrdtool graph
DEF:a="/opt/lampp/htdocs/cacti/rra/fbsr64k01_total_22994.rrd":total:AVERAGE \
DEF:b="/opt/lampp/htdocs/cacti/rra/fbsr64k01_total_22994.rrd":used:AVERAGE \
CDEF:cdeff=b,a,/,100,* \

I need to have a threshold when CDEF reaches for example 75 %.
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

new wrote: No, it is not an interface traffic, some dhcp server gives IP adresses from the poll, I need to have threshold of percentage of given from the total.

This is from the rrdtool graph
DEF:a="/opt/lampp/htdocs/cacti/rra/fbsr64k01_total_22994.rrd":total:AVERAGE \
DEF:b="/opt/lampp/htdocs/cacti/rra/fbsr64k01_total_22994.rrd":used:AVERAGE \
CDEF:cdeff=b,a,/,100,* \

I need to have a threshold when CDEF reaches for example 75 %.
OK, I see. Then yes, the same formula should work. What do you actually see? an error? 0? something else?
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!)
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests