[rancid] [PATCH] nxrancid ShowEnvPower oscillating
Zenon Mousmoulas
zmousm at noc.grnet.gr
Fri Jun 15 14:57:46 UTC 2012
On Fri, 15 Jun 2012 09:52:20 -0400, John Jetmore <jj33 at pobox.com> wrote:
> [...]
> Here is my version of your patch which solves all of the issues:
> 1) prevents line oscillation when the number of figits in the actual
> draw changes
> 2) stricter regexp, should only parse the line as we expect.
> 3) fixes alignment so all "show env power" output columns match
>
> ######################
> --- nxrancid-238-dist 2012-06-14 09:10:26.000000000 -0500
> +++ nxrancid-238-jetmore-2 2012-06-15 08:40:29.000000000 -0500
> @@ -379,8 +379,10 @@
> s/ \(Watts \) / /;
> s/ Draw / /;
> s/ ----------- / /;
> - s/ N\/A / / ||
> - s/ \d+ W / /; # Does not chop enough to line up.
> + s/ N\/A / /;
> + if (/(.*?)(\s+\d+ W)( +\d+ W.*)/) {
> + $_ = sprintf("%s%-".(length($2)-11)."s%s\n", $1, "",
$3);
> + }
>
> /actual draw/ && next; # Drop changing total power output.
> ##########################
In my approach I also trimmed the whitespace after this column (11+2=13
chars). Other than that, LGTM.
That is, until Cisco changes the width of this column ;)
Thanks,
Z.
More information about the Rancid-discuss
mailing list