[rancid] patch for Nexus 9000 'show environment power'
heasley
heas at shrubbery.net
Wed Jun 21 18:38:10 UTC 2017
Tue, Jun 20, 2017 at 10:00:02AM +0100, Howard Jones:
> On N9K (our 9508 at least), the current power usage has decimal places.
>
> !Env: Xb26 N9K-C9508-FM 119.00 W 250.80 W Powered-Up
> !Env: 27 N9K-SUP-B 76.00 W 79.92 W Powered-Up
> !Env: 28 N9K-SUP-B 58.00 W 79.92 W Powered-Up
> !Env: 29 N9K-SC-A 12.00 W 25.20 W Powered-Up
> !Env: 30 N9K-SC-A 12.00 W 25.20 W Powered-Up
>
> I only changed the two-value clause below, since that's the one that
> fixed my issue.
>
> --- nxos.pm-dist 2017-06-20 09:52:44.627985639 +0100
> +++ nxos.pm 2017-06-20 09:53:37.712598200 +0100
> @@ -468,7 +468,7 @@
> # nexus#
> if (/(.* +)(\d+ W +\d+ W)( +\d+ W.+)/) {
> $_ = sprintf("%s%-". length($2)."s%s\n", $1, "", $3);
> - } elsif (/(.* +)(\d+ W)( +\d+ W.+)/) {
> + } elsif (/(.* +)(\d+\.?\d* W)( +\d+\.?\d* W.+)/) {
> $_ = sprintf("%s%-". length($2)."s%s\n", $1, "", $3);
> }
>
afaict, it is not consistent, perhaps by o/s version. Perhaps this
instead?
Index: lib/nxos.pm.in
===================================================================
--- lib/nxos.pm.in (revision 3660)
+++ lib/nxos.pm.in (working copy)
@@ -421,8 +421,8 @@
# nexus#
if (/(.* +)(\d+ W +\d+ W)( +\d+ W.+)/) {
$_ = sprintf("%s%-". length($2)."s%s\n", $1, "", $3);
- } elsif (/(.* +)(\d+ W)( +\d+ W.+)/) {
- $_ = sprintf("%s%-". length($2)."s%s\n", $1, "", $3);
+ } elsif (/(.* +)(\d+(\.\d+)? W)( +\d+(\.\d+)? W.+)/) {
+ $_ = sprintf("%s%-". length($2)."s%s\n", $1, "", $4);
}
/actual draw/ && next; # Drop changing total power output.
Does that work?
More information about the Rancid-discuss
mailing list