parse_ini now reads the default section if the request one can't be found.
[monitoring-plugins.git] / contrib / rblcheck-web
blobeb4fcdeccc6b5efedfc047c62a272ddac40d7244
1 #!/usr/bin/perl
2 # Multi-RBL Query tool, developer Vikram <vr@udel.edu>
3 use IO::Socket::INET;
5 die "Syntax: $0 -H <ip address>\n" unless $ARGV[1];
7 $soc = new IO::Socket::INET->new(PeerPort=>80,
8 Proto=>'tcp',
9 PeerAddr=>"rbls.org") or die("Cannot connect to CERT");
11 $ip = $ARGV[1];
12 $uri = '/?q='.$ip;
14 $soc->send("GET $uri HTTP/1.1\nHost: rbls.org\n\n");
15 @buff = <$soc>;
16 delete @buff[0..7];
17 $len = @buff;
19 $alert = 0;
22 for( $i=0;$i<$len;$i++ ) {
23 next unless( defined $buff[$i] );
24 chomp($buff[$i]);
25 #print "$buff[$i]\n";
27 if ( $buff[$i] eq "<tr bgcolor=#ffc0c0>" ) {
28 $rbl = substr($buff[$i+1], 5, index($buff[$i], "</tr>") - 5);
29 next if ( index($rbl, '.') == -1 );
30 print "$ip is listed in the following RBLS: " if ( $alert == 0 );
31 print "$rbl ";
32 $alert = 1;
35 print "$ip is not listed in any RBLS" if ( $alert == 0 );
36 print "\n";
37 exit($alert);