- 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:
parent
a2bfa65904
commit
f96c0e60ff
31
check_iostat
31
check_iostat
@ -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-C <percent>\t Sets the CRITICAL 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";
|
||||
exit 1;
|
||||
}
|
||||
@ -51,13 +53,15 @@ unless ($iostat && -f $iostat) {
|
||||
|
||||
# Getting parameters:
|
||||
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 $warning = $opts{'w'};
|
||||
my $critical = $opts{'c'};
|
||||
my $warning_iowait = $opts{'W'};
|
||||
my $critical_iowait = $opts{'C'};
|
||||
my $warning_util = $opts{'X'};
|
||||
my $critical_util = $opts{'Y'};
|
||||
|
||||
VERSION_MESSAGE() if $opts{'v'};
|
||||
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) {
|
||||
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();
|
||||
}
|
||||
|
||||
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_disk = 0;
|
||||
|
||||
# Doing the actual check:
|
||||
open (IOSTAT,"-|","$iostat -k $disk 5 2");
|
||||
open (IOSTAT,"-|","$iostat -kx $disk 5 2");
|
||||
while (<IOSTAT>) {
|
||||
chomp();
|
||||
if (/^[0-9\.\ \t]+$/) {
|
||||
@ -112,7 +121,8 @@ while (<IOSTAT>) {
|
||||
$seen_disk++;
|
||||
next if $seen_disk < 2;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -132,6 +142,11 @@ if ($warning_iowait && $iowait >= $warning_iowait) {
|
||||
$status = 1;
|
||||
}
|
||||
|
||||
if ($warning_util && $util >= $warning_util) {
|
||||
$msg = "WARNING";
|
||||
$status = 1;
|
||||
}
|
||||
|
||||
if ($tps >= $crit_tps || $kbread >= $crit_read || $kbwritten >= $crit_written) {
|
||||
$msg = "CRITICAL";
|
||||
$status = 2;
|
||||
@ -142,9 +157,13 @@ if ($critical_iowait && $iowait >= $critical_iowait) {
|
||||
$status = 2;
|
||||
}
|
||||
|
||||
if ($critical_util && $iowait >= $critical_util) {
|
||||
$msg = "CRITICAL";
|
||||
$status = 2;
|
||||
}
|
||||
|
||||
# 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!
|
||||
exit $status;
|
||||
|
@ -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
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
#
|
||||
# spec file for package monitoring-plugins-sar-perf
|
||||
#
|
||||
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@ -19,11 +18,11 @@
|
||||
|
||||
Name: monitoring-plugins-sar-perf
|
||||
Summary: Get performance data from sar
|
||||
Version: 0.1
|
||||
Release: 100
|
||||
Url: https://github.com/nickanderson/check-sar-perf
|
||||
License: BSD-2-Clause
|
||||
Group: System/Monitoring
|
||||
Version: 0.1
|
||||
Release: 0
|
||||
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
|
||||
@ -35,7 +34,8 @@ Recommends: apparmor-profiles
|
||||
%endif
|
||||
Provides: nagios-plugins-sar-perf = %{version}-%{release}
|
||||
Obsoletes: nagios-plugins-sar-perf < %{version}-%{release}
|
||||
Requires: python sysstat
|
||||
Requires: python
|
||||
Requires: sysstat
|
||||
BuildArch: noarch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user