[rancid] [PATCH] nxrancid ShowEnvPower oscillating

John Jetmore jj33 at pobox.com
Fri Jun 15 18:39:26 UTC 2012


On Fri, Jun 15, 2012 at 12:00 PM, heasley <heas at shrubbery.net> wrote:
> your patch isnt complete; mine removed all the filters to remove the
> column and just blanked the data.  so the column remains and there is
> no issue with alignment.  but, your regex is correct including that
> WS, so in my method
>
>> +       if (/(.*) +(\d+ W)( +\d+ W.*)/) {
> becomes
> +       if (/(.* +)(\d+ W)( +\d+ W.*)/) {

It wasn't clear to me what you were doing because your diff wasn't
against the 2.3.8 code, but I now understand what you are saying.
Sounds like a fine solution to me, and I'm glad my response helped a
little.  Looking forward to seeing it in the next release.

For the record, here's what I actually tested locally:

#############################
--- nxrancid-238-dist   2012-06-14 09:10:26.000000000 -0500
+++ nxrancid-238-heasley-2      2012-06-15 13:37:27.000000000 -0500
@@ -374,13 +374,9 @@
 #-------  -------------------  -----------  -----------  --------------
 #2        NURBURGRING                N/A          573 W    Powered-Up
 #fan1                                N/A          720 W    Powered-Up
-       s/      Actual /  /;
-       s/      Output /  /;
-       s/    \(Watts \) /  /;
-       s/        Draw /  /;
-       s/ ----------- /  /;
-       s/        N\/A  /  / ||
-       s/ \d+ W /  /;          # Does not chop enough to line up.
+       if (/(.* +)(\d+ W)( +\d+ W.*)/) {
+               $_ = sprintf("%s%-".length($2)."s%s\n", $1, "", $3);
+       }

        /actual draw/ && next;  # Drop changing total power output.
########################

And example output (which lines up properly in monospace font):

!Env: Xb4      xbar                       N/A           60 W    Absent
!Env: Xb5      xbar                       N/A           60 W    Absent
!Env: fan1     N7K-C7010-FAN-S                         720 W    Powered-Up
!Env: fan2     N7K-C7010-FAN-S                         720 W    Powered-Up


Thanks
--John


More information about the Rancid-discuss mailing list