Zabbix iostat Monitoring configuration
Installation and configuration of zabbix iostat Monitoring template
Configure scheduled tasks to generate statistics for iostat
Crontab-e
* / usr/local/zabbix327/bin/iostat-cron.sh
Edit / usr/local/zabbix327/bin/iostat-cron.sh
#! / bin/bash DEST_DATA=/tmp/iostat-data TMP_DATA=/tmp/iostat-data.tmp iostat- kx 10 2 > $TMP_DATA mv $TMP_DATA $DEST_DATA
Add execution permission
# chmod + x iostat-cron.sh
Edit / usr/local/zabbix327/bin/lld-iostat.sh
#! / bin/bashDEVICES= `iostat | awk'{if ($1 ~ "^ ([shxv] | xv) d [amurz] $") {print $1}} '`COUNT= `echo "$DEVICES" | wc-l`index = 0echo' {"data": ['echo "$DEVICES" | while read LINE; do echo-n' {"DEVNAME}": "'$LINE'"} 'INDEX= `expr $INDEX + 1`if [$INDEX-lt $COUNT]; then echo', 'fidoneecho']}'
Add execution permission
# chmod + x lld-iostat.sh
Edit / usr/local/zabbix327/bin/iostat.sh
#! / bin/bashZBX_REQ_DATA= "$2" ZBX_REQ_DATA_DEV= "$1" SOURCE_DATA=/tmp/iostat-dataERROR_NO_DATA_FILE= "- 0.9900" ERROR_OLD_DATA= "- 0.9901" ERROR_WRONG_PARAM= "- 0.9902" ERROR_MISSING_PARAM= "- 0.9903" if [!-f "$SOURCE_DATA"]; then echo $ERROR_NO_DATA_FILE exit 1fiif [- z "$ZBX_REQ_DATA_DEV"] Then echo $ERROR_MISSING_PARAM exit 1fiOLD_DATA=5if [$(stat-c "% Y" $SOURCE_DATA)-lt $(date-d "now-$OLD_DATA min"+% s")]; then echo $ERROR_OLD_DATA exit 1fidevicecounters $(grep-Ec "^ $ZBX_REQ_DATA_DEV" $SOURCE_DATA) if [$device_count-eq 0] Then echo $ERROR_WRONG_PARAM exit 1ficase $ZBX_REQ_DATA in rrqm/s) grep-E "^ $ZBX_REQ_DATA_DEV" $SOURCE_DATA | tail-1 | awk'{print $2}';; wrqm/s) grep-E "^ $ZBX_REQ_DATA_DEV" $SOURCE_DATA | tail-1 | awk'{print $3}';; rhand s) grep-E "^ $ZBX_REQ_DATA_DEV" $SOURCE_DATA | tail-1 | awk'{print $4}' Grep-E "^ $ZBX_REQ_DATA_DEV" $SOURCE_DATA | tail-1 | awk'{print $5}';; rkB/s) grep-E "^ $ZBX_REQ_DATA_DEV" $SOURCE_DATA | tail-1 | awk'{print $6}';; wkB/s) grep-E "^ $ZBX_REQ_DATA_DEV" $SOURCE_DATA | tail-1 | awk'{print $7}' Avgrq-sz) grep-E "^ $ZBX_REQ_DATA_DEV" $SOURCE_DATA | tail-1 | awk'{print $8}';; avgqu-sz) grep-E "^ $ZBX_REQ_DATA_DEV" $SOURCE_DATA | tail-1 | awk'{print $9}';; await) grep-E "^ $ZBX_REQ_DATA_DEV" $SOURCE_DATA | tail-1 | awk'{print $10}' Svctm) grep-E "^ $ZBX_REQ_DATA_DEV" $SOURCE_DATA | tail-1 | awk'{print $11}';;% util) grep-E "^ $ZBX_REQ_DATA_DEV" $SOURCE_DATA | tail-1 | awk'{print $12}';; *) echo $ERROR_WRONG_PARAM; exit 1 against esacexit 0
Add execution permission
# chmod + x iostat.sh
test
Check whether the files under / tmp/: iostat-data and iostat-data.tmp are generated.
Test whether the script executes correctly under the zabbix user:
$. / lld-iostat.sh
$. / iostat.sh hda wplink s
Edit zabbix agentd configuration file and add custom parameters, including lld parameters and monitoring parameters
UserParameter=custom.vfs.dev.discovery,/usr/local/zabbix327/bin/lld-iostat.sh UserParameter=iostat [*], / usr/local/zabbix327/bin/iostat.sh $1 $2
Configuration template / Import template
Name: $1 $2 / * $1 represents the first parameter of Key $2 represents the second parameter of Key * * /
Key: iostat [{# DEVNAME}, svctm]
Type of information: Numberic (float)
Applications: iostat
Name: Disk Devices
Key: custom.vfs.dev.discovery
Update interval: 60
Configuration/Templates, click Create template, enter the name of the template, select Groups, and save
Select Discovery rules, click Create discovery rule, fill in the necessary information, and save it.
Select Discovery rules, click Item prototypes in the list, click the Create item prototype button, and save it after the configuration is complete.
Configure the following Item prototype as above (only need to modify the second parameter of Key):
% util,rkB/s,avgqu-sz,await,wkB/s, rrqm/s, wrqm/s,r/s
Select Trigger prototypes tab to configure Trigger prototypes as needed, and click Create trigger prototype. Here is the key description, Expression section, click the Add button, in the pop-up window, click Select prototype, select the monitoring item, and then configure other items. Finally, click Save.