Zabbix monitor DISK I/O

Zabbix disk i/o template:
zbx_linux_disk_io_template.xml.tar

Auto discovery script for zabbix agents written in perl:

#!/usr/bin/perl
use strict;
use warnings;

# Options
my $_proc = “/proc/diskstats”;

# Validate options
if ( ! -e $_proc)
{
die “File $_proc not found!”;
}

# Keep count
my $_first = 1;

# Present the data in JSON format
print “{\n”;
print “\t\”data\”:[\n\n”;

# Fetch the data and put it in an array
my @_data = `cat $_proc | awk ‘{ print \$3 }’`;
chomp @_data;

# Read the array and print the wanted data
foreach my $_disk (@_data)
{
# Print the data in JSON
print “\t,\n” if not $_first;
$_first = 0;

print “\t{\n”;
print “\t\t\”{#DISK}\”:\”$_disk\”\n”;
print “\n\t}\n”;
}

print “\n\t]\n”;
print “}\n”;

Zabbix userparameter_linux_disks.conf:

# See https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats
#
# reads completed successfully
UserParameter=custom.vfs.dev.read.ops[*],cat /proc/diskstats | egrep $1 | head -1 | awk ‘{print $$4}’
# sectors read
UserParameter=custom.vfs.dev.read.sectors[*],cat /proc/diskstats | egrep $1 | head -1 | awk ‘{print $$6}’
# time spent reading (ms)
UserParameter=custom.vfs.dev.read.ms[*],cat /proc/diskstats | egrep $1 | head -1 | awk ‘{print $$7}’
# writes completed
UserParameter=custom.vfs.dev.write.ops[*],cat /proc/diskstats | egrep $1 | head -1 | awk ‘{print $$8}’
# sectors written
UserParameter=custom.vfs.dev.write.sectors[*],cat /proc/diskstats | egrep $1 | head -1 | awk ‘{print $$10}’
# time spent writing (ms)
UserParameter=custom.vfs.dev.write.ms[*],cat /proc/diskstats | egrep $1 | head -1 | awk ‘{print $$11}’
# I/Os currently in progress
UserParameter=custom.vfs.dev.io.active[*],cat /proc/diskstats | egrep $1 | head -1 | awk ‘{print $$12}’
# time spent doing I/Os (ms)
UserParameter=custom.vfs.dev.io.ms[*],cat /proc/diskstats | egrep $1 | head -1 | awk ‘{print $$13}’

Full article there:

http://www.denniskanbier.nl/blog/monitoring/monitoring-disk-io-using-zabbix/

Leave a Reply

Your email address will not be published. Required fields are marked *