TOP IO DISK Utilization scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting TOP IO DISK Utilization scripting
# 1  
Old 06-15-2013
TOP IO DISK Utilization scripting

Hi Fiends,

I am new to scripting., I want to calculate the 2nd column in the below output and print the average for each hdisk.

Below is the output of sar command,

Code:
hdisk0 0
hdisk0 2
hdisk0 0
hdisk1 2
hdisk1 2
hdisk1 2
hdisk2 1
hdisk2 0
hdisk2 0

Thanks,
Srinivasan

Last edited by Scrutinizer; 06-15-2013 at 04:33 PM.. Reason: code tags
# 2  
Old 06-15-2013
You could try something like:
Code:
awk '{	c[$1]++; s[$1] += $2}
END {	for(i in c) print i, s[i] / c[i]}' sar.out

If you're using a Solaris/SunOS system, use /usr/xpg4/bin/awk, /usr/xpg6/bin/awk, or nawk instead of awk.

Last edited by Don Cragun; 06-15-2013 at 04:54 PM.. Reason: Fix typo.
# 3  
Old 06-15-2013
Don,

Thanks for u reply.

I am getting the following error.
Code:
cat /tmp/sar.txt | grep -v -p Average |egrep "hdisk" |cut -c 14-26|sort -rn
hdisk1      2
hdisk1      0
hdisk1      0
hdisk0      2
hdisk0      0
hdisk0      0
 
A=`cat /tmp/sar.txt | grep -v -p Average |egrep "hdisk" |cut -c 14-26|sort -rn`
 
awk '{ c[$1]++; s[$1] += $2}
END { for(i in c) print i, s[i] / c[i] }' $A
awk: 0602-533 Cannot find or open file hdisk1.
 The source line number is 2.

---------- Post updated at 02:55 AM ---------- Previous update was at 01:42 AM ----------

Hi friends,

I got the script from the earlier post.
Code:
awk '{
> c[$1]=1
> for(i=2;i<=NF;i++)
> {
>  total[$1,i]+=$i
>  count[$1,i]++
> }
> }
> END{
> for(i in c)
> {
>  printf "%s",i
>  for(j=2;count[i,j];j++)
>   printf "\t%.1f", (total[i,j]/count[i,j])
>  printf "\n"
> }
> }' sar.txt


Last edited by Scott; 06-16-2013 at 05:12 AM.. Reason: Code tags, please...
# 4  
Old 06-16-2013
A=`cat /tmp/sar.txt | grep -v -p Average |egrep "hdisk" |cut -c 14-26|sort -rn`
could be change to some more modern
A=$(cat /tmp/sar.txt | grep -v -p Average |egrep "hdisk" |cut -c 14-26|sort -rn)

You can not add variable to awk the way you try to do it.
Quote:
awk '{ c[$1]++; s[$1] += $2}
END { for(i in c) print i, s[i] / c[i] }' $A
correct
Code:
awk '{ c[$1]++; s[$1] += $2}
END { for(i in c) print i, s[i] / c[i] }' <<< "$A"

or
Code:
echo "$A" | awk '{ c[$1]++; s[$1] += $2}
END { for(i in c) print i, s[i] / c[i] }'

You also need to have $A in quotes like this "$A" to preserve the multiple lines.

If you give us some lines of sar.txt, we could for sure shorten the code for $A
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Top utilization of the users through script

I am trying for a shell script like, if the ram utilization is less than 300M and the load average is more then 4.00 , should take all the top users of memory and CPU utilization through "top" and "ps " command and put under one path. (6 Replies)
Discussion started by: gsiva
6 Replies

2. UNIX for Dummies Questions & Answers

Disk utilization

Hi, I have hundred folders under a fs /apps which is used by different users and they upload their data to these folders on a daily basis. Using du -sk gives me complete structure of the filesystem but i want to find out day to day utlization of the top ten highest accoriding to size wise ... (4 Replies)
Discussion started by: chetansingh23
4 Replies

3. Red Hat

Disk Utilization

Hi, Can anybody explain why my newly created 120G FS shows 100% utilization when only 113G of disk space has been used? ...... # df -h . Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg01-lvol0 119G 113G 0 100% /u02 #du -h /u02 16K ... (3 Replies)
Discussion started by: Duffs22
3 Replies

4. Infrastructure Monitoring

Disk Utilization between Global + Zone

Dear Gentleman in my environment I have Solaris10 OS Box in Global Zone with 136 GB and mount point from SAN Storage 500 GB (Orastorage) Zone1 mounted on /Zones folder with 66 GB when I run zpool list output -bash-3.00$ zpool list NAME SIZE ALLOC FREE CAP HEALTH... (0 Replies)
Discussion started by: Hosam
0 Replies

5. Shell Programming and Scripting

disk space utilization script

Hi, I wrote the following script for monitoring disk space and inform the concerned team accordingly. But script gives me below error syntax error at line 70 : `<' unmatched #!/bin/ksh . /home/scr/.profile . /home/scr/.infa_env # Get the list of Integration Services ... (6 Replies)
Discussion started by: svajhala
6 Replies

6. Shell Programming and Scripting

need help for scrip to monitor disk utilization

Hi, I need help to write a script which will monitor disk utilization. Please suggest the best approach to achive this. I am thinking of having sleep inside the script which will run for(eg.) 60 secs and then disk utilization will be checked and depends on the % usage of disk mail will... (1 Reply)
Discussion started by: sunilmenhdiratt
1 Replies

7. Red Hat

Disk Utilization is very high

Hi, I have monitored that disk utilization is very high on one of red hat linux VM. Would like to know how to find out that issue of high disk utilization is because of disk or Installed Application on that server is causing the problem. Regards, Manoj (1 Reply)
Discussion started by: manoj.solaris
1 Replies

8. UNIX for Advanced & Expert Users

File disk utilization for 10 days prior

Hi I have a requirement to list the files & the total disk utilization they have which are 10 prior to current date. I tried couple of options in combinations of find mtime, ctime with du -m, but no luck. Could you please help me in this ? (2 Replies)
Discussion started by: videsh77
2 Replies

9. Solaris

syslogd 30% utilization in top, solaris 9

Hi folks, Sorry to barge in and ask a question right off the bat without contributing first. I have a V440, 4 X 1GHZ, 32GB ram, and recently syslogd has started showing 30+ % cpu usage. It's also repeating entries in the syslog, over and over. the /var/log/syslog file had grown to over 2GB - I... (2 Replies)
Discussion started by: chugheshc
2 Replies

10. AIX

Historical Disk bandwidth utilization

Early this morning our sar reports show that WIO on the system was over 50% for about an hour. We also had some users complain about response time problems during this time. Is there a way I can go back and check what disks were busy during this time (something like topas but for historical data)? (1 Reply)
Discussion started by: 2dumb
1 Replies
Login or Register to Ask a Question