Quantcast
Channel: THWACK: Message List
Viewing all articles
Browse latest Browse all 20625

Re: anyone who can parse below text with powershell.

$
0
0

see the following script it is right or not plz

I tested this script for nexus 3048 when we want to find the Fan status is ok.

then export the result to the file

 

========SCRPT===========

$orgtxt = @"

Fan:

------------------------------------------------------

Fan             Model                Hw         Status

------------------------------------------------------

Chassis-1       N3K-C3048-FAN-B      --         ok

PS-1            N2200-PAC-400W-B     --         ok

PS-2            N2200-PAC-400W-B     --         ok

Temperature

-----------------------------------------------------------------

Module   Sensor     MajorThresh   MinorThres   CurTemp     Status

                    (Celsius)     (Celsius)    (Celsius)        

-----------------------------------------------------------------

1         D0        66            52           46          ok            

1         D1        65            51           40          ok            

1         D2        63            49           38          ok            

1         D3        61            47           37          ok            

Power Supply:

Voltage: 12 Volts

-----------------------------------------------------------

PS  Model                Input Power       Current   Status

                         Type  (Watts)     (Amps)         

-----------------------------------------------------------

1   N2200-PAC-400W-B     AC     396.00     33.00     ok                 

2   N2200-PAC-400W-B     AC     396.00     33.00     ok                 

Mod Model                   Power     Current     Power     Current     Status

                            Requested Requested   Allocated Allocated        

                            (Watts)   (Amps)      (Watts)   (Amps)             

--- ----------------------  -------   ----------  --------- ----------  ----------

1    N3K-C3048TP-1GE-SUP    349.20    29.10       349.20    29.10       powered-up

Power Usage Summary:

--------------------

Power Supply redundancy mode:                 Redundant

Power Supply redundancy operational mode:     Redundant

Total Power Capacity                              792.00 W

Power reserved for Supervisor(s)                  349.20 W

Power currently used by Modules                     0.00 W

                                                -------------

Total Power Available                             442.00 W

                                                -------------

"@

 

 

$orgtxt = $orgtxt -split ("`r`n")

 

 

$lines = @()

foreach ($line in $orgtxt) {

    switch -wildcard ($line)

    {

        "*Chassis-1*" {$A += $line.Substring(48,2)}

    }

    switch -wildcard ($line)

    {

        "*PS-1*" {$B += $line.Substring(48,2)}

    }

}   

 

$A

$B


Viewing all articles
Browse latest Browse all 20625

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>