[rancid] [PATCH] nxrancid ShowEnvPower oscillating

John Jetmore jj33 at pobox.com
Thu Jun 14 16:37:15 UTC 2012


On Wed, Jun 6, 2012 at 5:42 AM, Zenon Mousmoulas <zmousm at noc.grnet.gr> wrote:
> Hi,
>
> ShowEnvPower in nxrancid tries to filter actual power/draw from the
> output, but (as noted in a comment) it does not always chop enough for the
> text to line up. Therefore nxrancid output oscillates when the power draw
> of some module(s), as reported by "show environment power", switches
> between 3-digit and 4-digit wattage. For example:
>
> --- group/configs/n7k-device    2012/06/04 23:18:42     7973
> +++ group/configs/n7k-device    2012/06/05 02:18:43     7974
> @@ -192,7 +192,7 @@
>  !Env: 4        N7K-M148GS-11L                     400 W    Powered-Up
>  !Env: 5        N7K-SUP1                     210 W    Powered-Up
>  !Env: 6        N7K-SUP1                     210 W    Powered-Up
> -!Env: 7        N7K-M132XP-12L                   750 W    Powered-Up
> +!Env: 7        N7K-M132XP-12L                     750 W    Powered-Up
>  !Env: Xb1      N7K-C7010-FAB-1               80 W    Powered-Up
>  !Env: Xb2      N7K-C7010-FAB-1               80 W    Powered-Up
>  !Env: Xb3      N7K-C7010-FAB-1               80 W    Powered-Up
>
> The following patch tries to stop this. Fixed width parsing works with
> NX-OS 6.0, I could not run this against other (previous) versions but it
> should be the same -- I hope someone on the list can test it.
>
> Best regards,
> Zenon Mousmoulas
> ---
>
> diff -ru rancid-2.3.8/bin/nxrancid.in rancid-2.3.8-zmousm/bin/nxrancid.in
> --- rancid-2.3.8/bin/nxrancid.in        2011-07-29 23:40:40.000000000 +0300
> +++ rancid-2.3.8-zmousm/bin/nxrancid.in 2012-06-06 11:56:59.000000000
> +0300
> @@ -374,13 +374,16 @@
>  #-------  -------------------  -----------  -----------  --------------
>  #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 (/Actual +Total/ ||
> +           /Actual +Power/ ||
> +           /Draw +Allocated/ ||
> +           /Output +Capacity/ ||
> +           /(\(Watts \)) +\g{-1}/ ||
> +           /(-----------) +\g{-1}/ ||
> +           /(\d+ W|N\/A) +\d+ W/) {
> +           substr $_, 30, 13, "";
> +       }
>
>        /actual draw/ && next;  # Drop changing total power output.

Zenon, thanks for reporting this.  I just started looking at a similar
issue on an NX-OS 5 machine, it was great to find your problem report
and patch.  I ended up using a slightly smaller fix which is working
well for me:

#########################
--- nxrancid-238-dist   2012-06-14 10:58:55.000000000 -0500
+++ nxrancid-238-local  2012-06-14 11:00:00.000000000 -0500
@@ -380,7 +380,7 @@
        s/        Draw /  /;
        s/ ----------- /  /;
        s/        N\/A  /  / ||
-       s/ \d+ W /  /;          # Does not chop enough to line up.
+       s/ [ \d]{9} W /  /;             # Does not chop enough to line
up. (does now)

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

###########################

I didn't feel comfortable that the substr() solution wouldn't cause
other problems (for instance, unexpectedly long module or model names
making the column 30 starting point incorrect).  My solution isn't
perfect, but it feels slightly safer to me.

Thanks
--John


More information about the Rancid-discuss mailing list