Created
July 16, 2018 19:37
-
-
Save linuxkidd/6c2fad63c829b452c7f22453193008e7 to your computer and use it in GitHub Desktop.
Given output of 'iostat -x 1', provides a time spent by Utilization in 10% Util buckets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/awk -f | |
BEGIN { | |
} | |
function histoevent(mykey,myevent,myfunc,myvalue) { | |
EVENTHEADERS[myevent]=1 | |
if(myfunc=="sum") | |
EVENTCOUNT[mykey][myevent]+=myvalue | |
else if(myfunc=="set") | |
EVENTCOUNT[mykey][myevent]=myvalue | |
else if(myfunc=="inc") | |
EVENTCOUNT[mykey][myevent]++ | |
} | |
/^[a-zA-Z]/ { | |
if($1 !~ /avg-cpu/ && $1 !~ /Linux/ && $1 !~ /Device/) { | |
mykey=sprintf("%d",int($NF/10)*10) | |
if($NF>100) | |
mykey=sprintf("%d",int($NF/100)*100) | |
histoevent(mykey,$1,"inc",1) | |
histoevent("TOT",$1,"inc",1) | |
} | |
} | |
END { | |
n=asorti(EVENTHEADERS) | |
printf("%Util") | |
for (i=1;i<=n;i++) { | |
printf(",%s",EVENTHEADERS[i]) | |
} | |
for (j=0;j<=100;j+=10) { | |
printf("%d",j) | |
for (i=1;i<=n;i++) { | |
printf(",%0.2f",(EVENTCOUNT[j][EVENTHEADERS[i]]/EVENTCOUNT["TOT"][EVENTHEADERS[i]])*100) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment