Environmental information, for example temperature, fan speed, etc., provide critical information about the health of your clustered Data ONTAP system. Depending on your version of ONTAP, you can query the environmental information different ways to find out the status.
With ZAPI version 1.21 and above (cDOT 8.2.3+) the environment-sensors-get-iter
API exists, which makes it excessively easy to collect environmental information about the controllers. We can take the same approach with environmental sensors as performance information:
Querying ZAPI Directly
Using the Invoke-NcSystemApi
cmdlet we can execute ZAPI directly. Don’t be intimidated by this, it’s quite easy! To view all of the sensor data, we can execute the Invoke-NcSystemApi
cmdlet. Because the API is an iter
it means that there is the potential for not all of the results to be returned at once, so we must iterate over the API until all of them are returned. The cluster knows where to start by using the “next-tag” item:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
$sensors = Invoke-NcSystemApi '' $result = $sensors.results.'attributes-list'.'environment-sensors-info' while ($true) { if ($sensors.results.'next-tag') { $tag = $sensors.results.Item('next-tag').InnerXml $sensors = Invoke-NcSystemApi "$($tag)" $result += $sensors.results.'attributes-list'.'environment-sensors-info' } else { break } } |
The $result
variable now contains an array of XML objects with the results. PowerShell conveniently turns the ZAPI response (which is XML) into an object which can be accessed using the traditional dot notation. To view the returned data:
1 |
$result |
Which shows us a long list (depending on how many controllers you have). Here is a snippet from my cluster:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
discrete-sensor-state : normal discrete-sensor-value : GOOD node-name : VICE-01 sensor-name : PSU2 sensor-type : fru threshold-sensor-state : normal discrete-sensor-state : normal discrete-sensor-value : GOOD node-name : VICE-01 sensor-name : PSU1 sensor-type : fru threshold-sensor-state : normal discrete-sensor-state : normal discrete-sensor-value : GOOD node-name : VICE-01 sensor-name : Fan3 sensor-type : fru threshold-sensor-state : normal |
Finding the Desired Sensor(s)
Much like with performance reporting, there are three levels of detail:
- Sensor Type
- Sensor Name
- Sensor Value(s)
To show the list of all the different sensor types we first query the API, as above, then we find all the unique sensor types:
1 |
$result.'sensor-type' | Sort-Object | Get-Unique |
This results in eight different sensors returned from my system.
1 2 3 4 5 6 7 8 |
battery_life counter current discrete fan fru thermal voltage |
For the full list we can simply look to the documentation:
- “fan” – FAN RPM sensors
- “thermal” – Temerature sensors
- “voltage” – Voltage measurement sensors
- “current” – Current measurement sensors
- “battery-life” – Sensors report battery life
- “discrete” – Discrete sensors
- “fru” – FRU sensors
- “nvmem” – Sensors on the NVMEM module
- “counter” – Sensors report in counters
- “minutes” – Sensors report by minutes
- “percent” – Sensors report in percentage
- “agent” – Sensors on or throught the Agent device
- “unknown” – Unknown sensors
Going down to the next level, we want to find the sensor names for each type. Let’s look at an example using the thermal type:
1 |
($result | ?{ $_.'sensor-type' -eq "thermal" }).'sensor-name' | Sort-Object | Get-Unique |
The sensor type thermal
has 14 sensors:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
Bat Temp CPU0 Temp Margin CPU1 Temp Margin In Flow Temp IO Mid1 Temp IO Mid2 Temp LM56 Temp NVMEM Bat Temp Out Flow Temp PCI Riser_R Temp PCI Slot Temp PSU1 Temp PSU2 Temp Smart Bat Temp |
And, finally, we can get the value(s) we’re interested in:
1 2 3 |
$result | ?{ $_.'sensor-type' -eq "thermal" -and $_.'sensor-name' -eq "In Flow Temp" } | Select-Object 'node-name','threshold-sensor-value','threshold-sensor-state' |
Making It Better
Putting it all together we get this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
$sensors = Invoke-NcSystemApi '' $result = $sensors.results.'attributes-list'.'environment-sensors-info' while ($true) { if ($sensors.results.'next-tag') { $tag = $sensors.results.Item('next-tag').InnerXml $sensors = Invoke-NcSystemApi "$($tag)" $result += $sensors.results.'attributes-list'.'environment-sensors-info' } else { break } } $result | ?{ $_.'sensor-type' -eq "thermal" -and $_.'sensor-name' -eq "In Flow Temp" } | Select 'node-name','threshold-sensor-value','value-units','threshold-sensor-state' |
The result, for my cluster, looks like this:
1 2 3 4 5 6 7 8 9 10 |
node-name threshold-sensor-value value-units threshold-sensor-state --------- ---------------------- ----------- ---------------------- VICE-01 30 C normal VICE-02 28 C normal VICE-03 27 C normal VICE-04 28 C normal VICE-05 28 C normal VICE-06 29 C normal VICE-07 30 C normal VICE-08 29 C normal |
Of course, this is all terribly inefficient since it collects all of the sensor information for each query…about 100 per node. We can narrow down the scope of each query using the API which will make things much faster. For example, we can limit the the sensor type and sensor name by modifying the ZAPI appropriately.
1 2 3 4 5 6 7 8 9 |
$sensors = Invoke-NcSystemApi ' thermal In Flow Temp ' $result = $sensors.results.'attributes-list'.'environment-sensors-info' $result | Select 'node-name','threshold-sensor-value','value-units','threshold-sensor-state' |
This results in a much faster call (about 2 seconds vs 12 seconds), and a lot less PowerShell for filtering out unwanted objects. The result is exactly the same as above, but only those 8 results are returned instead of the original 790, which means we don’t have to work as hard for the iteration either.
Please reach out to me using the comments below or the NetApp Community site with any questions about how to collect environmental information from your systems.
Hello All,
I am looking for disk failured report daily bases. any one have powershell scriipt with and netapp toolkit API