- use -x for iostat and add utilization monitoring

OBS-URL: https://build.opensuse.org/package/show/server:monitoring/monitoring-plugins-sar-perf?expand=0&rev=7
This commit is contained in:
Ruediger Oertel 2017-04-24 10:33:47 +00:00 committed by Git OBS Bridge
parent a2bfa65904
commit f96c0e60ff
3 changed files with 36 additions and 12 deletions

View File

@ -40,6 +40,8 @@ sub HELP_MESSAGE {
print "\t-w <tps>,<read>,<wrtn>\tSets the WARNING level for tps, KB_read/s and KB_written/s, respectively\n"; print "\t-w <tps>,<read>,<wrtn>\tSets the WARNING level for tps, KB_read/s and KB_written/s, respectively\n";
print "\t-C <percent>\t Sets the CRITICAL level for iowait\n"; print "\t-C <percent>\t Sets the CRITICAL level for iowait\n";
print "\t-W <percent>\t Sets the WARNING level for iowait\n"; print "\t-W <percent>\t Sets the WARNING level for iowait\n";
print "\t-X <percent>\t Sets the CRITICAL level for utilization\n";
print "\t-Y <percent>\t Sets the WARNING level for utilization\n";
print "\t\t\t(if no level is set for iowait, no warning is set for this value)\n"; print "\t\t\t(if no level is set for iowait, no warning is set for this value)\n";
exit 1; exit 1;
} }
@ -51,13 +53,15 @@ unless ($iostat && -f $iostat) {
# Getting parameters: # Getting parameters:
my %opts; my %opts;
getopts('d:w:c:W:C:hv', \%opts); getopts('d:w:c:W:C:X:Y:hv', \%opts);
my $disk = $opts{'d'}; my $disk = $opts{'d'};
my $warning = $opts{'w'}; my $warning = $opts{'w'};
my $critical = $opts{'c'}; my $critical = $opts{'c'};
my $warning_iowait = $opts{'W'}; my $warning_iowait = $opts{'W'};
my $critical_iowait = $opts{'C'}; my $critical_iowait = $opts{'C'};
my $warning_util = $opts{'X'};
my $critical_util = $opts{'Y'};
VERSION_MESSAGE() if $opts{'v'}; VERSION_MESSAGE() if $opts{'v'};
HELP_MESSAGE() if $opts{'h'}; HELP_MESSAGE() if $opts{'h'};
@ -89,16 +93,21 @@ if ($warn_tps > $crit_tps || $warn_read > $crit_read || $warn_written > $crit_wr
} }
if ($warning_iowait && $critical_iowait && $warning_iowait > $critical_iowait) { if ($warning_iowait && $critical_iowait && $warning_iowait > $critical_iowait) {
warn "ERROR: critical iowait level must be higher that warning level\n"; warn "ERROR: critical iowait level must be higher than warning level\n";
HELP_MESSAGE(); HELP_MESSAGE();
} }
my ($tps,$kbread,$kbwritten,$iowait); if ($warning_util && $critical_util && $warning_util > $critical_util) {
warn "ERROR: critical utilization level must be higher than warning level\n";
HELP_MESSAGE();
}
my ($tps,$rps,$wps,$kbread,$kbwritten,$iowait,$util);
my $seen_usage = 0; my $seen_usage = 0;
my $seen_disk = 0; my $seen_disk = 0;
# Doing the actual check: # Doing the actual check:
open (IOSTAT,"-|","$iostat -k $disk 5 2"); open (IOSTAT,"-|","$iostat -kx $disk 5 2");
while (<IOSTAT>) { while (<IOSTAT>) {
chomp(); chomp();
if (/^[0-9\.\ \t]+$/) { if (/^[0-9\.\ \t]+$/) {
@ -112,7 +121,8 @@ while (<IOSTAT>) {
$seen_disk++; $seen_disk++;
next if $seen_disk < 2; next if $seen_disk < 2;
my (@stats) = split ('\s+', $_); my (@stats) = split ('\s+', $_);
($tps,$kbread,$kbwritten) = @stats[1,2,3]; ($rps,$wps,$kbread,$kbwritten,$util) = @stats[1,2,5,6,13];
$tps = $rps + $wps;
last; last;
} }
} }
@ -132,6 +142,11 @@ if ($warning_iowait && $iowait >= $warning_iowait) {
$status = 1; $status = 1;
} }
if ($warning_util && $util >= $warning_util) {
$msg = "WARNING";
$status = 1;
}
if ($tps >= $crit_tps || $kbread >= $crit_read || $kbwritten >= $crit_written) { if ($tps >= $crit_tps || $kbread >= $crit_read || $kbwritten >= $crit_written) {
$msg = "CRITICAL"; $msg = "CRITICAL";
$status = 2; $status = 2;
@ -142,9 +157,13 @@ if ($critical_iowait && $iowait >= $critical_iowait) {
$status = 2; $status = 2;
} }
if ($critical_util && $iowait >= $critical_util) {
$msg = "CRITICAL";
$status = 2;
}
# Printing the results: # Printing the results:
print "$msg - I/O stats tps=$tps KB_read/s=$kbread KB_written/s=$kbwritten iowait=$iowait | 'tps'=$tps; 'KB_read/s'=$kbread; 'KB_written/s'=$kbwritten; 'iowait'=$iowait\n"; print "$msg - I/O stats tps=$tps KB_read/s=$kbread KB_written/s=$kbwritten iowait=$iowait | 'tps'=$tps; 'KB_read/s'=$kbread; 'KB_written/s'=$kbwritten; 'iowait'=$iowait; 'util'=$util\n";
# Bye! # Bye!
exit $status; exit $status;

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Mon Apr 24 12:33:08 CEST 2017 - ro@suse.de
- use -x for iostat and add utilization monitoring
------------------------------------------------------------------- -------------------------------------------------------------------
Fri Oct 30 15:01:40 UTC 2015 - lars@linux-schulserver.de Fri Oct 30 15:01:40 UTC 2015 - lars@linux-schulserver.de

View File

@ -1,8 +1,7 @@
# #
# spec file for package monitoring-plugins-sar-perf # spec file for package monitoring-plugins-sar-perf
# #
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. # Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@ -19,11 +18,11 @@
Name: monitoring-plugins-sar-perf Name: monitoring-plugins-sar-perf
Summary: Get performance data from sar Summary: Get performance data from sar
Version: 0.1
Release: 100
Url: https://github.com/nickanderson/check-sar-perf
License: BSD-2-Clause License: BSD-2-Clause
Group: System/Monitoring Group: System/Monitoring
Version: 0.1
Release: 0
Url: https://github.com/nickanderson/check-sar-perf
Source0: nickanderson-check-sar-perf-4878d0c.tar.gz Source0: nickanderson-check-sar-perf-4878d0c.tar.gz
Source1: check_iostat Source1: check_iostat
Source2: usr.lib.nagios.plugins.check_iostat Source2: usr.lib.nagios.plugins.check_iostat
@ -35,7 +34,8 @@ Recommends: apparmor-profiles
%endif %endif
Provides: nagios-plugins-sar-perf = %{version}-%{release} Provides: nagios-plugins-sar-perf = %{version}-%{release}
Obsoletes: nagios-plugins-sar-perf < %{version}-%{release} Obsoletes: nagios-plugins-sar-perf < %{version}-%{release}
Requires: python sysstat Requires: python
Requires: sysstat
BuildArch: noarch BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build