executing top on several computers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting executing top on several computers
# 1  
Old 09-11-2012
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.

Code:
#!/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
# 2  
Old 09-11-2012
Try with square brackets..

Quote:
Originally Posted by Tobbev
Code:
#!/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

Tobbe
any other errors..???

Last edited by pamu; 09-11-2012 at 03:56 AM.. Reason: added info..
# 3  
Old 09-11-2012
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.
# 4  
Old 09-11-2012
I am not sure it works or not. have you tried this...

Code:
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...?
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Solaris

Rcp between 2 computers

Hi, I need to rcp heavy files between 2 solaris 10/sparc M3000 computers. Currently theses 2 computers are linked via a switch/firewall and the rcp commands take a very long time, I have been told that this is because of the firewall (old one). I asked my client to by a cross ethernet cable and... (2 Replies)
Discussion started by: zionassedo
2 Replies

2. What is on Your Mind?

How Many Computers Do You Have At Home?

Here is an easy one. Count the number of desktops and servers you have running at home, including your home office if you have one. Don't count those that are in storage or you rarely use, count the ones that are powered on most, if not all, of the day (and night). (86 Replies)
Discussion started by: Neo
86 Replies

3. AIX

Need a list of top 10 CPU using processes (also top 10 memory hogs, separately)

Okay, I am trying to come up with a multi-platform script to report top ten CPU and memory hog processes, which will be run by our enterprise monitoring application as an auto-action item when the CPU and Memory utilization gets reported as higher than a certain threshold I use top on other... (5 Replies)
Discussion started by: thenomad
5 Replies

4. AIX

Top command in AIX 4.2 (no topas, no nmon, no top)?

Is there a 'top' command equivalent in AIX 4.2 ? I already checked and I do not see the following ones anywhere: top nmon topas (1 Reply)
Discussion started by: Browser_ice
1 Replies

5. UNIX for Advanced & Expert Users

Using other computers for processing

Hello I've wrote a C++ program which does some mathematical calculations, but the problem is that it takes way too long on any computer to finish. Is there anyway to make more than 1 computer do the processing so it can process faster? (5 Replies)
Discussion started by: arya6000
5 Replies

6. IP Networking

two computers one internet

i have a computer (sempron 2200+) with Suse 9.3 and another computer with windows 98 (PI 233 Mhz). I'm connect first computer (with Suse) on the Internet through ethernet but second computers in not connect. How can connect second computers on the internet (with 3 network card...two on the first... (8 Replies)
Discussion started by: dragos
8 Replies

7. UNIX for Dummies Questions & Answers

How Can I Have Top Display The Top 20 Processes??

how can i do that in a script withough havin the script halt at the section where the top command is located. am writign a script that will send me the out put of unx commands if the load average of a machine goes beyond the recommended number. top -n 20 i want to save this output to a file... (1 Reply)
Discussion started by: TRUEST
1 Replies

8. UNIX for Dummies Questions & Answers

two computers - one modem

I have two mashines with RedHat 8.0......they connected with cross over cabel...I want use both mashines for Internet, but modem has only first computer... Maybe..through gateway ?.... What must i do for it ?...... sorry for my terrible english.... (3 Replies)
Discussion started by: Pennywize
3 Replies
Login or Register to Ask a Question