# HG changeset patch # User Christian Arnold # Date 1305203954 -7200 # Node ID c6e374ba7961bfc1acb347c42e4bedb48738c2fe import to mercurial bulding debian package diff -r 000000000000 -r c6e374ba7961 .hgignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.hgignore Thu May 12 14:39:14 2011 +0200 @@ -0,0 +1,8 @@ +syntax: glob +*.swp +debian/files +check_zarafa + +syntax: regexp +(build|configure)-stamp$ +debian/nagios-plugin-zarafa[./] diff -r 000000000000 -r c6e374ba7961 .perltitdy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.perltitdy Thu May 12 14:39:14 2011 +0200 @@ -0,0 +1,2 @@ +--paren-tightness=2 +--square-bracket-tightness=2 diff -r 000000000000 -r c6e374ba7961 Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Thu May 12 14:39:14 2011 +0200 @@ -0,0 +1,22 @@ +SCRIPTS = check_zarafa +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 $@ diff -r 000000000000 -r c6e374ba7961 check_zarafa.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/check_zarafa.pl Thu May 12 14:39:14 2011 +0200 @@ -0,0 +1,190 @@ +#! /usr/bin/perl + +# Copyright (C) 2011 Christian Arnold +# +# This program 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 3 of the License, or +# (at your option) any later version. +# +# This program 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 program. If not, see . +# +# Christian Arnold + +use 5.010; +use strict; +use warnings; +use File::Basename qw(basename); +use Pod::Usage; +use Getopt::Long; +use LWP::Simple; + +delete @ENV{ grep /^LC_/ => keys %ENV }; +$ENV{LANG} = "C"; +$ENV{LC_ALL} = "C"; + +sub version($$); +sub get_last_version($$); +sub get_current_version($); +sub report($$); + +my %ERRORS = ( + OK => 0, + WARNING => 1, + CRITICAL => 2, + UNKNOWN => 3, + DEPENDENT => 4 +); + +my $ME = basename $0; +my $NAME = 'ZARAFA'; +my $VERSION = '0.1'; + +my %opt = ( + url => 'http://www.zarafa.com/download-release', + search => 'http://download.zarafa.com/community/final/[\d\.]+/([\d\.-]+)', + package => 'zarafa' +); + +MAIN: { + Getopt::Long::Configure('no_ignore_case_always'); + GetOptions( + "u|uerl=s" => \$opt{url}, + "s|search=s" => \$opt{search}, + "p|package=s" => \$opt{package}, + "h|help" => sub { pod2usage( -verbose => 1, -exitval => $ERRORS{OK} ) }, + "m|man" => sub { pod2usage( -verbose => 2, -exitval => $ERRORS{OK} ) }, + "V|version" => sub { version( $ME, $VERSION ); exit $ERRORS{OK}; } + ) or pod2usage( -verbose => 1, -exitval => $ERRORS{CRITICAL} ); + + my $last_verbose = get_last_version( $opt{url}, $opt{search} ); + my $current_version = get_current_version( $opt{package} ); + + report( $last_verbose, $current_version ); +} + +sub get_last_version($$) { + my ( $url, $search ) = @_; + my @webside = (); + my $last_verbose = ""; + + push @webside, split( "\n", get($url) ); + foreach (@webside) { + /$search/ or next; + $last_verbose = $1 and last; + } + return $last_verbose if ($last_verbose); + return "-"; +} + +sub get_current_version($) { + my ($package) = @_; + my $version = undef; + + my @current_version = grep { /^Version:/ } `dpkg -s $package 2> /dev/null`; + if ( $current_version[0] ) { + $current_version[0] =~ /^Version:\s+(\S+)/ and $version = $1; + } + return $version if ($version); + return "-"; +} + +sub report($$) { + my ( $last_verbose, $current_version ) = @_; + + if ( $last_verbose eq $current_version ) { + say "$NAME OK: $opt{package} version $current_version"; + exit $ERRORS{OK}; + } + else { + say +"$NAME WARNING: $opt{package} installed version $current_version available version $last_verbose"; + exit $ERRORS{WARNING}; + } +} + +sub version($$) { + my ( $progname, $version ) = @_; + print <<_VERSION; +$progname version $version +Copyright (C) 2011 by Christian Arnold and Schlittermann internet & unix support. + +$ME comes with ABSOLUTELY NO WARRANTY. This is free software, +and you are welcome to redistribute it under certain conditions. +See the GNU General Public Licence for details. +_VERSION +} + +__END__ + +=head1 NAME + +check_zarafa - nagios plugin to check installed zarafa version + +=head1 SYNOPSIS + +check_zarafa [B<-u>|B<--url> string] [B<-s>|B<--search> string] [B<-p>|B<--package> string] + +check_zarafa [B<-h>|B<--help>] + +check_zarafa [B<-m>|B<--man>] + +check_zarafa [B<-V>|B<--version>] + +=head1 OPTIONS + +=over + +=item B<-u>|B<--url> I + +URL where will be look for the I string ( default: http://www.zarafa.com/download-release ) + +=item B<-s>|B<--search> I + +Perl regular expression to search version string on the url. The content of the round brackets in the +regular expression will be used to compare with the installed package version. +( default: 'http://download.zarafa.com/community/final/[\d\.]+/([\d\.-]+)' ) + +=item B<-p>|B<--package> I + +Installed package name ( default: zarafa ) + +=item B<-h>|B<--help> + +Print detailed help screen. + +=item B<-m>|B<--man> + +Print manual page. + +=item B<-V>|B<--version> + +Print version information. + +=back + +=head1 DESCRIPTION + +This nagios plugin I on a specified I for a version string and compare the I result with an installed I version. + +=head1 VERSION + +This man page is current for version 0.1 of B. + +=head1 AUTHOR + +Written by Christian Arnold L + +=head1 COPYRIGHT + +Copyright (C) 2011 by Christian Arnold and Schlittermann internet & unix support. This is free software, and you are welcome to +redistribute it under certain conditions. +See the GNU General Public Licence for details. + +=cut diff -r 000000000000 -r c6e374ba7961 debian/changelog --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/changelog Thu May 12 14:39:14 2011 +0200 @@ -0,0 +1,5 @@ +nagios-plugin-zarafa (0.1) lenny squeeze; urgency=low + + * Initial Release. + + -- Christian Arnold Thu, 12 May 2011 14:00:04 +0200 diff -r 000000000000 -r c6e374ba7961 debian/compat --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/compat Thu May 12 14:39:14 2011 +0200 @@ -0,0 +1,1 @@ +7 diff -r 000000000000 -r c6e374ba7961 debian/control --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/control Thu May 12 14:39:14 2011 +0200 @@ -0,0 +1,14 @@ +Source: nagios-plugin-zarafa +Section: net +Priority: extra +Maintainer: Christian Arnold +Build-Depends: debhelper (>= 7.0.50~) +Standards-Version: 3.8.4 +Homepage: https://keller.schlittermann.de/hg/ius/nagios/nagios-plugin-zarafa/ + +Package: nagios-plugin-zarafa +Architecture: all +Depends: perl-base, perl-doc, libwww-perl +Description: nagios plugin to check installed zarafa version + This nagios plugin search on a specified url for a version string + and compare the search result with an installed package version. diff -r 000000000000 -r c6e374ba7961 debian/copyright --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/copyright Thu May 12 14:39:14 2011 +0200 @@ -0,0 +1,39 @@ +This work was packaged for Debian by: + + Christian Arnold on Thu, 12 May 2011 14:00:04 +0200 + +It was downloaded from: + + https://keller.schlittermann.de/hg/ius/nagios/nagios-plugin-zarafa/ + +Upstream Author(s): + + Christian Arnold + +Copyright: + + Copyright (C) 2011 Schlittermann internet & unix support + +License: + + This program 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 3 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 program. If not, see . + +On Debian systems, the complete text of the GNU General +Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". + +The Debian packaging is: + + Copyright (C) 2011 Christian Arnold + +and is licensed under the GPL version 3, see above. diff -r 000000000000 -r c6e374ba7961 debian/rules --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/rules Thu May 12 14:39:14 2011 +0200 @@ -0,0 +1,13 @@ +#!/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 + +%: + dh $@ diff -r 000000000000 -r c6e374ba7961 debian/source/format --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/debian/source/format Thu May 12 14:39:14 2011 +0200 @@ -0,0 +1,1 @@ +3.0 (native)