osc copypac from project:server:monitoring package:nagios-plugins-sar-perf revision:10
OBS-URL: https://build.opensuse.org/package/show/server:monitoring/monitoring-plugins-sar-perf?expand=0&rev=1
This commit is contained in:
commit
af43822f8a
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
## Default LFS
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.osc
|
150
check_iostat
Normal file
150
check_iostat
Normal file
@ -0,0 +1,150 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
#
|
||||
# Version 0.0.2 - Jan/2009
|
||||
# Changes: added device verification
|
||||
#
|
||||
# by Thiago Varela - thiago@iplenix.com
|
||||
|
||||
# Version 0.1 - Nov/2011
|
||||
# by Ruediger Oertel ro@suse.de
|
||||
# Changes:
|
||||
# - rewrite in perl, no need for external grep, awk, bc
|
||||
# - add output for iowait
|
||||
# - implement using device mapper names, e.g. $vg-$lv
|
||||
|
||||
use strict;
|
||||
use Getopt::Std;
|
||||
|
||||
$Getopt::Std::STANDARD_HELP_VERSION = "true";
|
||||
|
||||
my $iostat = `which iostat 2>/dev/null`;
|
||||
chomp($iostat);
|
||||
|
||||
my $progname = $0;
|
||||
|
||||
|
||||
# call it VERSION_MESSAGE so that getopts uses it automatically
|
||||
sub VERSION_MESSAGE {
|
||||
print "$progname: version 0.1, Nov/2011\n";
|
||||
}
|
||||
|
||||
# call it HELP_MESSAGE so that getopts uses it automatically
|
||||
sub HELP_MESSAGE {
|
||||
print "\n\tThis plugin shows the I/O usage of the specified disk, using the iostat external program.\n";
|
||||
print "\tIt prints three statistics: Transactions per second (tps), Kilobytes per second\n";
|
||||
print "tread from the disk (KB_read/s) and and written to the disk (KB_written/s)\n\n";
|
||||
print "$progname:\n\t-d <disk>\t\tDevice to be checked (without the full path, eg. sda)\n";
|
||||
print "\t\t\t\t(also accepted are device mapper names)\n";
|
||||
print "\t-c <tps>,<read>,<wrtn>\tSets the CRITICAL 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-W <percent>\t Sets the WARNING level for iowait\n";
|
||||
print "\t\t\t(if no level is set for iowait, no warning is set for this value)\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
unless ($iostat && -f $iostat) {
|
||||
warn "ERROR: You must have iostat installed in order to run this plugin\n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
# Getting parameters:
|
||||
my %opts;
|
||||
getopts('d:w:c:W:C:hv', \%opts);
|
||||
|
||||
my $disk = $opts{'d'};
|
||||
my $warning = $opts{'w'};
|
||||
my $critical = $opts{'c'};
|
||||
my $warning_iowait = $opts{'W'};
|
||||
my $critical_iowait = $opts{'C'};
|
||||
|
||||
VERSION_MESSAGE() if $opts{'v'};
|
||||
HELP_MESSAGE() if $opts{'h'};
|
||||
|
||||
# Adjusting the three warn and crit levels:
|
||||
my ($crit_tps,$crit_read,$crit_written) = split(',',$critical);
|
||||
my ($warn_tps,$warn_read,$warn_written) = split(',',$warning);
|
||||
|
||||
# Checking parameters:
|
||||
if (! -b "/dev/$disk") {
|
||||
if (-b "/dev/mapper/$disk") {
|
||||
my @f = stat("/dev/mapper/$disk");
|
||||
$f[6] %= 256;
|
||||
$disk = "dm-$f[6]";
|
||||
} else {
|
||||
warn "ERROR: Device incorrectly specified\n";
|
||||
HELP_MESSAGE();
|
||||
}
|
||||
}
|
||||
|
||||
unless ($warn_tps && $warn_read && $warn_written && $crit_tps && $crit_read && $crit_written) {
|
||||
warn "ERROR: You must specify all warning and critical levels\n";
|
||||
HELP_MESSAGE();
|
||||
}
|
||||
|
||||
if ($warn_tps > $crit_tps || $warn_read > $crit_read || $warn_written > $crit_written) {
|
||||
warn "ERROR: critical levels must be highter than warning levels\n";
|
||||
HELP_MESSAGE();
|
||||
}
|
||||
|
||||
if ($warning_iowait && $critical_iowait && $warning_iowait > $critical_iowait) {
|
||||
warn "ERROR: critical iowait level must be higher that warning level\n";
|
||||
HELP_MESSAGE();
|
||||
}
|
||||
|
||||
my ($tps,$kbread,$kbwritten,$iowait);
|
||||
my $seen_usage = 0;
|
||||
my $seen_disk = 0;
|
||||
|
||||
# Doing the actual check:
|
||||
open (IOSTAT,"-|","$iostat -k $disk 5 2");
|
||||
while (<IOSTAT>) {
|
||||
chomp();
|
||||
if (/^[0-9\.\ \t]+$/) {
|
||||
$seen_usage++;
|
||||
next if $seen_usage < 2;
|
||||
my (@stats) = split ('\s+', $_);
|
||||
$iowait = $stats[4];
|
||||
next;
|
||||
}
|
||||
if (/^$disk /) {
|
||||
$seen_disk++;
|
||||
next if $seen_disk < 2;
|
||||
my (@stats) = split ('\s+', $_);
|
||||
($tps,$kbread,$kbwritten) = @stats[1,2,3];
|
||||
last;
|
||||
}
|
||||
}
|
||||
close (IOSTAT);
|
||||
|
||||
my $msg = "OK";
|
||||
my $status = 0;
|
||||
|
||||
# Comparing the result and setting the correct level:
|
||||
if ($tps >= $warn_tps || $kbread >= $warn_read || $kbwritten >= $warn_written) {
|
||||
$msg = "WARNING";
|
||||
$status = 1;
|
||||
}
|
||||
|
||||
if ($warning_iowait && $iowait >= $warning_iowait) {
|
||||
$msg = "WARNING";
|
||||
$status = 1;
|
||||
}
|
||||
|
||||
if ($tps >= $crit_tps || $kbread >= $crit_read || $kbwritten >= $crit_written) {
|
||||
$msg = "CRITICAL";
|
||||
$status = 2;
|
||||
}
|
||||
|
||||
if ($critical_iowait && $iowait >= $critical_iowait) {
|
||||
$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";
|
||||
|
||||
# Bye!
|
||||
exit $status;
|
14
nagios-plugins-sar-perf-output.patch
Normal file
14
nagios-plugins-sar-perf-output.patch
Normal file
@ -0,0 +1,14 @@
|
||||
Index: check_sar_perf.py
|
||||
===================================================================
|
||||
--- check_sar_perf.py.orig
|
||||
+++ check_sar_perf.py
|
||||
@@ -99,7 +99,8 @@ class SarNRPE:
|
||||
# Create dictionary
|
||||
for i in range(len(columns)):
|
||||
# Remove first column if data contains only letters
|
||||
- if i != 0 or not search.match(data[i]):
|
||||
+ #if i != 0 or not search.match(data[i]):
|
||||
+ if (i != 0 or not search.match(data[i])) and (columns[i] != "DEV"):
|
||||
# Remove characters that cause issues (%/)
|
||||
badchars=['%','/']
|
||||
columns[i] = ''.join(j for j in columns[i] if j not in badchars)
|
19
nagios-plugins-sar-perf-stdout.patch
Normal file
19
nagios-plugins-sar-perf-stdout.patch
Normal file
@ -0,0 +1,19 @@
|
||||
Index: check_sar_perf.py
|
||||
===================================================================
|
||||
--- check_sar_perf.py.orig
|
||||
+++ check_sar_perf.py
|
||||
@@ -153,11 +153,12 @@ def Main(args):
|
||||
else:
|
||||
sar = SarNRPE(myOpts[args[1]])
|
||||
else:
|
||||
- print 'ERROR: option not defined'
|
||||
+ print 'ERROR: option ',args[1],' not defined'
|
||||
sys.exit(ERR_UNKN)
|
||||
|
||||
# Output in NRPE format
|
||||
- print 'sar OK|', ' '.join(sar.stats)
|
||||
+ args[0]=''
|
||||
+ print 'sar OK: ',' '.join(args),'|', ' '.join(sar.stats)
|
||||
|
||||
if __name__ == '__main__':
|
||||
Main(sys.argv)
|
54
nagios-plugins-sar-perf.changes
Normal file
54
nagios-plugins-sar-perf.changes
Normal file
@ -0,0 +1,54 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Nov 9 16:57:05 CET 2012 - ro@suse.de
|
||||
|
||||
- check_iostat: use 5 seconds instead of 2 to get more useful data
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Mon Nov 28 14:26:57 CET 2011 - ro@suse.de
|
||||
|
||||
- check_iostat: add warning and critical levels for iowait
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Nov 26 19:41:38 CET 2011 - ro@suse.de
|
||||
|
||||
- check_iostat: actually check current io stats, not since boot
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sat Nov 26 00:59:35 CET 2011 - ro@suse.de
|
||||
|
||||
- more additions to check_iostat: can use device-mapper name
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Nov 25 12:51:48 CET 2011 - ro@suse.de
|
||||
|
||||
- rewrite check_iostat in perl, also output iowait value
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Nov 25 10:51:16 CET 2011 - ro@suse.de
|
||||
|
||||
- add requires sysstat
|
||||
- check_iostat: call iostat with "-k" to really display kb
|
||||
instead of blocks as unit
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Nov 24 16:26:58 UTC 2011 - lars@linux-schulserver.de
|
||||
|
||||
- added check_iostat
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Oct 4 15:27:09 UTC 2011 - lars@linux-schulserver.de
|
||||
|
||||
- also print the used arguments as output to STDOUT, so the user
|
||||
knows what is mesured (nagios-plugins-sar-perf-stdout.patch)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Oct 4 12:59:33 UTC 2011 - lars@linux-schulserver.de
|
||||
|
||||
- added nagios-plugins-sar-perf-output.patch :
|
||||
do not print DEV name for disk in performance output
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Sun Jul 24 10:05:07 UTC 2011 - lars@linux-schulserver.de
|
||||
|
||||
- initial version (git commit 4878d0cc66e928bd1075) defined as 0.1
|
||||
|
72
nagios-plugins-sar-perf.spec
Normal file
72
nagios-plugins-sar-perf.spec
Normal file
@ -0,0 +1,72 @@
|
||||
#
|
||||
# spec file for package nagios-plugins-sar-perf
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
# upon. The license for this file, and modifications and additions to the
|
||||
# file, is the same license as for the pristine package itself (unless the
|
||||
# license for the pristine package is not an Open Source License, in which
|
||||
# case the license is the MIT License). An "Open Source License" is a
|
||||
# license that conforms to the Open Source Definition (Version 1.9)
|
||||
# published by the Open Source Initiative.
|
||||
|
||||
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||||
#
|
||||
|
||||
# norootforbuild
|
||||
|
||||
|
||||
Name: nagios-plugins-sar-perf
|
||||
Summary: NRPE plugin to get performance data from sar
|
||||
Version: 0.1
|
||||
Release: 1
|
||||
Url: https://github.com/nickanderson/check-sar-perf
|
||||
License: GPL
|
||||
Group: System/Monitoring
|
||||
Source0: nickanderson-check-sar-perf-4878d0c.tar.gz
|
||||
Source1: check_iostat
|
||||
Patch0: nagios-plugins-sar-perf-output.patch
|
||||
Patch1: nagios-plugins-sar-perf-stdout.patch
|
||||
Requires: python sysstat
|
||||
BuildArch: noarch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||
%define libexecdir %_prefix/lib/nagios/plugins
|
||||
|
||||
%description
|
||||
This plug-in was written to get performance data from sar. It was developed for
|
||||
use with Zenoss but should work with other NRPE compatible NMS.
|
||||
|
||||
Example output:
|
||||
|
||||
check_sar_perf cpu
|
||||
sar OK| CPU=all user=59.90 nice=0.00 system=4.46 iowait=0.00 steal=0.00
|
||||
idle=35.64
|
||||
|
||||
check_sar_perf disk sda
|
||||
sar OK| DEV=sda tps=0.00 rd_sec/s=0.00 wr_sec/s=0.00 avgrq-sz=0.00
|
||||
avgqu-sz=0.00 await=0.00 svctm=0.00 util=0.00
|
||||
|
||||
|
||||
%prep
|
||||
%setup -q -n nickanderson-check-sar-perf-4878d0c
|
||||
%patch0 -p0
|
||||
%patch1 -p0
|
||||
|
||||
%build
|
||||
|
||||
%install
|
||||
install -D -m755 check_sar_perf.py %{buildroot}/%{libexecdir}/check_sar_perf
|
||||
install -m755 %{SOURCE1} %{buildroot}/%{libexecdir}/check_iostat
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
# avoid build dependecy of nagios - own the dirs
|
||||
%dir %{_prefix}/lib/nagios
|
||||
%dir %{libexecdir}
|
||||
%{libexecdir}/check_sar_perf
|
||||
%{libexecdir}/check_iostat
|
||||
|
||||
%changelog
|
3
nickanderson-check-sar-perf-4878d0c.tar.gz
Normal file
3
nickanderson-check-sar-perf-4878d0c.tar.gz
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:4c76642e2dfc208fe0e699f6fdc55231d9839f2bfd55cb6371c63cf5ad8be5ed
|
||||
size 3308
|
Loading…
Reference in New Issue
Block a user