gather uptime of mulitipule machines

Below is a script that I put together to log into multipliable machines via ssh to grab the uptime of the machine. In this situation the machines are all Solaris of either 8,9,10. There is no reason that this script or any other script that I write can not be used on linux or any other *NIX with out a tiny bit of modification. I try to put plenty of comments into my scripts so they are easy to understand.

# Written By: BAB
#Purpose: To gather the uptime from Unix machiens and present it in a readable fashion in order of uptime
#This is to be run from one central machine becuase that is where the ssh keys are set up from
#Prerequisites: ssh, sort, echo, nawk
#Files Used:uptime-before, and uptime-sorted. uptime-before is where all the machine names and uptime is stored before they are sorted and up in uptime-sorted
#Example Output: machine_name uptime, each on new line starting with shortest uptime, machines with <24 hours can show up not in their proper location because 17 hours is greater then 12 days!


echo “” > uptime-before

echo “Starting to gather uptime”

#add additional files with machine names to the end of the cat command below. The files should have one machine name (host name translatable via DNS) per a line
for server in `cat /opt/scripts/sudo/sudoserver_list /opt/scripts/sudo/stagingserver_list /opt/scripts/sudo/non_sudo_server`
uptime=`ssh root@$server uptime | nawk ‘{print $3}’ `

echo “$server $uptime” >> uptime-before
echo “done getting uptime”

echo “$DATE” > uptime-sorted
sort -u uptime-before | sort +1 -n >> uptime-sorted

mailx -s “Weekly uptime report” < /opt/scripts/uptime-sorted