Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Fri May 26, 2017 5:57 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: 'rewrite_value' syntax for captured groups?
PostPosted: Fri Jan 27, 2012 8:41 am 
Offline

Joined: Mon Dec 05, 2011 11:45 am
Posts: 24
Hello,

I'm running cacti 0.8.7i with the patches in mantis bug #0002149 to provide the 'rewrite_value' function (which I gather is in cacti 0.8.8 ).
It seems the syntax for rewrite_value is the same as PHP's 'serialize' function (which I know nothing about), but has an example in the docs (http://docs.cacti.net/manual:088:3a_advanced_topics.3_data_queries). I have managed to dig out the basic syntax, but have hit a problem.

An SNMP OID returns a (multi-word) string value, which typically ends in the word 'temperature'. What I wanted to do was use rewrite_value to remove that word from the value returned to cacti.
So, for example, 'module 5 outlet temperature' => 'module 5 outlet'. With regular expressions I would basically do '^(.*) temperature$' and then pass that captured group as the value. However, I have no idea what the syntax is in rewrite_value for captured groups :(

Can anyone provide any help with this please?


Top
 Profile  
 
 Post subject: Re: 'rewrite_value' syntax for captured groups?
PostPosted: Tue Mar 25, 2014 2:47 am 
Offline

Joined: Tue Mar 25, 2014 2:38 am
Posts: 2
Late reply, but maybe useful for others too. For your use case, I would look at using
<source>VALUE/REGEXP:</source>
instead of <rewrite_value>. VALUE/REGEXP parses the returned value and only returns the part of the value you're interested in.

For example like this:
<source>VALUE/REGEXP:^(.*) [a-zA-Z]+$</source>
to catch everything except the last word.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group