]> git.pld-linux.org Git - packages/nagios-plugin-check_rbl.git/commitdiff
- up to 1.2.0 auto/ac/nagios-plugin-check_rbl-1_2_0-1 auto/th/nagios-plugin-check_rbl-1_2_0-1
authorElan Ruusamäe <glen@pld-linux.org>
Fri, 9 Apr 2010 08:44:19 +0000 (08:44 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    mdns.patch -> 1.4
    nagios-plugin-check_rbl.spec -> 1.14
    verbose-reporting.patch -> 1.4

mdns.patch [deleted file]
nagios-plugin-check_rbl.spec
verbose-reporting.patch [deleted file]

diff --git a/mdns.patch b/mdns.patch
deleted file mode 100644 (file)
index eb9dcb4..0000000
+++ /dev/null
@@ -1,293 +0,0 @@
---- check_rbl-1.2.0/check_rbl  2010-04-06 20:40:42.858468257 +0300
-+++ check_rbl-1.1.0/check_rbl  2010-04-06 21:00:56.970381943 +0300
-@@ -4,6 +4,7 @@
- # See  the INSTALL file for installation instructions
- #
- # Copyright (c) 2007, ETH Zurich.
-+# Copyright (c) 2010, Elan Ruusamäe <glen@delfi.ee>.
- #
- # This module is free software; you can redistribute it and/or modify it
- # under the terms of GNU general public license (gpl) version 3.
-@@ -22,13 +23,11 @@
- use strict;
- use warnings;
--use Carp;
--use English '-no_match_vars';
- use Nagios::Plugin::Threshold;
- use Nagios::Plugin;
- use Nagios::Plugin::Getopt;
- use Net::DNS;
--use Parallel::Iterator qw(iterate);
-+use IO::Select;
- use Readonly;
- Readonly my $DEFAULT_RETRIES => 4;
-@@ -47,48 +46,15 @@
- #
- use vars qw(
-   @BLACKLISTED
-+  @TIMEOUTS
-   $IP
-   $OPTIONS
-   $PLUGIN
-   $THRESHOLD
-+  $res
- );
- ##############################################################################
--# Usage     : my $ip = lookup( $hostname );
--# Purpose   : DNS lookup
--# Returns   : $ip if found; undef if not found
--# Arguments : $hostname : the FQDN to resolve
--# Throws    : n/a
--# Comments  : n/a
--# See also  : n/a
--sub lookup {
--
--    my ($hostname) = @_;
--
--    require Net::DNS;
--
--    my $res = Net::DNS::Resolver->new;
--
--    $res->retry( $OPTIONS->retry() );
--
--    my $query = $res->search($hostname);
--
--    if ($query) {
--        foreach my $rr ( $query->answer ) {
--            if ( $rr->type eq 'A' ) {
--                return $rr->address;
--            }
--        }
--    }
--    else {
--        return;
--    }
--
--    return;    # dead code to make perlcritic happy
--
--}
--
--##############################################################################
- # Usage     : verbose("some message string", $optional_verbosity_level);
- # Purpose   : write a message if the verbosity level is high enough
- # Returns   : n/a
-@@ -123,36 +89,116 @@
- }
- ##############################################################################
--# Usage     : check_server( $ip, $server )
--# Purpose   : checks if $ip is blacklisted by $server
-+# Usage     : mdns(\@addresses, $callback)
-+# Purpose   : Perform multiple DNS lookups in parallel
- # Returns   : n/a
--# Arguments : $ip     : host IP
--#             $server : RBL server
--# Throws    : n/a
--# Comments  : if blacklisted pushed $server onto @blacklisted
--# See also  : n/a
--sub check_server {
--
--    my ($server) = @_;
--
--    my $lookup_ip = $IP;
--
--    $lookup_ip =~
--s/(\d{1,3}) [.] (\d{1,3}) [.] (\d{1,3}) [.] (\d{1,3})/$4.$3.$2.$1.$server/mxs;
--
--    verbose " -> $lookup_ip\n";
--
--    if ( lookup($lookup_ip) ) {
--
--        verbose "LISTED: $lookup_ip\n";
--        return $lookup_ip;
--
--    }
--
--    verbose "OK: $lookup_ip\n";
--
--    return 0;
-+# See also  : Perl Net::DNS module mresolv in examples
-+#
-+# Resolves all IPs in C<@addresses> in parallel.
-+# If answer is found C<$callback> is called with arguments as: $name, $host.
-+#
-+# Author: Elan Ruusamäe <glen@delfi.ee>, (c) 1999-2010
-+sub mdns {
-+      my $data = shift;
-+      my $callback = shift;
-+
-+      # number of requests to have outstanding at any time
-+      my $opt_n = $OPTIONS->workers;
-+      # timeout per query (seconds)
-+      my $opt_t = 15;
-+      my $opt_d = $OPTIONS->verbose;
-+
-+      my $sel = IO::Select->new;
-+      my $eof = 0;
-+
-+      my @addrs = @$data;
-+      my %addrs;
-+      while (1) {
-+              #----------------------------------------------------------------------
-+              # Read names until we've filled our quota of outstanding requests.
-+              #----------------------------------------------------------------------
-+
-+              while (!$eof && $sel->count < $opt_n) {
-+                      print "DEBUG: reading..." if $opt_d;
-+                      my $name = shift @addrs;
-+                      unless (defined $name) {
-+                              print "EOF.\n" if $opt_d;
-+                              $eof = 1;
-+                              last;
-+                      }
-+                      print "NAME: $name\n" if $opt_d;
-+                      my $sock = $res->bgsend($name);
-+
-+                      # we store in a hash the query we made, as parsing it back from
-+                      # response gives different ip for ips with multiple hosts
-+                      $addrs{$sock} = $name;
-+                      $sel->add($sock);
-+                      print "name = $name, outstanding = ", $sel->count, "\n" if $opt_d;
-+              }
-+
-+              #----------------------------------------------------------------------
-+              # Wait for any replies.  Remove any replies from the outstanding pool.
-+              #----------------------------------------------------------------------
-+
-+              my @ready;
-+              my $timed_out = 1;
-+
-+              print "DEBUG: waiting for replies\n" if $opt_d;
-+
-+              for (@ready = $sel->can_read($opt_t);
-+                       @ready;
-+                       @ready = $sel->can_read(0)) {
-+
-+                      $timed_out = 0;
-+
-+                      print "DEBUG: replies received: ", scalar @ready, "\n" if $opt_d;
-+
-+                      foreach my $sock (@ready) {
-+                              print "DEBUG: handling a reply\n" if $opt_d;
-+                              my $addr = $addrs{$sock};
-+                              delete $addrs{$sock};
-+                              $sel->remove($sock);
-+
-+                              my $ans = $res->bgread($sock);
-+                              my $host;
-+                              if ($ans) {
-+                                      foreach my $rr ($ans->answer) {
-+                                              next unless $rr->type eq 'A';
-+                                              $host = $rr->address;
-+                                              # take just first answer
-+                                              last;
-+                                      }
-+                              } else {
-+                                      print "DEBUG: no answer: ". $res->errorstring. "\n" if $opt_d;
-+                              }
-+                              &$callback($addr, $host);
-+                      }
-+              }
-+
-+              #----------------------------------------------------------------------
-+              # If we timed out waiting for replies, remove all entries from the
-+              # outstanding pool.
-+              #----------------------------------------------------------------------
-+
-+              if ($timed_out) {
-+                      print "DEBUG: timeout: clearing the outstanding pool.\n" if $opt_d;
-+                      foreach my $sock ($sel->handles) {
-+                              my $addr = $addrs{$sock};
-+                              delete $addrs{$sock};
-+                              $sel->remove($sock);
-+                              # callback for hosts that timed out
-+                              &$callback($addr, '');
-+                      }
-+              }
-+
-+              print "DEBUG: outstanding = ", $sel->count, ", eof = $eof\n" if $opt_d;
-+
-+              #----------------------------------------------------------------------
-+              # We're done if there are no outstanding queries and we've read EOF.
-+              #----------------------------------------------------------------------
-+              last if ($sel->count == 0) && $eof;
-+      }
- }
- ##############################################################################
-@@ -232,9 +278,16 @@
-         'critical has to be greater or equal warning' );
- }
-+$res = new Net::DNS::Resolver;
-+$res->force_v4(1) if $res->can('force_v4');
-+$res->retry($OPTIONS->retry());
-+
- $IP = $OPTIONS->host;
--if ( $IP =~ m/[[:lower:]]/mxs ) {
--    $IP = lookup( $OPTIONS->host );
-+if ($IP =~ m/[[:lower:]]/mxs) {
-+      mdns([ $OPTIONS->host ], sub {
-+              my ($addr, $host) = @_;
-+              $IP = $host;
-+      });
- }
- if ( !$IP ) {
-@@ -259,28 +312,37 @@
- verbose 'Checking ' . $OPTIONS->host . " ($IP) on $nservers server(s)\n";
--my $iter = iterate(
--    { workers => $OPTIONS->workers },
--    \&check_server,
--    sub {
--        while ( my $server = pop @servers ) {
--            return $server;
--        }
--        return;
--    }
--);
--
--while ( my ( $server, $result ) = $iter->() ) {
--    if ($result) {
--        push @BLACKLISTED, $server;
--    }
-+# build address lists
-+my @addrs;
-+foreach my $server (@servers) {
-+      (my $ip = $IP) =~ s/(\d{1,3}) [.] (\d{1,3}) [.] (\d{1,3}) [.] (\d{1,3})/$4.$3.$2.$1.$server/x;
-+      push(@addrs, $ip);
- }
-+mdns(\@addrs, sub {
-+      my ($addr, $host) = @_;
-+      # extract RBL we checked
-+      $addr =~ s/^(?:\d+\.){4}//;
-+      if (defined $host) {
-+              if ($host eq '') {
-+                      push @TIMEOUTS, $addr;
-+              } else {
-+                      verbose "listed in $addr as $host\n";
-+                      push @BLACKLISTED, $addr;
-+              }
-+      }
-+});
-+
- my $total = scalar @BLACKLISTED;
- my $status =
-   $OPTIONS->host. " BLACKLISTED on $total " . ( ( $total == 1 ) ? 'server' : 'servers' ) . " of $nservers";
-+# append timeout info, but do not account these in status
-+if (@TIMEOUTS) {
-+      $status .= sprintf(" (%d servers timeout: %s)", scalar @TIMEOUTS, join(', ', @TIMEOUTS));
-+}
-+
- if ( $total > 0 ) {
-     $status .= " (@BLACKLISTED)";
- }
index 7d449eba90379a00fb704892038602e7a46d9476..defb6ef4256e2b8a695929d8e073bd227c69a270 100644 (file)
@@ -6,19 +6,14 @@
 %define                plugin  check_rbl
 Summary:       Nagios plugin to check if an server is blacklisted in RBL servers
 Name:          nagios-plugin-%{plugin}
-Version:       1.1.0
-Release:       5
+Version:       1.2.0
+Release:       1
 License:       GPL
 Group:         Networking
 Source0:       https://trac.id.ethz.ch/projects/nagios_plugins/downloads/%{plugin}-%{version}.tar.gz
-# Source0-md5: 724cd353d48df3f4e9a98743146cfd0f
+# Source0-md5: 630902d9d7b644a0ab6537030ec40f12
 Source1:       %{plugin}.cfg
-# https://trac.id.ethz.ch/projects/nagios_plugins/ticket/67
 Source2:       %{plugin}.ini
-# https://trac.id.ethz.ch/projects/nagios_plugins/ticket/66
-Patch0:                verbose-reporting.patch
-# https://trac.id.ethz.ch/projects/nagios_plugins/ticket/69
-Patch1:                mdns.patch
 URL:           https://trac.id.ethz.ch/projects/nagios_plugins/wiki/check_rbl
 BuildRequires: perl-ExtUtils-MakeMaker >= 6.42
 BuildRequires: rpm-perlprov >= 4.1-13
@@ -43,19 +38,13 @@ Nagios plugin to check if an server is blacklisted in RBL servers.
 
 %prep
 %setup -q -n %{plugin}-%{version}
-%patch0 -p1
 
 # https://trac.id.ethz.ch/projects/nagios_plugins/ticket/68
 %{__sed} -i -e '
-# no need for debug dependency
-/use Data::Dumper;/d
-
 # not needed, so kill to avoid extra dep
 /use version;/d
 ' %{plugin}
 
-%patch1 -p1
-
 %build
 %{__perl} Makefile.PL \
        INSTALLVENDORSCRIPT=%{plugindir} \
@@ -86,4 +75,4 @@ rm -rf $RPM_BUILD_ROOT
 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{plugin}.cfg
 %attr(640,root,nagios) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/%{plugin}.ini
 %attr(755,root,root) %{plugindir}/%{plugin}
-%{_mandir}/man3/*.3pm*
+%{_mandir}/man1/check_rbl.1*
diff --git a/verbose-reporting.patch b/verbose-reporting.patch
deleted file mode 100644 (file)
index e2e6a68..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
---- check_rbl-1.1.0/check_rbl  2010-02-01 18:28:07.075134119 +0200
-+++ check_rbl-1.1.0/check_rbl  2010-02-01 18:28:07.075134119 +0200
-@@ -144,10 +144,13 @@
-     if ( lookup($lookup_ip) ) {
-+        verbose "LISTED: $lookup_ip\n";
-         return $lookup_ip;
-     }
-+    verbose "OK: $lookup_ip\n";
-+
-     return 0;
- }
-@@ -238,6 +241,7 @@
-     $PLUGIN->nagios_exit( UNKNOWN, 'Cannot resolve ' . $OPTIONS->host );
- }
-+verbose "Using " . $OPTIONS->timeout . " as global script timeout\n";
- alarm $OPTIONS->timeout;
- ################
-@@ -250,13 +254,16 @@
- ################################################################################
--verbose 'Checking ' . $OPTIONS->host . " ($IP)\n";
-+my @servers = @{$OPTIONS->server};
-+my $nservers = scalar @servers;
-+
-+verbose 'Checking ' . $OPTIONS->host . " ($IP) on $nservers server(s)\n";
- my $iter = iterate(
-     { workers => $OPTIONS->workers },
-     \&check_server,
-     sub {
--        while ( my $server = pop @{ $OPTIONS->server } ) {
-+        while ( my $server = pop @servers ) {
-             return $server;
-         }
-         return;
-@@ -272,7 +279,7 @@
- my $total = scalar @BLACKLISTED;
- my $status =
--  "BLACKLISTED on $total " . ( ( $total == 1 ) ? 'server' : 'servers' );
-+  $OPTIONS->host. " BLACKLISTED on $total " . ( ( $total == 1 ) ? 'server' : 'servers' ) . " of $nservers";
- if ( $total > 0 ) {
-     $status .= " (@BLACKLISTED)";
This page took 0.107615 seconds and 4 git commands to generate.