--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore Wed Jul 28 16:24:58 2010 +0200
@@ -0,0 +1,8 @@
+syntax: glob
+*.swp
+debian/files
+check_release
+
+syntax: regexp
+(build|configure)-stamp$
+debian/nagios-plugin-release[./]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile Wed Jul 28 16:24:58 2010 +0200
@@ -0,0 +1,22 @@
+SCRIPTS = check_release
+CLEANFILES = ${SCRIPTS}
+DESTDIR =
+prefix = /usr
+
+plugindir = ${prefix}/lib/nagios/plugins/ius
+
+.PHONY: all clean install
+
+all: ${SCRIPTS}
+
+clean:
+ -rm -f ${CLEANFILES}
+
+install: all
+ install -d -m 0755 ${DESTDIR}/${plugindir}
+ install -m 0755 $(SCRIPTS) ${DESTDIR}/${plugindir}/
+
+%: %.pl
+ @perl -c $<
+ @cp -f $< $@
+ @chmod +x $@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/check_release.pl Wed Jul 28 16:24:58 2010 +0200
@@ -0,0 +1,114 @@
+#!/usr/bin/perl -w
+
+use strict;
+use File::Basename;
+use Getopt::Long;
+use LWP::Simple;
+
+use lib "/usr/lib/nagios/plugins";
+use utils qw (%ERRORS &print_revision &support);
+
+my $ME = basename $0;
+my $VERSION = "1.1";
+my $USAGE = <<EOF;
+Usage: $ME [-u | --url]
+ $ME [-s | --search]
+ $ME [-f | --file]
+ $ME [-h | --help]
+ $ME [-V | --version]
+EOF
+
+my $opt_url = "http://www.debian.org/releases/stable/index.html";
+my $opt_search = "<p>Debian GNU/Linux";
+my $opt_file = "/etc/debian_version";
+my ($found, $current_release, $current_majornr, $stable_release, $stable_majornr, @website);
+
+sub check_status();
+sub print_help();
+sub print_usage();
+
+MAIN: {
+ Getopt::Long::Configure('bundling');
+ GetOptions(
+ "u|url" => \$opt_url,
+ "s|search" => \$opt_search,
+ "f|file" => \$opt_file,
+ "h|help" => sub { print_help(); exit $ERRORS{OK}; },
+ "V|version" =>
+ sub { print_revision( $ME, $VERSION ); exit $ERRORS{OK}; },
+ );
+
+ # get current release number
+ unless ( -r $opt_file ) {
+ print "RELEASE CRITICAL: $opt_file not exists or not read permission is granted\n";
+ exit $ERRORS{"CRITICAL"};
+ }
+
+ open(CR, "<$opt_file");
+ while(<CR>) {
+ chomp;
+ $current_release = $_;
+ $current_release =~ /^(\d)+.*/;
+ $current_majornr = $1;
+ }
+ close(CR);
+
+ # download the website
+ push @website, split("\n", get($opt_url));
+
+ foreach (@website) {
+ unless ($found) {
+ /$opt_search/ or next;
+ $found = $_;
+ next;
+ }
+ }
+
+ # get stable release number
+ if ($found =~ /$opt_search\s+([\d\.]+).*/) {
+ $stable_release = $1;
+ $stable_release =~ /^(\d)+.*/;
+ $stable_majornr = $1;
+ }
+
+ check_status();
+
+}
+
+sub check_status() {
+ if ($stable_release eq $current_release) {
+ print "RELEASE OK: current release number $current_release\n";
+ exit $ERRORS{"OK"};
+ } elsif ($current_majornr < $stable_majornr) {
+ print "RELEASE CRITICAL: current release number $current_release / stable release number $stable_release\n";
+ exit $ERRORS{"CRITICAL"};
+ } else {
+ print "RELEASE WARNING: current release number $current_release / stable release number $stable_release\n";
+ exit $ERRORS{"WARNING"};
+ }
+}
+
+
+sub print_usage() { print $USAGE }
+
+sub print_help() {
+ print_revision( $ME, $VERSION );
+ print <<EOF;
+Copyright (c) 2010 Christian Arnold
+
+This plugin checks the current debian release number.
+
+$USAGE
+ -u, --url
+ URL where to search for the search string (default: http://www.debian.org/releases/stable/index.html)
+ -s, --search
+ search string on the url (default: '<p>Debian GNU/Linux')
+ -f, --file
+ file with current release informations (default: /etc/debian_version)
+ -h, --help
+ print detailed help screen
+ -V, --version
+ print version information
+EOF
+ support();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/changelog Wed Jul 28 16:24:58 2010 +0200
@@ -0,0 +1,16 @@
+nagios-plugin-release (1.1-0) stable; urgency=low
+
+ * fixing package dependencies (libwww-perl)
+ * return critical status if major number is lower than current stable major
+ number
+ * return warning status if minor number is unequal current stable minor
+ number
+
+ -- Christian Arnold <arnold@schlittermann.de> Thu, 15 Jul 2010 10:28:42 +0200
+
+nagios-plugin-release (1.0-1) stable; urgency=low
+
+ * Initial release
+
+ -- Christian Arnold <arnold@schlittermann.de> Fri, 09 Jul 2010 15:48:43 +0200
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/compat Wed Jul 28 16:24:58 2010 +0200
@@ -0,0 +1,1 @@
+7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/control Wed Jul 28 16:24:58 2010 +0200
@@ -0,0 +1,12 @@
+Source: nagios-plugin-release
+Section: net
+Priority: extra
+Maintainer: Christian Arnold <arnold@schlittermann.de>
+Build-Depends: debhelper (>= 7)
+Standards-Version: 3.7.3
+
+Package: nagios-plugin-release
+Architecture: all
+Depends: ${shlibs:Depends}, ${misc:Depends}, libwww-perl
+Description: nagios plugin to check current debian release number
+ This plugin checks the current debian release number.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/copyright Wed Jul 28 16:24:58 2010 +0200
@@ -0,0 +1,40 @@
+This package was debianized by Christian Arnold <arnold@schlittermann.de> on
+Fri, 09 Jul 2010 15:48:43 +0200.
+
+It was downloaded from <url://example.com>
+
+Upstream Author(s):
+
+ <put author's name and email here>
+ <likewise for another author>
+
+Copyright:
+
+ <Copyright (C) YYYY Name OfAuthor>
+ <likewise for another author>
+
+License:
+
+ This package is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this package; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+On Debian systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL'.
+
+The Debian packaging is (C) 2010, Christian Arnold <arnold@schlittermann.de> and
+is licensed under the GPL, see above.
+
+
+# Please also look if there are files or directories which have a
+# different copyright/license attached and list them here.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/dirs Wed Jul 28 16:24:58 2010 +0200
@@ -0,0 +1,2 @@
+usr/bin
+usr/sbin
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/rules Wed Jul 28 16:24:58 2010 +0200
@@ -0,0 +1,91 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+
+
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ # Add here commands to configure the package.
+
+ touch configure-stamp
+
+
+build: build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+
+ # Add here commands to compile the package.
+ $(MAKE)
+ #docbook-to-man debian/nagios-plugin-release.sgml > nagios-plugin-release.1
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ # Add here commands to clean up after the build process.
+ $(MAKE) clean
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/nagios-plugin-release.
+ $(MAKE) DESTDIR=$(CURDIR)/debian/nagios-plugin-release install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_installexamples
+# dh_install
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_python
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+# dh_perl
+# dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure