haussli / rancid

RANCiD
Other
114 stars 42 forks source link

nxos.pm reports current fan speed of device #20

Open JamesW-AU opened 3 years ago

JamesW-AU commented 3 years ago

I added some Cisco MDS devices running NX-OS and noticed when it runs "show environment fan" it dumps the current fan (or fans) speed, causing a diff on every run.

After some testing I've added the below to sub ShowEnv, and although it isn't as neat as the process in ShowEnvTemp it seems to work.

        if (/(fan speed)/i) {
            ProcessHistory("COMMENTS","","","!Env: $_");
            while (<$INPUT>) {
                tr/\015//d;
                goto EndShowEnv if (/^$prompt/);
                if (/(^ChassisFan)(.*)(\d\d\d\d\s\s[-]\s\s\d\d\d\d)/) {
                   $_ = sprintf("%s%-". length($2)."s%s\n", $1, $2, "");
                }
                ProcessHistory("COMMENTS","","","!Env: $_");
                last if (/^\s*$/);
            }
            next;
        }

Perhaps someone who is more skilled than me could take this and do it more cleanly? ShowEnvTemp removes the unused column text (CurTemp), although I'm not sure how.

JamesW-AU commented 3 years ago

Output from device:

Cisco# show env fan
Fan:
-----------------------------------------------------------------------------------------------------------------
Fan             Model                Hw         Status        Airflow direction        Fan Speed[Fan0-Fan1] (rpm)
-----------------------------------------------------------------------------------------------------------------
ChassisFan1     FAN Module 1         --         Ok              Back to Front               7077  -  5268      
ChassisFan2     FAN Module 2         --         Ok              Back to Front               7133  -  5351      
ChassisFan3     FAN Module 3         --         Ok              Back to Front               7142  -  5335      
ChassisFan4     FAN Module 4         --         Ok              Back to Front               7124  -  5278      
Fan_in_PS1      --                   --         Ok              Back to Front                   --
Fan_in_PS2      --                   --         Ok              Back to Front                   --
Fan Air Filter : NotSupported