How can I calculate Line speed in CDEF automatically?

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Moderators, Developers

Author
Message
User avatar
TFC
Cacti Pro User
Posts: 722
Joined: Wed Apr 09, 2003 2:17 am
Location: Izmir/Turkey

How can I calculate Line speed in CDEF automatically?

#1 Post by TFC » Wed Jan 07, 2004 6:54 am

Hi,
When I want to see my GPRINT like XX (ZY%) like MRTG,I need to know line speed and write down this value to CDEF. So if there are many different line speed we must create different CDEF and different graph template for each Line speed. I mean, for example, If Ihave 100Mbit,64Kbit,10Mbit or 155Mbit, I have to create 4 CDEF and 4 graph template. AM I right?
Now, question time, Is there any way to insert line speed to CDEF automatically.
I write down my CDEF as an example:
Item #1 Special Data Source: CURRENT_DATA_SOURCE
Item #2 Custom String: 8
Item #3 Operator: *
Item #4 Custom String: 100000000
Item #5 Operator: /
Item #6 Custom String: 100
Item #7 Operator: *
As you see this is CDEF for 100Mbit fast ethernet.

Bisonlux
Cacti User
Posts: 79
Joined: Wed Jul 23, 2003 4:35 pm
Location: Luxembourg

#2 Post by Bisonlux » Wed Jan 07, 2004 11:41 am

1) Edit rrd.php file and search this string:

Code: Select all

$cdef_string = str_replace("ALL_DATA_SOURCES_NODUPS", $cdef_total, $cdef_string); 
2) Add below a new line with this string:

Code: Select all

$cdef_string = str_replace("|rrd_upper_limit|", $graph["upper_limit"], $cdef_string);
3) Replace your CDEF item # 4 with this value:
Item #4 Custom String: |rrd_upper_limit|
In this example the variable rrd_upper_limit is replaced by the Upper Limit defined in the Graph Configuration

Bye,

raX
Lead Developer
Posts: 2237
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

#3 Post by raX » Thu Jan 08, 2004 11:31 pm

Also due to popular demand, the next version of Cacti impliments two new special data sources:

CURRENT_MAXIMUM_VALUE
CURRENT_MINIMUM_VALUE

These will automatically substitute the maximum/minimum value of a data source into a CDEF.

-Ian

User avatar
TFC
Cacti Pro User
Posts: 722
Joined: Wed Apr 09, 2003 2:17 am
Location: Izmir/Turkey

#4 Post by TFC » Tue Jan 13, 2004 1:49 am

We are waiting impatiently :)

raX
Lead Developer
Posts: 2237
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

#5 Post by raX » Wed Jan 14, 2004 12:56 am

0.8.5 has entered a feature freeze. Pending my ability to test it a bunch, I should release it within a week. I also might put up a beta on the board in the next day or two for courageous users to beat up.

You can also check out the CHANGELOG for 0.8.5 so far here:

http://cvs.raxnet.net/cgi-bin/viewcvs.c ... text/plain

-Ian

User avatar
TFC
Cacti Pro User
Posts: 722
Joined: Wed Apr 09, 2003 2:17 am
Location: Izmir/Turkey

#6 Post by TFC » Wed Jan 14, 2004 1:09 am

raX wrote:0.8.5 has entered a feature freeze. Pending my ability to test it a bunch, I should release it within a week. I also might put up a beta on the board in the next day or two for courageous users to beat up.

You can also check out the CHANGELOG for 0.8.5 so far here:

http://cvs.raxnet.net/cgi-bin/viewcvs.c ... text/plain

-Ian
Great! WHy dont u add percentage style in the graph template?

raX
Lead Developer
Posts: 2237
Joined: Sat Oct 13, 2001 7:00 pm
Location: Carlisle, PA
Contact:

#7 Post by raX » Thu Jan 15, 2004 11:58 pm

TFC wrote:Great! WHy dont u add percentage style in the graph template?
I typically try not to clutter the default traffic graph template with extra stuff like this. I could however create a new template that contained the percentage and include it in the data query so users can choose it when creating new traffic graphs.

-Ian

kc
Posts: 6
Joined: Thu May 27, 2004 11:17 am
Location: Atlanta, GA

How can I calculate Line speed in CDEF automatically?

#8 Post by kc » Thu May 27, 2004 8:54 pm

Hello all,
I've been playing with Cacti for about a week and it was killing me on how to get the interface speed dynamically into one CDEF to calculate percentage usage on that interface. Thanks to Bisonlux for pointing in the right direction… I have found a solution. Using the following steps you can use |query_ifSpeed| in your CDEF. See the steps below on how to accomplish this. Maybe raX will include this in his next release.

1) Edit rrd.php file and search for this string (should be line #667):

Code: Select all

$cdef_string = str_replace("ALL_DATA_SOURCES_NODUPS", $cdef_total, $cdef_string);
2) Add below a new line with this string:

Code: Select all

$cdef_string = str_replace("|query_ifSpeed|", $ifSpeed["field_value"], $cdef_string);
3) Search for this string (should be line #392):

Code: Select all

/* lets make that sql query... */
4) Above that line, add these:

Code: Select all

        $ifSpeed = db_fetch_row("select
                host_snmp_cache.field_value
                from graph_templates_graph,graph_local,host_snmp_cache
                where graph_local.id=graph_templates_graph.local_graph_id
                and graph_templates_graph.local_graph_id=$local_graph_id
                and host_snmp_cache.host_id=graph_local.host_id
                and host_snmp_cache.snmp_index=graph_local.snmp_index
                and host_snmp_cache.field_value>1000");
NOTE: "host_snmp_cache.field_value>1000" must be a number greater then 255. This is to avoid an IP address being returned for the value or any other strange values. I went with 1000 to avoid any other strange behavior.

Have fun!
-KC


(found a bug in the SQL string, the above is now correct. 5/28)

Guest

Re: How can I calculate Line speed in CDEF automatically?

#9 Post by Guest » Thu Jul 22, 2004 7:46 am

kc wrote:Hello all,
I've been playing with Cacti for about a week and it was killing me on how to get the interface speed dynamically into one CDEF to calculate percentage usage on that interface. Thanks to Bisonlux for pointing in the right direction… I have found a solution. Using the following steps you can use |query_ifSpeed| in your CDEF. See the steps below on how to accomplish this. Maybe raX will include this in his next release.

1) Edit rrd.php file and search for this string (should be line #667):

Code: Select all

$cdef_string = str_replace("ALL_DATA_SOURCES_NODUPS", $cdef_total, $cdef_string);
2) Add below a new line with this string:

Code: Select all

$cdef_string = str_replace("|query_ifSpeed|", $ifSpeed["field_value"], $cdef_string);
3) Search for this string (should be line #392):

Code: Select all

/* lets make that sql query... */
4) Above that line, add these:

Code: Select all

        $ifSpeed = db_fetch_row("select
                host_snmp_cache.field_value
                from graph_templates_graph,graph_local,host_snmp_cache
                where graph_local.id=graph_templates_graph.local_graph_id
                and graph_templates_graph.local_graph_id=$local_graph_id
                and host_snmp_cache.host_id=graph_local.host_id
                and host_snmp_cache.snmp_index=graph_local.snmp_index
                and host_snmp_cache.field_value>1000");
NOTE: "host_snmp_cache.field_value>1000" must be a number greater then 255. This is to avoid an IP address being returned for the value or any other strange values. I went with 1000 to avoid any other strange behavior.

Have fun!
-KC


(found a bug in the SQL string, the above is now correct. 5/28)

Is it possible for you to provide an example on how to use this "feature"?

Sincerely
Perseus

Guest

#10 Post by Guest » Fri Oct 08, 2004 5:43 am

w00t. I tried this method by KC and it works! Thanks KC!

btw, is there a better way to do this in the current release of cacti ? i rather not hack it if i could so all my previous graphs remains okay :)

allowing the use of those variables in CDEF is excellent!

User avatar
pshankland
Cacti User
Posts: 247
Joined: Fri Dec 31, 2004 7:07 am
Location: UK

#11 Post by pshankland » Mon Apr 25, 2005 2:32 pm

kc - Can you explain what you do after you modify rrd.php?

I have created a new CDEF called 'Percentage Bandwidth Utilisation' and included the following:

Code: Select all

Item #1:  Special Data Source: CURRENT_DATA_SOURCE
Item #2:  Custom String: |query_ifSpeed|
Item #3:  Operator: /
Item #4:  Custom String: 100
Item #5:  Operator: *
I have then modified the Graph Template I am using to include the following:

Code: Select all

Graph Item:       11
Data Source:      (traffic_out):    Traffic Out Utilisation %:
Graph Item Type:  GPRINT
CF Type:          LAST
CDEF Function:    Percentage Bandwidth Utilisation
The problem I get is that the graphs are now not getting generated :(

When I run Graph Debug Mode I get the following error:

Code: Select all

ERROR: bad format for [G]PRINT in 'Traffic Out Utilisation %:%8.2lf %s'
Anybody have any ideas?

Thanks.

Pete.

User avatar
TheWitness
Developer
Posts: 14817
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

#12 Post by TheWitness » Mon Apr 25, 2005 5:47 pm

COMMENT: Maximum Speed: |query_ifSpeed| ???

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

kc
Posts: 6
Joined: Thu May 27, 2004 11:17 am
Location: Atlanta, GA

Re: How can I calculate Line speed in CDEF automatically?

#13 Post by kc » Tue Apr 26, 2005 8:31 am

Yea… I had made some tweaks to the rrd.php file last year to make the SNMP Interface Speed a CDEF value. I had emailed Ian when I did it and never heard back from him; I'm sure he was busy with the new release. Now, every time I want to upgrade, I have to retweak the file. :)


Below is the XML of a graph template (and dependences) titled "Interface - Traffic (bits/sec) w/Bandwidth." It will accomplish this graph below. When every you want to change the bandwidth filed, just updated the router's "Bandwidth" interface statement and then do a SNMP refresh on the device and your done.

-KC
Attachments
graph_template_w-bandwidth.xml
Interface - Traffic (bits/sec) w/Bandwidth XML
(20.55 KiB) Downloaded 1223 times
graph_image.php.png
I make by Bandwidth statement the CIR of the PVC so I get a RED line when it goes over.
graph_image.php.png (4.42 KiB) Viewed 19576 times

User avatar
TheWitness
Developer
Posts: 14817
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

#14 Post by TheWitness » Tue Apr 26, 2005 4:30 pm

Whose your ISP thats letting you bust so high above CIR?

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of MacTrack, Boost, CLog, SpikeKill, Platform RTM, DSStats, maintainer of Spine, lot's of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Central Plugin Repository
Central Templates Repository


I'm still out there people. Getting excited for Cacti 1.2. I think it will be a great release.

kc
Posts: 6
Joined: Thu May 27, 2004 11:17 am
Location: Atlanta, GA

#15 Post by kc » Tue Apr 26, 2005 8:50 pm

TheWitness wrote:Whose your ISP thats letting you bust so high above CIR?

TheWitness

Bellsouth :lol:
It is a full DS3 frame-relay port with a 9Mb PVC/CIR to the Internet.

-KC

Post Reply