[rancid] How to remove fan speed from f5rancid output?

Alan McKinnon alan.mckinnon at gmail.com
Wed Jul 8 07:11:57 UTC 2015


On 08/07/2015 01:14, Matt Almgren wrote:
> Well, I had thought I had fixed this, but it was just not running for
> our f5s for a while.  Oopps.
> 
> Anyway, my perl-fu isn’t very good.  Can someone quickly tell me what I
> need to change in this code to remove the fan speed(rpm) values from the
> output below:
> 
> 
> ## $Id: f5rancid.in 2279 2011-01-31 22:41:00Z heas $
> 
> sub ShowHardware {
>     print STDERR "    In ShowHardware: $_" if ($debug);
> 
>     while (<INPUT>) {
>         tr/\015//d;
>         last if (/^$prompt/);
>         next if (/^(\s*|\s*$cmd\s*)$/);
>         return(1) if /^\s*\^\s*$/;
>         return(1) if /(Invalid input detected|Type help or )/;
>         return(-1) if (/command authorization failed/i);
> 
>         s/\d+rpm//ig;
>         s/^\|//;
>         s/^\ \ ([0-9]+)(\ +).*up.*[0-9]/  $1$2up REMOVED/i;
             ^^^^         ^^

This is the code that is intended to do what you want.
But there's no need to escape the spaces in that regex.
Replace with literal spaces, or preferrably \s for any whitespace:

          s/^\s+([0-9]+)(\s+).*up.*[0-9]/  $1$2up REMOVED/i;


Tweak and adjust it to your liking depending on what you want the output
line to be transformed into.

You don't need much perl-fu for this, you do however need quite a bit of
regex-fu. The Llama Book (google it) has very good perl regex tutorials
at just the right level to get you going.


Alan




-- 
Alan McKinnon
alan.mckinnon at gmail.com



More information about the Rancid-discuss mailing list