Threshold for Bandwidth %

Support questions about the Threshold plugin

Moderators: Developers, Moderators

And
Posts: 23
Joined: Thu Jun 12, 2008 8:36 am

Threshold for Bandwidth %

Post by And »

Hi all,
I'm interested in creating a threshold based on a network interface port utilization. That's because I've got a lot of interfaces to monitor, with different interfaces speed (100 Mbits, 1Gigabits and so on).
I've been searching the forum and it looks like it's not possible wto do it ith network interfaces. Please correct me if I'm wrong.
Thanks in advance!

And :)
drh
Posts: 17
Joined: Mon Jan 26, 2009 10:34 am

Percentage based % threshold on interface utilization

Post by drh »

Also struggled thru lots of threads looking to get a percentage based threshold trigger of interface utilization, but non so far have been satisfactory.
Lost of requests for % util in graphs and thold, but so far not easy without changing base scripts.

So I'm also looking to accomplish that without any tinkering to the underneath engines of Cacti so updates don't screw up the modifications.

Should be feasible using traffic_in, traffic_out and ifSpeed values?
But how?

BTW. rrd_maximum is set to ifSpeed. Is that usefull? If so how.
mstbone67a
Posts: 28
Joined: Mon Sep 21, 2009 9:31 am

Post by mstbone67a »

trying to do this also.. is there some cdef that can define the link speed for it to calc the % against.. Newb here..
redback09
Posts: 9
Joined: Wed Jul 22, 2009 9:55 am

bandwidth%

Post by redback09 »

hello
if I understand your question

y need to prepare threshold template
for 1G and 100Mbps
Y can apply this template for each 1G or 100Mbps links


Data Type CDEF
Threshold CDEF
Apply this CDEF before returning the data.
y can use cdef that y can prepare for change turn bytes Mbps

for example
1000Mpbs-|%100-%2| Interface - Traffic traffic_out High/Low 1000 50 5 Minutes Every 6 Hours
drh
Posts: 17
Joined: Mon Jan 26, 2009 10:34 am

Want to treashold to a percentage not absolute value

Post by drh »

@redback09

Thx for the response, but that is not the approach I was looking for.
I started out that way, but it is tedious when you need to apply that to a single, or worse multiple, interface like a 10/100/1000 and don't know/remember what ifSpeed it is actually running at.

I want to have just one threshold template that is applicable to 10, 100, 1000, 10000Mbps links. So one that just has a percentage of actual ifSpeed as threshold.

This way one does not have to go check each interface individually to see/remember the ifSpeed and then choose the appropriate threshold template.
mstbone67a
Posts: 28
Joined: Mon Sep 21, 2009 9:31 am

Post by mstbone67a »

thanks for the tip on the cdef to convert bytes to Mbps got this working.. manually setting the high limit.. instead of using a % value.

thanks
Now if i can get the damn alert to syslog working.. I have no thold.log i see the entries for the alerts in the db though..
tpang13
Posts: 12
Joined: Sun Feb 11, 2007 9:04 pm

Post by tpang13 »

Dear Sirs,

how can i create the formula of calculation the % of network utilization ?

Regards
Attachments
cacti.jpg
cacti.jpg (198.29 KiB) Viewed 41059 times
Daemon1978

Post by Daemon1978 »

Hello all,
no solution has been found so far.

At the moment I was trying to apply this CDEF:

cdef=CURRENT_DATA_SOURCE,8,*,CURRENT_DS_MAXIMUM_VALUE,/,100,*

This should permit to:

Multiply data source value per 8
Divide it for the maximum value of the data source (the IfSpeed)
Multiply the result per 100 to have a percentage value

But, strangely, just a simple division for the CURRENT_DS_MAXIMUM_VALUE returns 1. So it obviously doesn't work.

Putting 1000000000 instead of CURRENT_DS_MAXIMUM_VALUE works fine, but in this way this is not automatic anymore.

Is this related to a Cacti Bug or a Thold plugin bug?

Any clue?

Thank you in advance.

Regards
Last edited by Daemon1978 on Wed Nov 09, 2016 4:52 am, edited 1 time in total.
TheHack
Posts: 28
Joined: Fri Apr 28, 2006 4:02 am

Threshold % of line speed!

Post by TheHack »

I guess you're looking for CDEF to accomplish the percent calculation that queries the if_speed and make the a % calculation.
See the example below:
And please post if you were successful!
Attachments
CDEF for Thresholds
CDEF for Thresholds
Threshold percentage CDEF.jpg (50.62 KiB) Viewed 40203 times
Threshold settings
Threshold settings
Threshold percentage.jpg (79.4 KiB) Viewed 40203 times
snipi_
Posts: 1
Joined: Thu May 06, 2010 5:58 am

Post by snipi_ »

hi there,

Im working on the same problem right now and the "query_ifSpeed" argument in CDEF didnt work for me

my approach was like this:

i added a 3rd data source ("c") to the snmp - interface data query which stores the maximum link speed of an interface

therefore, i added the folling to interface.xml

Code: Select all

<ifLinkSpeed>
                        <name>LinkSpeed</name>
                        <method>walk</method>
                        <source>value</source>
                        <direction>output</direction>
                        <oid>.1.3.6.1.2.1.2.2.1.5</oid>
</ifLinkSpeed>
With a few modifications to grap templates and CDEF, cacti allows me to display the current network load in %

my CDEF is:

Code: Select all

cdef=CURRENT_DATA_SOURCE,8,*,c,/,100,*
where current_data_source is either traffic_in or traffic_out and "c" is always LinkSpeed (the 3rd data source)

This works for the graph, but *NOT* for thold ....

If i use the same CDEF in thold, it always returns 0%

my guess is, thold can not work with "c" because when i change the "c" in the CDEF to a static value like 100000, it works ....
Attachments
in the graph, the CDEF works (&amp;quot;LinkSpeed&amp;quot; is the maximum speed, &amp;quot;Usage In&amp;quot; and &amp;quot;Usage Out&amp;quot; are the network loads in %)
in the graph, the CDEF works (&quot;LinkSpeed&quot; is the maximum speed, &quot;Usage In&quot; and &quot;Usage Out&quot; are the network loads in %)
usage.PNG (49.41 KiB) Viewed 40164 times
in thold, the CDEF always returns 0 when used with the &amp;quot;c&amp;quot; argument. if i change it to a static value, it works
in thold, the CDEF always returns 0 when used with the &quot;c&quot; argument. if i change it to a static value, it works
thold.PNG (6.55 KiB) Viewed 40164 times
TheHack
Posts: 28
Joined: Fri Apr 28, 2006 4:02 am

Post by TheHack »

Well, yes you are correct but with a small tweaking on the code it will work:

Code: Select all

//----------------------
// starting on line 845 in thold_functions.php after the switch statement closure bracket:
// break;
// }
			} else if ($cdef['type'] == 6) {
        $regresult = preg_match('/^\|query_(.*)\|$/', $cdef['value'], $matches);
      	if($regresult > 0) {
  				// Grab result for query
					$cdef['value'] = db_fetch_cell("SELECT `h`.`field_value` FROM `poller_item` p, `host_snmp_cache` h where `p`.`local_data_id` = '" . $rra . "' and `p`.`host_id` = `h`.`host_id` and `h`.`field_name` = '" . $matches[1] . "' and `p`.`rrd_name` = 'traffic_in' and SUBSTRING_INDEX(`p`.`arg1`, '.', -1 ) = `h`.`snmp_index`", FALSE);
//-------------------------------------------------
Attached you will find the full code as zip file[/code]
Attachments
thold_functions.zip
thold_functions.php patched for Thold 4.1 to allow ifspeed queries in CDEF's.
(15.11 KiB) Downloaded 3708 times
brightm
Cacti User
Posts: 88
Joined: Wed Jun 16, 2010 6:20 am
Location: Bournemouth UK

Post by brightm »

Hi,

I've followed this thread to get the same thing working. After weeks of playing around i finally managed to get graphs showing bandwidth percentage using cdef, etc. The final piece of the puzzle was getting thold to alert on the percentage but i still can't get this bit working. I have downloaded the thold_functions.php file but it doesn't seem to work. The current speed in thold is showing as -100 so it looks like the cdef is not working in thold (speed of line percent). Can you help?

Thanks, Mick.
TheHack
Posts: 28
Joined: Fri Apr 28, 2006 4:02 am

Post by TheHack »

You have to check if your device is returning ifspeed of the given interface.
You may need to add a comment into the graph with |query_ifspeed| to check and rebuild the poller cache.

Once you have confirmed that |query_ifspeed| is halding a vlue, you may need to check your print format and if the DS upper and lower values are set correctly.

The CDEF solution only works if you get the ifspeed from the device correctly..
TheHack
Posts: 28
Joined: Fri Apr 28, 2006 4:02 am

Post by TheHack »

BTW: The solution with the 3rd data source (ifspeed) works differently:

There is no need to use a CDEF to calculate the bandwidth. You simply say in the thold template to caclulate the percentage based on the 'c' datasouce if you like.

The only problem might be that ifspeed returns bps while standard usage is returning bytes per second. You have to add a CDEF to the thold template calculation to make c bytes per second as well.
I have attached my template for storage usage as an example for percentage calculation in thold...
Attachments
Thold Percentage calculation.png
Thold Percentage calculation.png (67.35 KiB) Viewed 39262 times
brightm
Cacti User
Posts: 88
Joined: Wed Jun 16, 2010 6:20 am
Location: Bournemouth UK

Post by brightm »

Thanks for the reply. Can i just check a few things with you:

1) My original graphs were based on 'Traffic Statistics' which did not include ifSpeed as an 'output' in the xml query. By adding to the xml file an snmp query for ifBandwidth as an 'output' i get the correct interface speed on the graphs. But as i now have a new DS i have been re-creating the rrd files using rrdtool create and overwriting the old ones.

2) with a new DS of ifBandwidth in the snmp xml query it is necessary yo update each device's 'associated data query' = click the green button.

3) In the threshold template the 'Data Type' = 'Percentage' and the 'Percent Datasource' = ifSpeed (or ifBandwidth in my case) or should this be 'traffic_in and 'traffic_out'.
The DS 'c' in my case is ifSpeed (ifBandwidth)

4) Are you saying that I need to convert interface speed from bits to bytes.


I was informed of an alternative way of doing all this by adding two more Data Source's to my RRD files of type COMPUTE to calculate traffic in and traffic out as a percentage. This means re-creating all the RRD files and assigning the new DS's in the graph listings to get the percentage values without using CDEF's. It's alot of work. Also i would still need to update all the device's snmp queries to get ifBandwidth (ifSpeed) as an 'output'.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest