executing top on several computers

Hi

I'm waiting for the IT department to install Ganglia, and until that happens, I need to know the current load on 14 computers.

To do this, I'm trying to write a small script that output the top processes on each of the computers using top, but for some reason it doesn't work.

#!/usr/bin/ksh93
for i in {1..14}; do
  if (( $i < 10 ))
  then
   echo $i
   eval "ssh gotc10$i"
   eval "top -b -n 1 | head -n 8 | tail -n 1"
   eval "exit"
  else
   eval "gotc1$i"
   eval "top -b -n 1 | head -n 8 | tail -n 1"
   eval "exit"
  fi
done

What happens is that the script logs into the first machine, then does nothing.

Any input is highly appreciated.

Tobbe

Try with square brackets..

any other errors..???

I tried, but sadly it made no difference..

Tobbe

---------- Post updated at 01:56 AM ---------- Previous update was at 01:53 AM ----------

When I run the script, I log in to gotc101 and then nothing happens. When I manually run exit, it outputs the top process on gotc101 but does not log off gotc101, so something changed with the square brackets. I'm not sure on how to interpret it though...

---------- Post updated at 02:26 AM ---------- Previous update was at 01:56 AM ----------

I think I know the problem now. The top commands run locally and not on the ssh'd machine.

I am not sure it works or not. have you tried this...

eval "ssh gotc10$i" "top -b -n 1 | head -n 8 | tail -n 1" # not sure about this..
ssh "gotc10$i" "top -b -n 1 | head -n 8 | tail -n 1"

And do we need to exit after every connection...?