Skip to content
Snippets Groups Projects
Commit 923b929c authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

check_disk-io: update check; add doc page

parent 7150f40b
No related branches found
No related tags found
1 merge request!127Update icinga checks and docs
...@@ -2,44 +2,58 @@ ...@@ -2,44 +2,58 @@
# ====================================================================== # ======================================================================
# #
# Check DISK IO over all disks # Check DISK IO over all disks
#
# data besed on /proc/diskstats # data besed on /proc/diskstats
# https://www.kernel.org/doc/Documentation/iostats.txt # https://www.kernel.org/doc/Documentation/iostats.txt
# #
# based on /sys/block/*/stat # based on /sys/block/*/stat
# https://www.kernel.org/doc/Documentation/block/stat.txt # https://www.kernel.org/doc/Documentation/block/stat.txt
# #
# Requires: bc, lsblk
#
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# 2020-07-17 v1.0 <axel.hahn@iml.unibe.ch> # 2020-07-17 v1.0 <axel.hahn@iml.unibe.ch>
# 2023-07-27 v1.1 <axel.hahn@iml.unibe.ch> shell fixes; remove unsupported warn and critical
# ====================================================================== # ======================================================================
. `dirname $0`/inc_pluginfunctions . $( dirname $0 )/inc_pluginfunctions
self_APPNAME=$( basename $0 | tr [:lower:] [:upper:] )
self_APPVERSION=1.1
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# FUNCTIONS # FUNCTIONS
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# diskinfo based on lsblk # diskinfo based on lsblk
# # param string comma separated list of names (no spaces)
function _diskInfo(){ function _diskInfo(){
local _fields=$1 local _fields=$1
test -z $_fields && _fields='NAME,MAJ:MIN,TYPE,SIZE,FSTYPE,MOUNTPOINT,STATE,ROTA,VENDOR,MODEL,SERIAL,HCTL' test -z "$_fields" && _fields='NAME,MAJ:MIN,TYPE,SIZE,FSTYPE,MOUNTPOINT,STATE,ROTA,VENDOR,MODEL,SERIAL,HCTL'
lsblk -ai --output $_fields lsblk -ai --output "$_fields"
} }
# get a list of local disks
function getDisks(){ function getDisks(){
_diskInfo "NAME,TYPE" | grep "disk" | awk '{ print $1 }' | sed "s#[^a-z0-9]##g" _diskInfo "NAME,TYPE" | grep "disk" | awk '{ print $1 }' | sed "s#[^a-z0-9]##g"
} }
function getPartitions(){
_diskInfo "NAME,TYPE" | grep "part" | awk '{ print $1 }' | sed "s#[^a-z0-9]##g"
}
# UNUSED get a list of local partitions
# function getPartitions(){
# _diskInfo "NAME,TYPE" | grep "part" | awk '{ print $1 }' | sed "s#[^a-z0-9]##g"
# }
# show help
function showHelp(){ function showHelp(){
_self=$(basename $0)
cat <<EOF cat <<EOF
______________________________________________________________________ ______________________________________________________________________
CHECK_DISK IO AND LATENCY $self_APPNAME
v$self_APPVERSION
Check dis io and latency
(c) Institute for Medical Education - University of Bern (c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3 Licence: GNU GPL 3
...@@ -47,17 +61,18 @@ ______________________________________________________________________ ...@@ -47,17 +61,18 @@ ______________________________________________________________________
Disk infos based on /sys/block/[NAME]/stat Disk infos based on /sys/block/[NAME]/stat
See https://www.kernel.org/doc/Documentation/block/stat.txt See https://www.kernel.org/doc/Documentation/block/stat.txt
and https://www.kernel.org/doc/Documentation/iostats.txt
The system data are counters that are difficult to read.
The output of this check for each value a delta value per second since
last check.
SYNTAX: SYNTAX:
`basename $0` -m MODE [-w WARN_LIMIT] [-c CRITICAL_LIMIT] $_self -m MODE
OPTIONS: OPTIONS:
-m MODE set mode for type of output (required) -m MODE set mode for type of output (required)
-w VALUE warning level (default: 0 for none)
-c VALUE critical level (default: 0 for none)
-h or --help show this help. -h or --help show this help.
PARAMETERS: PARAMETERS:
...@@ -68,7 +83,7 @@ PARAMETERS: ...@@ -68,7 +83,7 @@ PARAMETERS:
wait total wait time for all requests wait total wait time for all requests
EXAMPLE: EXAMPLE:
`basename $0` -m io $_self -m io
EOF EOF
} }
...@@ -77,18 +92,8 @@ EOF ...@@ -77,18 +92,8 @@ EOF
# MAIN # MAIN
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# TESTAREA 51
# _diskInfo
# echo "--- disks: "
# getDisks
# echo "--- partitions: "
# getPartitions
ph.require bc lsblk
typeset -i iDelta=0 typeset -i iDelta=0
case "$1" in case "$1" in
"--help"|"-h") "--help"|"-h")
showHelp showHelp
...@@ -97,12 +102,10 @@ case "$1" in ...@@ -97,12 +102,10 @@ case "$1" in
*) *)
esac esac
# set default / override from command line params ph.require bc lsblk
typeset -i iWarnLimit=` ph.getValueWithParam 0 w "$@"`
typeset -i iCriticalLimit=` ph.getValueWithParam 0 c "$@"`
# --- set mode # --- set mode
sMode=` ph.getValueWithParam '' m "$@"` sMode=$( ph.getValueWithParam '' m "$@")
# --- labels and its columns in /sys/block/$myDisk/stat # --- labels and its columns in /sys/block/$myDisk/stat
...@@ -143,20 +146,20 @@ case "$sMode" in ...@@ -143,20 +146,20 @@ case "$sMode" in
*) *)
echo "ERROR: missing or wrong MODE parameter -m" echo "ERROR: missing or wrong MODE parameter -m"
showHelp showHelp
exit 0 exit 1
esac esac
tmpfile1=`mktemp` tmpfile1=$(mktemp)
# --- add data for each disk # --- add data for each disk
for myDisk in `getDisks` for myDisk in $(getDisks)
do do
echo >>$tmpfile1 echo >>"$tmpfile1"
echo "--- $myDisk" >> $tmpfile1 echo "--- $myDisk" >> "$tmpfile1"
diskdata=$( cat /sys/block/$myDisk/stat ) diskdata=$( cat /sys/block/$myDisk/stat )
# echo $diskdata >> $tmpfile1 # echo $diskdata >> $tmpfile1
...@@ -166,35 +169,35 @@ do ...@@ -166,35 +169,35 @@ do
column=${aColums[$index]} column=${aColums[$index]}
value=$( echo $diskdata | cut -f $column -d " " ) value=$( echo $diskdata | cut -f $column -d " " )
iDelta=`ph.perfdeltaspeed "$label" $value` iDelta=$(ph.perfdeltaspeed "$label" $value)
typeset -i aTotals[$index]=${aTotals[$index]}+$iDelta typeset -i aTotals[$index]=${aTotals[$index]}+$iDelta
# echo " $label $iDelta per sec ... total: $value" >> $tmpfile1 # echo " $label $iDelta per sec ... total: $value" >> "$tmpfile1"
printf "%30s %10d \n" "$label:" "$iDelta" >> $tmpfile1 printf "%30s %10d \n" "$label:" "$iDelta" >> "$tmpfile1"
done done
done done
# --- add total # --- add total
echo >>$tmpfile1 echo >>"$tmpfile1"
echo "--- TOTAL" >> $tmpfile1 echo "--- TOTAL" >> "$tmpfile1"
for index in ${!aNames[*]} for index in ${!aNames[*]}
do do
label="${aNames[$index]}" label="${aNames[$index]}"
value=${aTotals[$index]} value=${aTotals[$index]}
# echo " $label: $value" >> $tmpfile1 # echo " $label: $value" >> $tmpfile1
printf "%30s %10d \n" "$label:" "$value" >> $tmpfile1 printf "%30s %10d \n" "$label:" "$value" >> "$tmpfile1"
ph.perfadd "$label" "$value" ph.perfadd "$label" "$value"
done done
echo >>$tmpfile1 echo >>"$tmpfile1"
# --- output # --- output
ph.status "Disk data ... $info " # READ `toUnit $iTotalRead M` MB/s << [DISC] << `toUnit $iTotalWrite M` MB/s WRITE" ph.status "Disk data ... $info " # READ `toUnit $iTotalRead M` MB/s << [DISC] << `toUnit $iTotalWrite M` MB/s WRITE"
cat $tmpfile1 cat "$tmpfile1"
# --- cleanup and bye # --- cleanup and bye
rm -f $tmpfile1 rm -f "$tmpfile1"
ph.exit ph.exit
...@@ -17,7 +17,7 @@ There is one include script used by all checks: ...@@ -17,7 +17,7 @@ There is one include script used by all checks:
* check_couchdb-lb * check_couchdb-lb
* [check_cpu](check_cpu.md) * [check_cpu](check_cpu.md)
* [check_cronstatus](check_cronstatus.md) * [check_cronstatus](check_cronstatus.md)
* check_disk-io * [check_disk-io](check_disk-io.md)
* check_dns_responsetime * check_dns_responsetime
* [check_eol](check_eol.md) * [check_eol](check_eol.md)
* check_haproxy_health * check_haproxy_health
......
# CHECK_DISK-IO
## Introduction
**check_disk-io** is a plugin to show io, ticks and wait time.
It shows a multiline output and sends performance data.
## Requirements
* `lsblk` List information about block devices
* `bc` calculator
## Syntax
```txt
______________________________________________________________________
CHECK_DISK-IO
v1.1
Check dis io and latency
(c) Institute for Medical Education - University of Bern
Licence: GNU GPL 3
______________________________________________________________________
Disk infos based on /sys/block/[NAME]/stat
See https://www.kernel.org/doc/Documentation/block/stat.txt
and https://www.kernel.org/doc/Documentation/iostats.txt
The system data are counters that are difficult to read.
The output of this check for each value a delta value per second since
last check.
SYNTAX:
check_disk-io -m MODE
OPTIONS:
-m MODE set mode for type of output (required)
-h or --help show this help.
PARAMETERS:
MODE
io read I/Os, write I/Os, discard I/0s
ticks read ticks, write ticks, discard ticks
wait total wait time for all requests
EXAMPLE:
check_disk-io -m io
```
### Parameters
`-m <MODE>` where MODE is a string to define kind of output.
## Examples
`$ check_disk-io -m io` returns
```txt
OK: Disk data ... read I/Os, write I/Os, discard I/0s, number of I/Os currently in flight
--- sda
disk-sda-ReadIO: 0
disk-sda-WriteIO: 0
disk-sda-DiscardIO: 0
disk-sda-FlightIO: 0
--- nvme0n1
disk-nvme0n1-ReadIO: 3
disk-nvme0n1-WriteIO: 16
disk-nvme0n1-DiscardIO: 4
disk-nvme0n1-FlightIO: 0
--- TOTAL
ReadIO: 3
WriteIO: 16
DiscardIO: 4
FlightIO: 0
|readio=3;; writeio=16;; discardio=4;; flightio=0;;
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment