osc copypac from project:server:monitoring package:nagios-plugins-count_file revision:1

OBS-URL: https://build.opensuse.org/package/show/server:monitoring/monitoring-plugins-count_file?expand=0&rev=1
This commit is contained in:
Lars Vogdt 2014-07-30 19:14:41 +00:00 committed by Git OBS Bridge
commit bc787d1071
5 changed files with 150 additions and 0 deletions

23
.gitattributes vendored Normal file
View 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
View File

@ -0,0 +1 @@
.osc

60
count_file.pl Normal file
View File

@ -0,0 +1,60 @@
#!/usr/bin/perl -w
## $Id: count_file.pl 232 2006-10-01 15:23:55Z touche $
## julien.touche@touche.fr.st
##
## modified from http://answers.tveasy.co.uk/c.l.p.misc/count-fd.htm
use strict;
$ENV{'PATH'}='';
$ENV{'BASH_ENV'}='';
$ENV{'ENV'}='';
#use lib "/usr/local/libexec/nagios";
#use lib "T:\\sysshare\\unattended\\install\\packages\\admin\\nrpe_nt\\bin\\utils.pm";
#use utils qw(%ERRORS);
if($#ARGV+1!=3 || ! -d $ARGV[0]){
print "Usage: \"Filename\" \"Critical number of files\" \"Warning number of files\"\n";
print " examples: $0 <dir> 1 10\n";
print " examples: $0 <dir> 3:10 1:3\n";
exit 0;
}
my $exit=0;
my ($dir,$maxwarn,$maxcrit,$minwarn,$mincrit);
$dir = $ARGV[0];
$maxcrit = $ARGV[1];
if ($maxcrit =~ m/([0-9].+):([0-9].+)/) {
$mincrit = $1;
$maxcrit = $2;
}
$maxwarn = $ARGV[2];
if ($maxwarn =~ m/([0-9].+):([0-9].+)/) {
$minwarn = $1;
$maxwarn = $2;
}
my ($count);
opendir DIR, $dir or die "Could not opendir $dir; Reason: $!";
my @files = grep !/^\.\.?$/ => readdir DIR;
$count = @files ;
closedir DIR;
if ($count>$maxcrit) {
print "Critical: Filecount of '$dir' too large $count > $maxcrit.\n";$exit=2;
} elsif (defined($mincrit) && $count < $mincrit) {
print "Critical: Filecount of '$dir' too small $count < $mincrit.\n";$exit=2;
} elsif ($count>$maxwarn) {
print "Warning: Filecount of '$dir' $count > $maxwarn.\n";$exit=1;
} elsif (defined($minwarn) && $count < $minwarn) {
print "Warning: Filecount of '$dir' $count < $minwarn.\n";$exit=1;
} else {
print "OK: Filecount of '$dir' $count.\n"; $exit = 0;
}
exit $exit;

View File

@ -0,0 +1,5 @@
-------------------------------------------------------------------
Sun Jan 12 15:40:50 UTC 2014 - lars@linux-schulserver.de
- initial version 232

View File

@ -0,0 +1,61 @@
#
# spec file for package nagios-plugins-count_file
#
# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# 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/
#
Name: nagios-plugins-count_file
Version: 232
Release: 0
License: BSD-4-Clause
Summary: Counts the number of files in a directory
Url: https://www.monitoringexchange.org/inventory/Check-Plugins/Operating-Systems/Linux/count_file
Group: System/Monitoring
Source0: count_file.pl
BuildRequires: nagios-rpm-macros
Requires: perl
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Use this plugin to count the number of files in a directory and
issue a warning or critical state if the number exceeds a limit.
Useful if you want to monitor for example:
* a directory which contains error files and must stay empty
* a tmp dir which have to stay under a practical limit
Usage: <filename> <Critical number of files> <Warning number of files>
Examples: count_file.pl 1 10
Examples: count_file.pl 3:10 1:3
%prep
#
%build
#
%install
install -Dm755 %{SOURCE0} %buildroot/%{nagios_plugindir}/count_file.pl
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root)
# avoid build dependecy of nagios - own the dirs
%dir %{nagios_libdir}
%dir %{nagios_plugindir}
%{nagios_plugindir}/count_file.pl
%changelog