| #!/bin/sh |
| |
| |
| # First try SCT Status, which only ties up the SATA bus |
| # for 1.5 msec. |
| temperature=$( |
| smartctl -l scttempsts $1 2>/dev/null | { |
| while IFS=":" read text temperature junk; do |
| if [ "$text" = "Current Temperature" ]; then |
| # trim " 55 Celsius" down to just "55". |
| echo "$temperature" | { IFS=" " read temp junk; echo "$temp"; } |
| fi |
| done; |
| } |
| ) |
| if [ -n "$temperature" ]; then |
| echo "$temperature" |
| exit 0 |
| fi |
| |
| # Fall back to SENSE CONDITION, which ties up the bus for 188 msec. |
| temperature=$( |
| hdparm -H $1 2>/dev/null | { |
| while IFS=":" read text temperature junk; do |
| if [ "${text#*celsius}" != "$text" ]; then |
| # trim " 55" down to just "55". |
| echo "$temperature" | { IFS=" " read temp junk; echo "$temp"; } |
| fi |
| done; |
| } |
| ) |
| if [ -n "$temperature" ]; then |
| echo "$temperature" |
| exit 0 |
| fi |
| |
| exit 1 |