Script to monitor IOwait


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to monitor IOwait
# 1  
Old 11-14-2012
Script to monitor IOwait

Hello, I need to monitor IOwait on a server and have started this script directly on the ssh prompt.

Effectively it almost does what it is supposed to do, but I have no idea how to stop it?

How can I make it run it as a file based bash script?

Code:
(
    iostat -xk 1 /dev/sdb2 | \
    perl -MPOSIX=strftime -ne '
        $|=1;
        next unless /^(sdb2|\s+\d)/;
        if (/^\s+/) {
            s/\s*$/ /;
            $_=strftime("%H:%M:%S ", localtime time).$_
        }
        print
    ' &> /tmp/iostat.log
) &


Last edited by Scrutinizer; 11-16-2012 at 05:24 AM.. Reason: quote tags => code tags
# 2  
Old 11-14-2012
which plateform/OS do you run ?
# 3  
Old 11-14-2012
Hello ctsgnb, I do use centos 6
# 4  
Old 11-14-2012
Does your OS have the command "watch" ?
# 5  
Old 11-15-2012
yes, it does. watch available
# 6  
Old 11-16-2012
Which shell are you currently using ?
Are you willing to monitor this interactively or only log it into a file ?

Last edited by ctsgnb; 11-16-2012 at 04:34 AM..
# 7  
Old 11-16-2012
This is what I would use (based on awk as I avoid perl like the plague):

Code:
#!/bin/sh
iostat -xk 1 /dev/sdb2 |
awk '
BEGIN { cmd="date +%H:%M:%S" }
NF == 6 { cmd|getline now;
  printf("%s %s\n",now,$0);
  close(cmd)
}'

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Script monitor website wth default tomcat script

Hi all, on our application server we have the following script that monitor the status of the website, my problem here is that i have edite the retries from 3 to 5, and the timewait to 120 second, so the script should check 5 times every 2 minutes, and if the fifth check fails it must restart... (0 Replies)
Discussion started by: charli1
0 Replies

2. Infrastructure Monitoring

Searching for Saas Monitor service which monitor my servers which are sitting in different providers

Sorry if this is the wrong forum Searching for Saas Monitor service which monitor my servers which are sitting in different providers . This monitor tool will take as less CPU as possible , and will send info about the server to main Dashboard. The info I need is CPU / RAM / my servers status (... (1 Reply)
Discussion started by: umen
1 Replies

3. Shell Programming and Scripting

How to monitor a shell script called within a script?

HIi Guys... I am in a fix.... 1st the code : Script 123.sh looks like this : ./abc # a script which is getting called in this script while true do count=`ps -ef | grep abc | wc -l` if echo "abc is running sleep 10 fi done but the process is getting checked... (5 Replies)
Discussion started by: chatwithsaurav
5 Replies

4. UNIX for Dummies Questions & Answers

Monitor a script

Hi All, In a script I would like to check whether the current running command is completed in 1 hour or not. This i want to achieve inside the same script. I don't want to use separate script to monitor my current running script. eg. pseudocode; Command1 if command1>60 mins then... (7 Replies)
Discussion started by: Vicky5
7 Replies

5. UNIX for Dummies Questions & Answers

Is total CPU usage for sar %user+%system+%iowait?

Hi all Can anyone advise/confirm whether total CPU usage when running sar is %user+%system+%iowait or is it %user+%system only? I want to confirm whether I am having a CPU-bound problem or not. This is a single-CPU VMware machine. $ sar 5 20 Linux 2.6.18-238.5.1.el5... (7 Replies)
Discussion started by: newbie_01
7 Replies

6. Shell Programming and Scripting

Monitor script

Does anyone have a monitoring script in solaris that monitors the drives in an exclosure? The script should be in /bin/bash or /bin/sh thnks again This should be for solaris 10/11 looking for something that tells me a drive is down or offline.:confused: (0 Replies)
Discussion started by: walnutpony123
0 Replies

7. Linux

how to trace iowait to a certain process

Hi all, Under top command you could see some iowait output. Is any way to locate which process(s) is causing the high percentage of iowait? 17:48:39 up 19 days, 18:54, 3 users, load average: 3.24, 3.14, 3.17 392 processes: 389 sleeping, 1 running, 2 zombie, 0 stopped CPU states: cpu user... (3 Replies)
Discussion started by: will_mike
3 Replies

8. UNIX for Advanced & Expert Users

How to reduce IOWAIT in linux

Hi All, Any ideas how to reduce IOWAIT and increase disk speed on Linux server. Server has 4 CPUs and with 8GB RAM. Thanks in advance, Regards, Bache (3 Replies)
Discussion started by: bache_gowda
3 Replies

9. UNIX for Dummies Questions & Answers

excessive IOWAIT

i have a server constantly have high iowait, but i am not able to tell which process generate the most of io. none commands, such as iostat, sar, top will give me this kind of information. hope there is some command can help me to spot the process generate the most of io let to know input... (1 Reply)
Discussion started by: giantpanda77
1 Replies
Login or Register to Ask a Question