Added diskstats which runs as trapper or agent
This commit is contained in:
parent
f8a36fa773
commit
3e40157c11
1 changed files with 89 additions and 0 deletions
89
scripts/diskstats.sh
Executable file
89
scripts/diskstats.sh
Executable file
|
@ -0,0 +1,89 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
mode=${1,,}
|
||||||
|
mountpath=${2-all}
|
||||||
|
stat=${3,,}
|
||||||
|
|
||||||
|
|
||||||
|
#echo "mode: $mode"
|
||||||
|
#echo "path: $mountpath"
|
||||||
|
#echo "stat: $stat"
|
||||||
|
|
||||||
|
if [[ "$mode" = "active" && ! -d "$mountpath" ]];
|
||||||
|
then
|
||||||
|
echo "ZBX_NOTSUPPORTED"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$mode" = "help" ]];
|
||||||
|
then
|
||||||
|
case $mountpath in
|
||||||
|
zabbix) myself=$(readlink -f $0)
|
||||||
|
echo "UserParameter vfs.read.ops[*],$myself active \$1"
|
||||||
|
echo "UserParameter vfs.read.ms[*],$myself active \$1"
|
||||||
|
echo "UserParameter vfs.read.sector[*],$myself active \$1"
|
||||||
|
echo "UserParameter vfs.write.ops[*],$myself active \$1"
|
||||||
|
echo "UserParameter vfs.write.ms[*],$myself active \$1"
|
||||||
|
echo "UserParameter vfs.write.sector[*],$myself active \$1"
|
||||||
|
echo "UserParameter vfs.io.active[*],$myself active \$1"
|
||||||
|
echo "UserParameter vfs.io.ms[*],$myself active \$1"
|
||||||
|
;;
|
||||||
|
*) echo "COMMAND:"
|
||||||
|
echo " ${0##*/} active path {STAT}"
|
||||||
|
echo " ${0##*/} trap [path]"
|
||||||
|
echo " ${0##*/} help [zabbix]"
|
||||||
|
echo " "
|
||||||
|
echo "STAT:"
|
||||||
|
echo " readops - Read Operations"
|
||||||
|
echo " readms - Read time in Miliseconds"
|
||||||
|
echo " readsectors - Read sectors"
|
||||||
|
echo " writeops - Write operations"
|
||||||
|
echo " writems - Write time in Miliseconds"
|
||||||
|
echo " writesectors - Write sectors"
|
||||||
|
echo " ioactive - Active IO threads"
|
||||||
|
echo " ioms - IO time in Miliseconds"
|
||||||
|
esac
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
#exit 0
|
||||||
|
|
||||||
|
while read -r spec file vfstype mntops freq passno
|
||||||
|
do
|
||||||
|
if [[ $spec = /dev* ]]
|
||||||
|
then
|
||||||
|
if [[ "$mountpath" != "all" && "$mountpath" != "$file" ]];
|
||||||
|
then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
device=$(readlink -f $spec)
|
||||||
|
device=${device##*/}
|
||||||
|
read -r no no no readops no readsectors readms writeops no writesectors writems ioactive ioms no <<< $(grep $device /proc/diskstats | head -1)
|
||||||
|
|
||||||
|
case $mode in
|
||||||
|
trap)
|
||||||
|
echo "- vfs.read.ops[$file] $readops"
|
||||||
|
echo "- vfs.read.ms[$file] $readms"
|
||||||
|
echo "- vfs.read.sectors[$file] $readsectors"
|
||||||
|
echo "- vfs.write.ops[$file] $writeops"
|
||||||
|
echo "- vfs.write.ms[$file] $writems"
|
||||||
|
echo "- vfs.write.sectors[$file] $writesectors"
|
||||||
|
echo "- vfs.io.active[$file] $ioactive"
|
||||||
|
echo "- vfs.io.ms[$file] $ioms"
|
||||||
|
;;
|
||||||
|
active)
|
||||||
|
case $stat in
|
||||||
|
readops) echo "$readops";;
|
||||||
|
readms) echo "$readms";;
|
||||||
|
readsectors) echo "$readsectors";;
|
||||||
|
writeops) echo "$writeops";;
|
||||||
|
writems) echo "$writems";;
|
||||||
|
writesectors) echo "$writesectors";;
|
||||||
|
ioactive) echo "$ioactive";;
|
||||||
|
ioms) echo "$ioms";;
|
||||||
|
*) echo "ZBX_NOTSUPPORTED";;
|
||||||
|
esac
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
done < /proc/mounts
|
||||||
|
|
Loading…
Reference in a new issue