diff options
-rw-r--r-- | CHANGES | 3 | ||||
-rw-r--r-- | doc/smokeping_install.pod | 4 | ||||
-rw-r--r-- | doc/smokeping_upgrade.pod | 23 | ||||
-rwxr-xr-x | htdocs/smokeping.cgi.dist | 9 | ||||
-rw-r--r-- | lib/Smokeping.pm | 20 | ||||
-rw-r--r-- | lib/Smokeping/probes/AnotherDNS.pm | 11 | ||||
-rw-r--r-- | lib/Smokeping/probes/Curl.pm | 6 | ||||
-rw-r--r-- | lib/Smokeping/probes/EchoPingHttp.pm | 2 | ||||
-rw-r--r-- | lib/Smokeping/probes/LDAP.pm | 20 |
9 files changed, 61 insertions, 37 deletions
@@ -1,3 +1,6 @@ +* graph fixes for small numbers of pings -- Chris Wilson <chris *aidworld.org> +* fix the LDAP probe killing the CGI with perl <5.6 -- Peter Farmer <pfarmer *hashbang.org.uk> +* make the LDAP probe work withouth IO::Socket::SSL -- niko * matchers start with a capital letter now -- niko * new probe programming interface -- niko - more strict config file checking giving helpful error messages when necessary diff --git a/doc/smokeping_install.pod b/doc/smokeping_install.pod index 7bb8a6b..079e17f 100644 --- a/doc/smokeping_install.pod +++ b/doc/smokeping_install.pod @@ -87,6 +87,10 @@ You need this for the AnotherDNS probe. You need this for the LDAP probe. +=item IO::Socket::SSL + +You need this if you want the LDAP probe to be able to use the 'starttls' command. + =item Authen::Radius You need this for the Radius probe. diff --git a/doc/smokeping_upgrade.pod b/doc/smokeping_upgrade.pod index 6c5fbc3..cbc324a 100644 --- a/doc/smokeping_upgrade.pod +++ b/doc/smokeping_upgrade.pod @@ -76,6 +76,19 @@ This is not an incompatible change, but it is mentioned here nevertheless. Target-specific variables can now be specified in the Probes section as well, and the values given become defaults for all the targets. +=item Timeouts + +The C<timeout> variable in the Probes section is now the maximum time +expected for B<one> ping to take. Previously it was the maximum time +allowed for all the pings to one target. This is an incompatible change, +but the code now works in the way it was documented to work even in 1.38. + +Those probes offering a target-specific C<timeout> variable will get a +default for it from the Probes section, as noted in the previous item. +This should ensure that probes that enforce the ping timeout themselves +(most do) will not get killed due to timeout before they have a chance +to do it. + =item Matchers The matcher modules have been renamed to start with a capital letter, @@ -110,6 +123,16 @@ The change was made to fix the confusing situation where the C<host> variable was required for each actual target, but it didn't actually have any effect (as the server to be probed came from the C<url> variable.) +The default timeout of this probe has been raised to 10 seconds. + +=item L<EchoPingHttp|Smokeping::probes::EchoPingHttp> + +The default timeout of this probe has been raised to 10 seconds. + +=item L<EchoPingHttps|Smokeping::probes::EchoPingHttps> + +The default timeout of this probe has been raised to 10 seconds. + =item L<EchoPingIcp|Smokeping::probes::EchoPingIcp> The C<url> variable is now mandatory, as the old default "/" didn't make diff --git a/htdocs/smokeping.cgi.dist b/htdocs/smokeping.cgi.dist index bce1b5d..f26ad5b 100755 --- a/htdocs/smokeping.cgi.dist +++ b/htdocs/smokeping.cgi.dist @@ -3,19 +3,12 @@ use lib qw(/usr/pack/rrdtool-1.0.33-to/lib/perl); use lib qw(/home/oetiker/data/projects/AADJ-smokeping/dist/lib); +use CGI::Carp qw(fatalsToBrowser); use Smokeping 1.38; Smokeping::cgi("/home/oetiker/data/projects/AADJ-smokeping/dist/etc/config"); - -BEGIN { - if ($ENV{SERVER_SOFTWARE}) { - $SIG{__WARN__} = sub { print "Content-Type: text/plain\n\n".(shift)."\n"; }; - $SIG{__DIE__} = sub { print "Content-Type: text/plain\n\n".(shift)."\n"; exit 1 } - }; -} - =head1 NAME smokeping.cgi - SmokePing webfrontend diff --git a/lib/Smokeping.pm b/lib/Smokeping.pm index 854da15..5daed06 100644 --- a/lib/Smokeping.pm +++ b/lib/Smokeping.pm @@ -687,7 +687,9 @@ sub get_detail ($$$$){ } my $smoke = $pings - 3 > 0 - ? smokecol $pings : [ 'COMMENT:"Not enough data collected to draw graph"' ]; + ? smokecol $pings : + [ 'COMMENT:(Not enough pings to draw any smoke.)\s', 'COMMENT:\s' ]; + # one \s doesn't seem to be enough my @upargs; my @upsmoke; my @median; @@ -727,6 +729,7 @@ sub get_detail ($$$$){ my $last = -1; my $swidth = $max->{$start} / $cfg->{Presentation}{detail}{height}; foreach my $loss (sort {$a <=> $b} keys %lc){ + next if $loss >= $pings; my $lvar = $loss; $lvar =~ s/\./d/g ; push @median, ( @@ -2240,7 +2243,7 @@ sub daemonize_me ($) { open STDERR, '>/dev/null' or die "ERROR: Redirecting STDERR to /dev/null: $!"; # send warnings and die messages to log $SIG{__WARN__} = sub { do_log ((shift)."\n") }; - $SIG{__DIE__} = sub { do_log ((shift)."\n"); exit 1 }; + $SIG{__DIE__} = sub { do_log ((shift)."\n"); }; } } @@ -2322,7 +2325,7 @@ sub load_cfg ($) { my $cfmod = (stat $cfgfile)[9] || die "ERROR: calling stat on $cfgfile: $!\n"; # when running under speedy this will prevent reloading on every run # if cfgfile has been modified we will still run. - if (not defined $cfg or $cfg->{__last} < $cfmod ){ + if (not defined $cfg or not defined $probes or $cfg->{__last} < $cfmod ){ $cfg = undef; my $parser = get_parser; $cfg = get_config $parser, $cfgfile; @@ -2406,12 +2409,6 @@ POD } sub cgi ($) { $cgimode = 'yes'; - # make sure error are shown in appropriate manner even when running from speedy - # and thus not getting BEGIN re-executed. - if ($ENV{SERVER_SOFTWARE}) { - $SIG{__WARN__} = sub { print "Content-Type: text/plain\n\n".(shift)."\n"; }; - $SIG{__DIE__} = sub { print "Content-Type: text/plain\n\n".(shift)."\n"; exit 1 } - }; umask 022; load_cfg shift; my $q=new CGI; @@ -2419,11 +2416,6 @@ sub cgi ($) { -expires=>'+'.($cfg->{Database}{step}).'s', -charset=> ( $cfg->{Presentation}{charset} || 'iso-8859-15') ); - if ($ENV{SERVER_SOFTWARE}) { - $SIG{__WARN__} = sub { print "<pre>".(shift)."</pre>"; }; - $SIG{__DIE__} = sub { print "<pre>".(shift)."</pre>"; exit 1 } - }; - initialize_cgilog(); if ($q->param(-name=>'secret') && $q->param(-name=>'target') ) { update_dynaddr $cfg,$q; } else { diff --git a/lib/Smokeping/probes/AnotherDNS.pm b/lib/Smokeping/probes/AnotherDNS.pm index 6d5a63f..65a1bd4 100644 --- a/lib/Smokeping/probes/AnotherDNS.pm +++ b/lib/Smokeping/probes/AnotherDNS.pm @@ -16,16 +16,6 @@ to generate the POD document. use strict; -# And now, an extra ugly hack -# Reason: Net::DNS does an eval("use Win32:Registry") to -# find out if it is running on Windows. This triggers the signal -# handler in the cgi mode. - -my $tmp = $SIG{__DIE__}; -$SIG{__DIE__} = sub { }; -eval("use Net::DNS;"); -$SIG{__DIE__} = $tmp; - use base qw(Smokeping::probes::basefork); use IPC::Open3; use Symbol; @@ -33,6 +23,7 @@ use Carp; use Time::HiRes qw(sleep ualarm gettimeofday tv_interval); use IO::Socket; use IO::Select; +use Net::DNS; sub pod_hash { return { diff --git a/lib/Smokeping/probes/Curl.pm b/lib/Smokeping/probes/Curl.pm index e04e6c9..8e40067 100644 --- a/lib/Smokeping/probes/Curl.pm +++ b/lib/Smokeping/probes/Curl.pm @@ -72,8 +72,8 @@ DOC timeout => { _doc => qq{The "-m" curl(1) option. Maximum timeout in seconds.}, _re => '\d+', - _example => 10, - _default => 5, + _example => 20, + _default => 10, }, interface => { _doc => <<DOC, @@ -144,7 +144,7 @@ sub test_usage { } sub ProbeDesc($) { - return "HTTP, HTTPS, and FTP URLs using curl(1)"; + return "URLs using curl(1)"; } # other than host, count and protocol-specific args come from here diff --git a/lib/Smokeping/probes/EchoPingHttp.pm b/lib/Smokeping/probes/EchoPingHttp.pm index 6483e10..464dd12 100644 --- a/lib/Smokeping/probes/EchoPingHttp.pm +++ b/lib/Smokeping/probes/EchoPingHttp.pm @@ -110,6 +110,8 @@ sub targetvars { delete $h->{udp}; delete $h->{fill}; delete $h->{size}; + $h->{timeout}{default} = 10; + $h->{timeout}{example} = 20; return $class->_makevars($h, { url => { _doc => <<DOC, diff --git a/lib/Smokeping/probes/LDAP.pm b/lib/Smokeping/probes/LDAP.pm index 07dd7f6..2888a14 100644 --- a/lib/Smokeping/probes/LDAP.pm +++ b/lib/Smokeping/probes/LDAP.pm @@ -19,7 +19,15 @@ use Smokeping::probes::passwordchecker; use Net::LDAP; use Time::HiRes qw(gettimeofday sleep); use base qw(Smokeping::probes::passwordchecker); -use IO::Socket::SSL; + +# don't bail out if IO::Socket::SSL +# can't be loaded, just warn +# about it when doing starttls + +my $havessl = 0; + +eval "use IO::Socket::SSL;"; +$havessl = 1 unless $@; my $DEFAULTINTERVAL = 1; @@ -42,7 +50,9 @@ be specified by the variables `port' and `version'. The probe can issue the starttls command to convert the connection into encrypted mode, if so instructed by the `start_tls' variable. -It can also optionally do an authenticated LDAP bind, if the `binddn' +This requires the 'IO::Socket::SSL' perl module to be installed. + +The probe can also optionally do an authenticated LDAP bind, if the `binddn' variable is present. The password to be used can be specified by the target-specific variable `password' or in an external file. The location of this file is given in the probe-specific variable @@ -95,6 +105,12 @@ sub targetvars { }, start_tls => { _doc => "If true, encrypt the connection with the starttls command. Disabled by default.", + _sub => sub { + my $val = shift; + return "ERROR: start_tls defined but IO::Socket::SSL couldn't be loaded" + if $val and not $havessl; + return undef; + }, _example => "1", }, timeout => { |