LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 12-11-2012, 06:14 PM   #1
sid1881s
LQ Newbie
 
Registered: Dec 2012
Posts: 1

Rep: Reputation: Disabled
How to write a shell script ?


Hi Everyone,

I am from the performance testing background and working on an application hosted on an app server having the Fedora OS. While load testing, I will need to collect the CPU, Memory and Disk metrics for the app server.

With regard to the same, I will need to write a shell script which will generate the output from the vmstat and iostat command at a sampling rate of 5 seconds and redirect to a single notepad.

I tried to google it but did not find any feasible solution. Can someone please help. It's urgent.

Thanks,
Sid
 
Old 12-11-2012, 06:35 PM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 345Reputation: 345Reputation: 345Reputation: 345
I think you just need a while loop, sleep and some redirection.

Hope this helps,
 
Old 12-11-2012, 07:13 PM   #3
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,159
Blog Entries: 10

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
53,900 'feasible solutions"
 
Old 12-12-2012, 01:26 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
These will help
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
 
Old 12-12-2012, 12:17 PM   #5
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,159
Blog Entries: 10

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
Quote:
...a shell script which will generate the output from the vmstat and iostat command at a sampling rate of 5 seconds and redirect to a single notepad.
Sid:

This should get you started:
Code:
#!/bin/bash
vmstat 5 3 | awk '{now=strftime("%m-%d-%Y %T "); print now $0}' >> /path/to/file.out
iostat 5 2 /dev/sd[x] >> /path/to/file.out
The "{vm,io}stat 5 3" is 5 seconds x times. I'll leave that to you.
the "x" in "/dev/sd[x]" is the disk you are interested in.


Quote:
It's urgent.
always is.

24 iostat, vmstat and mpstat Examples for Linux Performance Monitoring
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
SHELL SCRIPT Write at the right of the shell window solo9300 Linux - General 3 09-29-2009 05:56 PM
How to ssh from a shell script ? For ppl who can write shell scripts. thefountainhead100 Programming 14 10-22-2008 07:24 AM
Need help to write Shell Script vikrambhimbar Linux - Software 1 05-08-2006 07:10 AM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 04:00 PM


All times are GMT -5. The time now is 06:00 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration