commit 2a6e2ce6d227b35101ec6feece12da1c31ca11cc7568db4cd72a6f8c1ee0852b Author: Lars Vogdt Date: Wed Jul 30 19:17:00 2014 +0000 osc copypac from project:server:monitoring package:nagios-plugins-mailstat revision:3 OBS-URL: https://build.opensuse.org/package/show/server:monitoring/monitoring-plugins-mailstat?expand=0&rev=1 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..9b03811 --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..57affb6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.osc diff --git a/check_mailstat_plugin_v0.9.1-initial_values.patch b/check_mailstat_plugin_v0.9.1-initial_values.patch new file mode 100644 index 0000000..45e257b --- /dev/null +++ b/check_mailstat_plugin_v0.9.1-initial_values.patch @@ -0,0 +1,14 @@ +Index: check_mailstat_plugin_v0.9.1/check_mailstat.pl +=================================================================== +--- check_mailstat_plugin_v0.9.1.orig/check_mailstat.pl ++++ check_mailstat_plugin_v0.9.1/check_mailstat.pl +@@ -217,6 +217,9 @@ sub get_counter{ + $stat{$k} = $msgs_per_min; + } + } ++ else { ++ %stat=%stat_new; ++ } + + #write new stat to old file + open(my $stath_old, ">", $stat_old) or plugin_die "Can't open file $stat_old to write: $!"; diff --git a/check_mailstat_plugin_v0.9.1-stat_file.patch b/check_mailstat_plugin_v0.9.1-stat_file.patch new file mode 100644 index 0000000..5869e7b --- /dev/null +++ b/check_mailstat_plugin_v0.9.1-stat_file.patch @@ -0,0 +1,45 @@ +Index: check_mailstat_plugin_v0.9.1/check_mailstat.pl +=================================================================== +--- check_mailstat_plugin_v0.9.1.orig/check_mailstat.pl ++++ check_mailstat_plugin_v0.9.1/check_mailstat.pl +@@ -49,7 +49,6 @@ my @warn; + my @critical; + + my $stat_file = '/var/tmp/mailstat'; +-my $stat_old = $stat_file. ".old"; + + sub usage; + sub get_counter; +@@ -73,6 +72,7 @@ $status = GetOptions( + "V|version" => \$opt_V, + "h|help" => \$opt_h, + "w|warning=s" => \$opt_w, ++ "s|statfile=s" => \$stat_file, + "c|critical=s" => \$opt_c,); + + if ($status == 0) +@@ -92,6 +92,7 @@ if ($opt_h) { + exit $ERRORS{'OK'}; + } + ++my $stat_old = $stat_file. ".old"; + my @stat_counter = get_counter(); + $answer = stat_str(@stat_counter); + my $perfdata = sprintf "sent=%-6.2f received=%-6.2f bounced=%-6.2f rejected=%-6.2f virus=%-6.2f spam=%-6.2f", @stat_counter; +@@ -145,7 +146,7 @@ exit $ERRORS{$state}; + + sub usage { + print "\nUsage:\n"; +- print "$PROGNAME -w -c \n"; ++ print "$PROGNAME -w -c -s $stat_file\n"; + print "THRESHOLD: sent:received:bounced:rejected:virus:spam\n"; + print " if no threshold for a specific counter, set it to 0\n"; + print " measured by messages per minute\n"; +@@ -163,6 +164,7 @@ sub print_help { + print "\nOptions:\n"; + print " -w,--warning=THRESHOLD Return WARN if exceed the thresolds\n"; + print " -c,--critical=THRESHOLD Retrun CRITICAL if exceed the thresholds\n"; ++ print " -s,--statfile= Full path to statistic file from mailgraph (default: /var/tmp/mailstat)\n"; + print " -V (--Version) Plugin version\n"; + print " -v (--verbose) Enable verbose output\n"; + print " -h (--help) Usage help \n\n"; diff --git a/check_mailstat_plugin_v0.9.1.zip b/check_mailstat_plugin_v0.9.1.zip new file mode 100644 index 0000000..7c11b84 --- /dev/null +++ b/check_mailstat_plugin_v0.9.1.zip @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2a8e8be172bd71f7b3c5b81b77b6fcddf31f8c2e765050c4b72f5d8caf930ca5 +size 5750 diff --git a/nagios-plugins-mailstat-rpmlintrc b/nagios-plugins-mailstat-rpmlintrc new file mode 100644 index 0000000..2e559e2 --- /dev/null +++ b/nagios-plugins-mailstat-rpmlintrc @@ -0,0 +1 @@ +addFilter("non-etc-or-var-file-marked-as-conffile /usr/share/pnp4nagios/templates/check_mailstat.php"); diff --git a/nagios-plugins-mailstat.changes b/nagios-plugins-mailstat.changes new file mode 100644 index 0000000..69e9642 --- /dev/null +++ b/nagios-plugins-mailstat.changes @@ -0,0 +1,7 @@ +------------------------------------------------------------------- +Thu Jun 19 20:00:14 UTC 2014 - lars@linux-schulserver.de + +- initial version +- added: + + check_mailstat_plugin_v0.9.1-initial_values.patch + + check_mailstat_plugin_v0.9.1-stat_file.patch diff --git a/nagios-plugins-mailstat.spec b/nagios-plugins-mailstat.spec new file mode 100644 index 0000000..44fb059 --- /dev/null +++ b/nagios-plugins-mailstat.spec @@ -0,0 +1,76 @@ +# +# spec file for package nagios-plugins-mailstat +# +# 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-mailstat +Version: 0.9.1 +Release: 0 +Summary: Monitoring mail server statistics +License: GPL-3.0+ +Group: System/Monitoring +Url: http://linuxplayer.org/2010/12/check_mailstat-pl-a-nagios-plugin-for-monitoring-mail-server-statistics +Source0: check_mailstat_plugin_v%{version}.zip +Source1: nagios-plugins-mailstat-rpmlintrc +# PATCH-FIX-UPSTREAM -- allow to configure the path name of the statistics file via -s option +Patch1: check_mailstat_plugin_v0.9.1-stat_file.patch +# PATCH-FIX-UPSTREAM -- write out the initial values if there is no old file instead of all zero (confuses people) +Patch2: check_mailstat_plugin_v0.9.1-initial_values.patch +%if 0%{?suse_version} > 1010 +# nagios can execute the script with embedded perl +Recommends: perl +%endif +BuildRequires: nagios-rpm-macros +BuildRequires: unzip +Requires: nagios-plugins-common +BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildArch: noarch + +%description +This plugin includes a patch for mailgraph so that it will also output its +statistics counter to an external file(plus the rra file),and a +check_mailstat.pl which check the stat counter to see if it’s ok, emit +WARN/CRITICAl result if not.It can run on nagios server, or on remote server +via NRPE. + +%prep +%setup -q -n check_mailstat_plugin_v%{version} +%patch1 -p1 +%patch2 -p1 +sed -i "s| ||g" README.txt + +%build + +%install +install -D -m755 check_mailstat.pl %{buildroot}/%{nagios_plugindir}/check_mailstat +ln -s %{nagios_plugindir}/check_mailstat %{buildroot}/%{nagios_plugindir}/check_mailstat.pl +install -D -m644 extra/check_mailstat.php %{buildroot}/%{pnp4nagios_templatedir}/check_mailstat.php + +%clean +rm -rf %{buildroot} + +%files +%defattr(-,root,root) +%doc README.txt +# avoid build dependecy of nagios - own the dirs +%dir %{nagios_libdir} +%dir %{nagios_plugindir} +%{nagios_plugindir}/check_mailstat* +%dir %{pnp4nagios_datarootdir} +%dir %{pnp4nagios_templatedir} +%config(noreplace) %{pnp4nagios_templatedir}/check_mailstat.php + +%changelog