From bb1beac5535920ba53ff3f3ab0066085891092f957320cf951f4da6b054c4c72 Mon Sep 17 00:00:00 2001 From: Ruediger Oertel Date: Thu, 5 Dec 2019 13:41:57 +0000 Subject: [PATCH 1/3] - check_iostat: allow to just specify a directory OBS-URL: https://build.opensuse.org/package/show/server:monitoring/monitoring-plugins-sar-perf?expand=0&rev=18 --- check_iostat | 15 +++++++++++++++ monitoring-plugins-sar-perf.changes | 5 +++++ monitoring-plugins-sar-perf.spec | 4 ++-- usr.lib.nagios.plugins.check_iostat | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/check_iostat b/check_iostat index 91ed025..29de2f2 100644 --- a/check_iostat +++ b/check_iostat @@ -71,11 +71,26 @@ 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); + open(MOUNTS,"/proc/mounts"); + while() { + chomp($_); + my @line = split('\s+',$_); + $disk = $line[0] if $mp eq $line[1]; + } + close(MOUNTS); +} + if (! -b "/dev/$disk") { if (-b "/dev/mapper/$disk") { my @f = stat("/dev/mapper/$disk"); $f[6] %= 256; $disk = "dm-$f[6]"; + } elsif (-b $disk) { + # take as is } else { warn "ERROR: Device incorrectly specified\n"; HELP_MESSAGE(); diff --git a/monitoring-plugins-sar-perf.changes b/monitoring-plugins-sar-perf.changes index 5c1b3df..1c1e701 100644 --- a/monitoring-plugins-sar-perf.changes +++ b/monitoring-plugins-sar-perf.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +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..ba35d84 100644 --- a/usr.lib.nagios.plugins.check_iostat +++ b/usr.lib.nagios.plugins.check_iostat @@ -8,6 +8,7 @@ /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, From 0cb710c31c9baac6fd71d95f4dffb3473fb9cb7b9981266465f2561792006786 Mon Sep 17 00:00:00 2001 From: Ruediger Oertel Date: Thu, 5 Dec 2019 15:35:07 +0000 Subject: [PATCH 2/3] - check_iostat: exit with OK if running on tmpfs - check_iostat: fix apparmor profile to allow stat call OBS-URL: https://build.opensuse.org/package/show/server:monitoring/monitoring-plugins-sar-perf?expand=0&rev=19 --- check_iostat | 6 ++++++ monitoring-plugins-sar-perf.changes | 6 ++++++ usr.lib.nagios.plugins.check_iostat | 1 + 3 files changed, 13 insertions(+) diff --git a/check_iostat b/check_iostat index 29de2f2..2aadb49 100644 --- a/check_iostat +++ b/check_iostat @@ -75,6 +75,12 @@ 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($_); diff --git a/monitoring-plugins-sar-perf.changes b/monitoring-plugins-sar-perf.changes index 1c1e701..e38a303 100644 --- a/monitoring-plugins-sar-perf.changes +++ b/monitoring-plugins-sar-perf.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +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 diff --git a/usr.lib.nagios.plugins.check_iostat b/usr.lib.nagios.plugins.check_iostat index ba35d84..3e02b7d 100644 --- a/usr.lib.nagios.plugins.check_iostat +++ b/usr.lib.nagios.plugins.check_iostat @@ -5,6 +5,7 @@ #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, From 2f4e862ed2c67527146dc3c9f9ef10023d7a8e19860739535f07e0f13e98de04 Mon Sep 17 00:00:00 2001 From: Ruediger Oertel Date: Wed, 11 Dec 2019 17:11:36 +0000 Subject: [PATCH 3/3] - check_iostat: sanitize dev name to properly match iostat output OBS-URL: https://build.opensuse.org/package/show/server:monitoring/monitoring-plugins-sar-perf?expand=0&rev=20 --- check_iostat | 13 +++++++------ monitoring-plugins-sar-perf.changes | 5 +++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/check_iostat b/check_iostat index 2aadb49..e4f8978 100644 --- a/check_iostat +++ b/check_iostat @@ -90,16 +90,17 @@ if (-d "$disk") { 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]"; - } elsif (-b $disk) { - # take as is + $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 e38a303..8b19d71 100644 --- a/monitoring-plugins-sar-perf.changes +++ b/monitoring-plugins-sar-perf.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +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