Apply mathematical operations to |query...| ?
Moderators: Developers, Moderators
Apply mathematical operations to |query...| ?
I'm displaying a piece of data that's being gathered in an SNMP walk as part of a data query as "input" (ungraphed) data. I'm attaching it to a graph template as a 'COMMENT' using a '|query|', but the appropriate method for applying mathematical operations to the figure is eluding me. In this case, I'm pulling a numerical value from the query and I'd like to divide that value by ten. It seems I'm either missing something embarassingly simple, or it just can't be done in 'COMMENT' statements (or) can only be done with "output" data. Help..? ;b
Hi Frances,
I'm trying to do something similar - I want to graph my traffic in/out for my router interfaces (which isn't a problem) and I've created a comment that tells the link speed (which also isn't a problem.)
However, the graphs I'm creating I want to use bytes, not bits, so I want to convert the ifSpeed value to bytes instead of bits .......
So I get a COMMENT of "Link speed: 32KB/s"
I'm trying to do something similar - I want to graph my traffic in/out for my router interfaces (which isn't a problem) and I've created a comment that tells the link speed (which also isn't a problem.)
However, the graphs I'm creating I want to use bytes, not bits, so I want to convert the ifSpeed value to bytes instead of bits .......
So I get a COMMENT of "Link speed: 32KB/s"
-
- Posts: 14
- Joined: Tue Dec 14, 2004 9:54 am
Hmm... If I recall correctly, I tried to use a CDEF for this, but wasn't able to get a CDEF to apply to "input" data. The trick is, the OID for this piece of data is found via a query, but the data is not expected to change once found, so I'm grabbing it as "input" rather than "output" data in the query. I could grab it as "output" data, but I don't have need to graph it, I just want it displayed.
- TheWitness
- Developer
- Posts: 17047
- Joined: Tue May 14, 2002 5:08 pm
- Location: MI, USA
- Contact:
I am contemplating a patch to support the parsing of |query_...| in both COMMENTS and HRULE/VRULE before I return to work on July 18th. I will be out of town until July the 9th however.
TheWitness
TheWitness
True understanding begins only when we realize how little we truly understand...
Life is an adventure, let yours begin with Cacti!
Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages
For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
Life is an adventure, let yours begin with Cacti!
Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages
For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
-
- Posts: 5
- Joined: Tue Dec 19, 2006 12:13 pm
This worked for me
I was having the same problem, wanting to change the ifSpeed to Mbps.
I was getting "ERROR: rpn expressions without DEF or CDEF variables are not supported" if I did:
cdef=|query_ifSpeed|,1000000,/
Here's the CDEF I came up with:
cdef=CURRENT_DATA_SOURCE,CURRENT_DATA_SOURCE,-,|query_ifSpeed|,+,1000000,/
I take the current data and subract it from itself and add the result (which is 0) to the value returned by the query.
Works quite well.
Scott
I was getting "ERROR: rpn expressions without DEF or CDEF variables are not supported" if I did:
cdef=|query_ifSpeed|,1000000,/
Here's the CDEF I came up with:
cdef=CURRENT_DATA_SOURCE,CURRENT_DATA_SOURCE,-,|query_ifSpeed|,+,1000000,/
I take the current data and subract it from itself and add the result (which is 0) to the value returned by the query.
Works quite well.
Scott
- gandalf
- Developer
- Posts: 22383
- Joined: Thu Dec 02, 2004 2:46 am
- Location: Muenster, Germany
- Contact:
Re: This worked for me
Yep, ok. Reason for this is, that each CDEF must reference some DEF. Another approach may beinterweave wrote:cdef=CURRENT_DATA_SOURCE,CURRENT_DATA_SOURCE,-,|query_ifSpeed|,+,1000000,/
Code: Select all
cdef=CURRENT_DATA_SOURCE,POP,|query_ifSpeed|,+,1000000,/
Reinhard
-
- Posts: 5
- Joined: Tue Dec 19, 2006 12:13 pm
I like yours better!
Thanks Reinhard! I like your version better!
Scott
Scott
Who is online
Users browsing this forum: No registered users and 5 guests