# HG changeset patch # User Matthias Förste # Date 1309516196 -7200 # Node ID e061bc121954fd1362b4fa1593dde25ebe0fa81c # Parent 1e812db5da236b2b33fd83f61a27453085607a22 * removed usage of 'support()' because it recommends asking on the nagios list in case of problems with this plugin * changed url and search pattern and version detection mechanism * display actual defaults with -h unless they have been overridden on the commandline ;) diff -r 1e812db5da23 -r e061bc121954 check_avwebgate.pl --- a/check_avwebgate.pl Thu Oct 30 08:18:50 2008 +0000 +++ b/check_avwebgate.pl Fri Jul 01 12:29:56 2011 +0200 @@ -8,7 +8,7 @@ use LWP::Simple; use lib "/usr/lib/nagios/plugins"; -use utils qw (%ERRORS &print_revision &support); +use utils qw (%ERRORS &print_revision); sub print_help(); sub print_usage(); @@ -16,10 +16,9 @@ my $ME = basename $0; my ( $opt_u, $opt_s, $opt_V, $opt_h, $opt_b ); my ( $result, $found, $message, $version, $current_version ); -my ( @webside ); -$opt_u = "http://www.avira.de/de/downloads/avira_antivir_webgate.html"; -$opt_s = ">Avira AntiVir WebGate / Avira WebGate Suite<"; +$opt_u = 'http://www.avira.com/de/support-download-avira-antivir-webgate'; +$opt_s = 'Avira AntiVir WebGate / Avira WebGate Suite.*(?:\n.*){4}(\d+\.\d+\.\d+\.[\d-]+)'; $opt_b = "/usr/lib/AntiVir/avwebgate.bin"; Getopt::Long::Configure('bundling'); @@ -52,27 +51,22 @@ exit $ERRORS{"CRITICAL"}; } -# download the webside -push @webside, split("\n", get($opt_u)); - -foreach (@webside) { - unless ($found) { - /$opt_s/ or next; - $found = 1; - next; +{ + get($opt_u) =~ /$opt_s/; + unless ($version = $1) { + print "AVWEBGATE CRITICAL: cannot get version info from avira server\n"; + exit $ERRORS{"CRITICAL"}; } - /Version:\s([\d\.-]+).*/ or next; - $version = $1 and last; } -unless ($version) { - print "AVWEBGATE CRITICAL: cannot get version info from avira server\n"; - exit $ERRORS{"CRITICAL"}; +{ + qx(LANG= $opt_b --version) =~ /product version:\s*(\S+)/; + unless ($current_version = $1) { + print "AVWEBGATE CRITICAL: cannot get local version info\n"; + exit $ERRORS{"CRITICAL"}; + } } -$_ = `$opt_b --version`; -if ($_ =~ /product version:\s+(\S+)/) { $current_version = $1; } - $result = ($current_version eq $version) ? "OK" : "WARNING"; if ($result eq "WARNING") { @@ -99,11 +93,10 @@ print_usage(); print "\n"; print " -b, --binary \n"; - print " Path of AntiVir WebGate binary (default: /usr/lib/AntiVir/avwebgate.bin)\n"; + print " Path of AntiVir WebGate binary (default: $opt_b)\n"; print " -u, --url \n"; - print " URL where will be look for the search string (default: http://www.avira.com/de/downloads/avira_antivir_unix_webgate.html)\n"; + print " URL where will be look for the search string (default: $opt_u)\n"; print " -s, --search \n"; - print " Search string on the url (default: >Avira AntiVir UNIX WebGate<)\n"; + print " Search string on the url - put the pattern matching the version in parenthesis like 'optionalprefix(theversion)optionalpostfix' (default: $opt_s)\n"; print "\n"; - support(); }