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

Matt Almgren matta at surveymonkey.com
Wed Jul 8 16:21:09 UTC 2015

Thanks Alan for the tip.

I used regexr.com to help with this.  Man, I wish this site was around 10 years ago when I was writing regexps on a daily basis.  I had forgotten most of it.

This looks like it will work just fine:

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

Thanks, Matt

From: Alan McKinnon <alan.mckinnon at gmail.com<mailto:alan.mckinnon at gmail.com>>
Date: Wednesday, July 8, 2015 at 12:11 AM
To: "rancid-discuss at shrubbery.net<mailto:rancid-discuss at shrubbery.net>" <rancid-discuss at shrubbery.net<mailto:rancid-discuss at shrubbery.net>>
Subject: Re: [rancid] How to remove fan speed from f5rancid output?

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>) {
         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/^\ \ ([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 McKinnon
alan.mckinnon at gmail.com<mailto:alan.mckinnon at gmail.com>

Rancid-discuss mailing list
Rancid-discuss at shrubbery.net<mailto:Rancid-discuss at shrubbery.net>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.shrubbery.net/pipermail/rancid-discuss/attachments/20150708/d07f2a7a/attachment.html>

More information about the Rancid-discuss mailing list