-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheck_disk_io.sh
More file actions
69 lines (64 loc) · 1.75 KB
/
check_disk_io.sh
File metadata and controls
69 lines (64 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#####################################################################################################
# check disk io performance for zabbix
# version 0.1 date:2014/05/28
# usage:
# UserParameter=disk.io.discovery,/usr/local/etc/scripts/check_disk_io.sh disk_io_discovery
# UserParameter=disk.io.type[*],/usr/local/etc/scripts/check_disk_io.sh io_type $1(rrqm/wrqm/wrqm...)
#####################################################################################################
#! /bin/sh
function disk_io_discovery()
{
mydiskname=`iostat -d -x -k 1 1 | awk 'NR>=4&&NR<=4 {printf $1}'`
printf "{\n"
printf '\t'"\"data\":["
printf '\n\t\t{'
printf "\"{#DISK_NAME}\":\"$mydiskname\"}"
printf "\n\t]\n"
printf "}\n"
}
function io_type()
{
case "$1" in
rrqm)
awk 'NR>=7&&NR<=7 {printf $2}' /tmp/iostat.cache
;;
wrqm)
awk 'NR>=7&&NR<=7 {printf $3}' /tmp/iostat.cache
;;
readtimes)
awk 'NR>=7&&NR<=7 {printf $4}' /tmp/iostat.cache
;;
writetimes)
awk 'NR>=7&&NR<=7 {printf $5}' /tmp/iostat.cache
;;
rkB)
awk 'NR>=7&&NR<=7 {printf $6}' /tmp/iostat.cache
;;
wkB)
awk 'NR>=7&&NR<=7 {printf $7}' /tmp/iostat.cache
;;
await)
awk 'NR>=7&&NR<=7 {printf $8}' /tmp/iostat.cache
;;
svctm)
awk 'NR>=7&&NR<=7 {printf $11}' /tmp/iostat.cache
;;
util)
awk 'NR>=7&&NR<=7 {printf $12}' /tmp/iostat.cache
;;
*)
echo "unknown type"
;;
esac
}
case "$1" in
disk_io_discovery)
disk_io_discovery
;;
io_type)
io_type $2
;;
*)
echo "Usage:$0 disk_io_discovery|io_type [type]}"
;;
esac