Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


text-status rather than numeric-status

 
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates
Author Message
reboot3d



Joined: 14 Feb 2008
Posts: 15

PostPosted: Wed Apr 02, 2008 2:35 am    Post subject: text-status rather than numeric-status Reply with quote

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
Back to top
TheWitness
Developer


Joined: 14 May 2002
Posts: 9691
Location: MI, USA

PostPosted: Wed Apr 02, 2008 4:55 am    Post subject: Reply with quote

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
Back to top
reboot3d



Joined: 14 Feb 2008
Posts: 15

PostPosted: Wed Apr 02, 2008 6:06 am    Post subject: Reply with quote

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:
current: 1.0


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

Code:
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.
Back to top
TheWitness
Developer


Joined: 14 May 2002
Posts: 9691
Location: MI, USA

PostPosted: Wed Apr 02, 2008 6:11 am    Post subject: Reply with quote

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
Back to top
reboot3d



Joined: 14 Feb 2008
Posts: 15

PostPosted: Wed Apr 02, 2008 6:23 am    Post subject: Reply with quote

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
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12275
Location: Muenster, Germany

PostPosted: Thu Apr 03, 2008 1:51 pm    Post subject: Reply with quote

TheWitness wrote:
I would like to see if Gandolf has any suggestions.
That should be me. Hmm, let's do some magic ...
Reinhard
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12275
Location: Muenster, Germany

PostPosted: Thu Apr 03, 2008 1:52 pm    Post subject: Reply with quote

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
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12275
Location: Muenster, Germany

PostPosted: Thu Apr 03, 2008 1:56 pm    Post subject: Reply with quote

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
Back to top
reboot3d



Joined: 14 Feb 2008
Posts: 15

PostPosted: Fri Apr 04, 2008 8:38 am    Post subject: Reply with quote

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



port_status.jpg
 Description:
the items of the graph template
 Filesize:  20.46 KB
 Viewed:  1135 Time(s)

port_status.jpg



graph_image.php.png
 Description:
the resulting graph
 Filesize:  17.17 KB
 Viewed:  1135 Time(s)

graph_image.php.png


Back to top
reboot3d



Joined: 14 Feb 2008
Posts: 15

PostPosted: Fri Apr 04, 2008 10:28 am    Post subject: Reply with quote

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
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12275
Location: Muenster, Germany

PostPosted: Sat Apr 05, 2008 6:11 am    Post subject: Reply with quote

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
Back to top
chino



Joined: 09 May 2007
Posts: 1

PostPosted: Mon Apr 07, 2008 12:35 pm    Post subject: Reply with quote

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.



-Chino
Back to top
reboot3d



Joined: 14 Feb 2008
Posts: 15

PostPosted: Tue Apr 08, 2008 7:46 am    Post subject: Reply with quote

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
Back to top
reboot3d



Joined: 14 Feb 2008
Posts: 15

PostPosted: Tue Apr 08, 2008 8:13 am    Post subject: Reply with quote

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

                <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
Back to top
gandalf
Developer


Joined: 02 Dec 2004
Posts: 12275
Location: Muenster, Germany

PostPosted: Wed Apr 09, 2008 12:32 pm    Post subject: Reply with quote

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.



-Chino
Lovely approach! Indeed, lovely!
Reinhard
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Scripts and Templates All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group