Data Query - VALUE/MATH addition to source type

Anything that you think should be in Cacti.

Moderators: Developers, Moderators

Post Reply
llow
Cacti User
Posts: 170
Joined: Fri Oct 05, 2007 5:34 pm

Data Query - VALUE/MATH addition to source type

Post by llow »

It would be nice to be able to do math operations on values from data queries. I have attached a patch to 0.8.6j that adds this functionality.

Usage: VALUE/MATH:<math operations>

Example: VALUE/MATH:/1000 will take the value from the snmp query and divide it by 1000

I am using eval which may not be the best idea.
Attachments
cacti-0.8.6j-data_query_value_math.patch
cacti-0.8.6j-data_query_value_math.patch
(1.25 KiB) Downloaded 294 times
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Thank you for your effort.
I'd like to ask a question without having digged deeper into your code:
Did you already consider using a CDEF for calculations? If, why doesn't it fit?
And did you even consider using a COMPUTE data source? That's a feature of rrdtool 1.2.x not yet supported by cacti (but hopefully will be implemented soon).
Reinhard
llow
Cacti User
Posts: 170
Joined: Fri Oct 05, 2007 5:34 pm

Post by llow »

The reason for this addition is for input data, not output. I was polling the voltage from a Cisco device and getting the Low and High threshold. These values are in minivolts but I want to display them in volts.

Without wasting resources storing these values in an RRD file I just made them input values and created HRULEs. Since you can't perform a CDEF without a data source that would not work.

I have not found any good information in the RRDTool docs about COMPUTE but I don't believe it would fit what I needed in this scenario.

I will also be looking into allowing variables in the upper and lower limits of the graph template so that I can be sure the HRULEs show.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please have a look at the changelog of 087. If I remember correctly, CDEFs are allowed with GPRINTs, then
Reinhard
llow
Cacti User
Posts: 170
Joined: Fri Oct 05, 2007 5:34 pm

Post by llow »

RRDTool 1.2.23 won't allow a CDEF with just values though. Storing a single unchanging value in the RRD file seems like a waste.
llow
Cacti User
Posts: 170
Joined: Fri Oct 05, 2007 5:34 pm

Post by llow »

Fixed the patch so that it splits a value description from its value to do the math.

This patch will also apply against beta4 of 0.8.7.
Attachments
cacti-0.8.6j-data_query_value_math_v2.patch
(1.3 KiB) Downloaded 316 times
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests