text-status rather than numeric-status

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
reboot3d
Posts: 15
Joined: Thu Feb 14, 2008 12:41 pm

text-status rather than numeric-status

Post by reboot3d »

Hi There!

I searched the man-pages of RRDTool, many tutorials and the forum for this topic, but couldn't found one. Maybe someone could give me a pointer, how to do this.

I've some graphs, displaying the port-status of an ethernet-device. After some cdef-transformation, the status is now displayed as value of 0 (down) and 1 (up). The "current:" Item of the graph (actually the "last"-value of the rra) also shows the numerical value.
But I'd rather displayed the status as text for this item.

I tried to convert the value through a cdef-function into text, but couldn't achive the result I hoped for. It seems, the "last"-value is displayed as numerical value only.

I know, this is more a rrd-tool related topic, but I expected some experience in this community.

best regards

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

Post by TheWitness »

Andreas,

RRDtool stores only numeric integer and float data, if you have something else to store, you will have to use a different method. If you have a string value that contains a numeric value, the parsing functions in spine and cmd.php take care of stripping the non-numieric data.

If you are attampting to do anything with string data, it's likely not used in graphing, else you should consider a data query.

Can you provide more details?

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?
reboot3d
Posts: 15
Joined: Thu Feb 14, 2008 12:41 pm

Post by reboot3d »

I don't have to collect or store string data.

It's the SNMP-Data for interface port status (Integer value). The Data is collected with numercial values of 1's (up) and 2's (down).

I created a CDEF, which transforms from the collected data by cdef=Current_Data,-1,*,2,+; [which should be cdef=-x+2]). Now the Port Status is 0 (for down) and 1 (for up). Then I created a graph-template which shows the values as a graph and the current status as numerical value:

Code: Select all

current: 1.0
This works fine, but what I want is something like:

Code: Select all

current: up
I thought this could achived by writing a cdef, which "transforms" the value to string using a "if". This value hasn't to be stored, it should be used only, for creating graphs.

I toyed something with Graph-Debug mode and rrdtool returned "invalid expression in rpn" whenever I used quoted strings. I guess there is no way to transform the data to string or change the displayed "Current:" depending on the value.
User avatar
TheWitness
Developer
Posts: 17059
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Yea, that is a problem. You really need to use a comment. However, there is presently no special function to convert RRDtool output to a comment string. We have hacks like this for other RRDtool limitation's, but now what you have described.

I would like to see if Gandolf has any suggestions.

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?
reboot3d
Posts: 15
Joined: Thu Feb 14, 2008 12:41 pm

Post by reboot3d »

Great! Thanks for your time!

If this would be a "clean" hack, I have more use for this. There are many MIB's that have numerical values for status information. E.g. for printer: toner level - "full,available,depleted".

Andreas
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

TheWitness wrote:I would like to see if Gandolf has any suggestions.
That should be me. Hmm, let's do some magic ...
Reinhard
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

reboot3d wrote:I thought this could achived by writing a cdef, which "transforms" the value to string using a "if". This value hasn't to be stored, it should be used only, for creating graphs.
Definitively NOGO. You won't get strings beyond U/NaN out of a CDEF.
Reinhard
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

reboot3d wrote:Great! Thanks for your time!

If this would be a "clean" hack, I have more use for this. There are many MIB's that have numerical values for status information. E.g. for printer: toner level - "full,available,depleted".

Andreas
Perhaps there is a way when leaving rrdtool completely out of the picture. You know, when using a Data Query, Cacti will store results from <direction>input</direction> into the poller_cache. And using |query_*| magic will allow printing at least in COMMENTs. I suppose GPRINTs won't work.
Everything said is derived from pure theory. But it may be enough to give it a try.
Reinhard
reboot3d
Posts: 15
Joined: Thu Feb 14, 2008 12:41 pm

Post by reboot3d »

gandalf wrote:Perhaps there is a way when leaving rrdtool completely out of the picture. You know, when using a Data Query, Cacti will store results from <direction>input</direction> into the poller_cache. And using |query_*| magic will allow printing at least in COMMENTs. I suppose GPRINTs won't work.
Everything said is derived from pure theory. But it may be enough to give it a try.
Reinhard
This works!

Wow, I didn't knew the |query_*| could be used elsewhere than in titles. Is this somewhere in the manual? Did I missed it?

Thanks anyway. This leaves me with some opportunities ...

Have a nice day!

Andreas
Attachments
the resulting graph
the resulting graph
graph_image.php.png (17.17 KiB) Viewed 4021 times
the items of the graph template
the items of the graph template
port_status.jpg (20.46 KiB) Viewed 4021 times
reboot3d
Posts: 15
Joined: Thu Feb 14, 2008 12:41 pm

Post by reboot3d »

Well, It's not working.

The |query_*| get it's data from the snmp-cache. So the displayed status is not the current, but the status when the cache was build. If a status-data is not in the cache, the |query_*| is displayed.

Hmm, forcing the cache to be rebuilded every 5 minutes? or giving up?

I guess, I return to my numerical values.

Greetings

Andreas
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

You would need to "rebuild the cache of this data query" by changing the re-index option to make cacti re-index quite every polling interval. That will surely add additional load. But that's the best I can achive
Reinhard
chino
Posts: 1
Joined: Wed May 09, 2007 2:13 pm

Post by chino »

reboot3d,

Not sure if this works for you, but I had to graph a status that was number based, and I did it like this.

Image

-Chino
reboot3d
Posts: 15
Joined: Thu Feb 14, 2008 12:41 pm

Post by reboot3d »

gandalf wrote:You would need to "rebuild the cache of this data query" by changing the re-index option to make cacti re-index quite every polling interval. That will surely add additional load. But that's the best I can achive
Reinhard
@gandalf

Thanks, I appreciate your help. This wouldn't work in my case either. Since I display the status in a graph, and would use the pipes |query_ifOperStatus| the ifOperStatus must be defined input and output in the XML-file, as I understand now.

Wait, this gives me an idea! I duplicate the entry with the same oid, but under a different name.

I tell you the result.

@chino

Thanks. I consider your suggestion, when I write a multiple-state monitoring .It looks quiet good. For now I have only two states, which are represented in the timeline quite well for my purposes.


Greetings

Andreas
reboot3d
Posts: 15
Joined: Thu Feb 14, 2008 12:41 pm

Post by reboot3d »

Ok, I edited the interface.xml and duplicated the <ifOperStatus> field. now it looks like this:

Code: Select all

                <ifOperStatus>
                        <name>Status</name>
                        <method>walk</method>
                        <source>value</source>
                        <direction>input</direction>
                        <oid>.1.3.6.1.2.1.2.2.1.8</oid>
                </ifOperStatus>
                <ifOperState>
                        <name>Status</name>
                        <method>walk</method>
                        <source>value</source>
                        <direction>output</direction>
                        <oid>.1.3.6.1.2.1.2.2.1.8</oid>
                </ifOperState>
The first one will be used in |query_ifOperStatus| as Comment in the graphs, and the second one will be used as graphable values. ("the timeline")

The changes in the graph template are like above, only the data template had to be changed to ifOperState as DataSource. Well, no great loss. And now I re-index all devices after the poller had run.

Thanks again to all of you!

Andreas
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

chino wrote:reboot3d,

Not sure if this works for you, but I had to graph a status that was number based, and I did it like this.

Image

-Chino
Lovely approach! Indeed, lovely!
Reinhard
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest