diff --git a/check_iostat b/check_iostat index 91ed025..e4f8978 100644 --- a/check_iostat +++ b/check_iostat @@ -71,14 +71,36 @@ my ($crit_tps,$crit_read,$crit_written) = split(',',$critical); my ($warn_tps,$warn_read,$warn_written) = split(',',$warning); # Checking parameters: +if (-d "$disk") { + # directory specified ... + my $mp = `stat --format '\%m' $disk`; + chomp($mp); + my $fstype = `stat --file-system --format '\%T' $mp`; + chomp($fstype); + if ($fstype eq "tmpfs") { + print "OK - $disk (mountpoint $mp is tmpfs)\n"; + exit 0; + } + open(MOUNTS,"/proc/mounts"); + while() { + chomp($_); + my @line = split('\s+',$_); + $disk = $line[0] if $mp eq $line[1]; + } + close(MOUNTS); +} + +$disk =~ s/^\/dev\/mapper\///; +$disk =~ s/^\/dev\///; + if (! -b "/dev/$disk") { if (-b "/dev/mapper/$disk") { my @f = stat("/dev/mapper/$disk"); - $f[6] %= 256; - $disk = "dm-$f[6]"; + $f[6] %= 256; + $disk = "dm-$f[6]"; } else { - warn "ERROR: Device incorrectly specified\n"; - HELP_MESSAGE(); + warn "ERROR: Device incorrectly specified\n"; + HELP_MESSAGE(); } } diff --git a/monitoring-plugins-sar-perf.changes b/monitoring-plugins-sar-perf.changes index 5c1b3df..8b19d71 100644 --- a/monitoring-plugins-sar-perf.changes +++ b/monitoring-plugins-sar-perf.changes @@ -1,3 +1,19 @@ +------------------------------------------------------------------- +Wed Dec 11 18:10:48 CET 2019 - ro@suse.de + +- check_iostat: sanitize dev name to properly match iostat output + +------------------------------------------------------------------- +Thu Dec 5 16:34:19 CET 2019 - ro@suse.de + +- check_iostat: exit with OK if running on tmpfs +- check_iostat: fix apparmor profile to allow stat call + +------------------------------------------------------------------- +Thu Dec 5 14:40:38 CET 2019 - ro@suse.de + +- check_iostat: allow to just specify a directory + ------------------------------------------------------------------- Sun Apr 14 16:06:32 UTC 2019 - Christian Boltz diff --git a/monitoring-plugins-sar-perf.spec b/monitoring-plugins-sar-perf.spec index 31f0c91..cd4ad79 100644 --- a/monitoring-plugins-sar-perf.spec +++ b/monitoring-plugins-sar-perf.spec @@ -1,7 +1,7 @@ # # spec file for package monitoring-plugins-sar-perf # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -22,7 +22,7 @@ License: BSD-2-Clause Group: System/Monitoring Version: 0.1 Release: 0 -Url: https://github.com/nickanderson/check-sar-perf +URL: https://github.com/nickanderson/check-sar-perf Source0: nickanderson-check-sar-perf-4878d0c.tar.gz Source1: check_iostat Source2: usr.lib.nagios.plugins.check_iostat diff --git a/usr.lib.nagios.plugins.check_iostat b/usr.lib.nagios.plugins.check_iostat index 90e587e..3e02b7d 100644 --- a/usr.lib.nagios.plugins.check_iostat +++ b/usr.lib.nagios.plugins.check_iostat @@ -5,9 +5,11 @@ #include /usr/bin/iostat rix, /{usr/,}bin/bash rix, + /{usr/,}bin/stat rix, /usr/bin/which rix, /sys/devices/system/cpu/ r, /proc/meminfo r, + @{PROC}/[0-9]*/mounts r, /proc/diskstats r, /proc/uptime r, /etc/sysstat/sysstat.ioconf r,