LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-24-2007, 05:36 AM   #1
3ttt
LQ Newbie
 
Registered: May 2007
Posts: 18

Rep: Reputation: 0
Question Performance Monitoring Script


Hi everybody,

I would like to keep a log file which merges "iostat" and "netstat -i", let say for every 1 minute in one row. Are there any scripts or better tools I can take?

Thanks a lot.

3ts
 
Old 05-24-2007, 06:23 AM   #2
mechdave
Member
 
Registered: Apr 2007
Location: Adelaide, Australia
Distribution: Ubuntu 8.10 and 7.10 server
Posts: 95

Rep: Reputation: 15
Post

Try:
Code:
#!/bin/bash
logfile="/path/to/log/file"
while true; do
    iostat >> $logfile
    netstat -i >> $logfile
    sleep 60
done
 
Old 05-24-2007, 07:57 AM   #3
3ttt
LQ Newbie
 
Registered: May 2007
Posts: 18

Original Poster
Rep: Reputation: 0
Hi mechdave, thanks a lot!

How can I do if I want to get out of this while loop when I finish another command, e.g. "cp -r $sourcefile $storage"?


#!/bin/bash
logfile="/path/to/log/file"
sourcefile="/path/copy/source"
storage="/media/USBDISK"

cp -r $sourcefile $storage

while true; do
iostat >> $logfile
netstat -i >> $logfile
sleep 60
done

I try this but it doesn't work!!!
 
Old 05-25-2007, 05:31 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
If you're trying to collect stats on the cp cmd, you can do it as 2 diff progs.
1st, start the gatherer prog (iostat etc) in the background eg
nohup ./gatherer.sh &
then run the cp script, then kill the gatherer (which will have shown it's pid when you started it).
Alternatively, you can embed the gatherer script invocation at the top of the cp script and use the $! var to get it's pid; see http://tldp.org/LDP/abs/html/x8280.html
 
Old 05-26-2007, 03:15 AM   #5
3ttt
LQ Newbie
 
Registered: May 2007
Posts: 18

Original Poster
Rep: Reputation: 0
Thanks a lot Chris! I have got it :-D
Thanks mechdave for the idea :-)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
performance monitoring / optimization vikasbucha Linux - General 2 01-25-2007 04:38 PM
Performance Monitoring Tool kaplan71 Linux - Software 1 09-21-2006 02:40 PM
Performance Monitoring Risc91 AIX 11 10-21-2005 10:51 AM
Monitoring System Performance lapthorn Linux - General 3 04-22-2004 03:52 AM
CPU Utilization / Performance Monitoring codegomer Linux - General 3 02-18-2004 12:35 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration