#!/bin/bash temps=`nc $1 7634 |sed -e "s#||#\n#g" |sed -e "s#|# #g" |sed -e "s#/dev/##g" |sed -e "s# Maxtor##" |sed -e "s# WDC##" |awk '{print $1, $3}'` numdisks=`echo "$temps" |wc -l` tempsnumbers=`echo $temps |awk '{print $2}'` intotal=`echo $temps |sed -e "s#hd[a-z]\ ##g" |sed -e "s#sd[a-z]\ ##g" |sed "s/\ /\+/g" |bc` avg=`echo $intotal/$numdisks |bc` high=`echo "$temps" |awk {'print $2'} |sort -r |head -n1` low=`echo "$temps" |awk {'print $2'} |sort |head -n1` #echo "highest:" $high #echo "lowest:" $low #echo "avg:" $avg #echo "intotal:" $intotal #echo "tempsnumbers:" $tempsnumbers #echo $temps if [ $high -le "$2" ]; then echo "DISKTEMP OK - highest: "$high"C - lowest: "$low"C - avg: "$avg"C (num. disks: $numdisks)" ; exit 0 ; fi if [ $high -ge "$2" ]; then echo "DISKTEMP WARNING - highest: "$high"C - lowest: "$low"C - avg: "$avg"C (num. disks: $numdisks)" ; exit 2 ; fi