From f6d4093e0dc827fbc853ed21ad3cb0ab1f898704 Mon Sep 17 00:00:00 2001 From: Niko Tyni Date: Fri, 18 Feb 2005 13:04:12 +0000 Subject: * graph fixes for small numbers of pings -- Chris Wilson * fix the LDAP probe killing the CGI with perl <5.6 -- Peter Farmer * make the LDAP probe work withouth IO::Socket::SSL -- niko * make Curl description shorter -- Chris Wilson * use CGI::Carp for CGI error handling - remove the now unnecessary kludge from AnotherDNS * don't call exit() in the daemon __DIE__ handler * raise Curl and EchoPingHttp{,s} default timeouts * add a section on timeouts to smokeping_upgrade * add IO::Socket::SSL to smokeping_install --- lib/Smokeping.pm | 20 ++++++-------------- lib/Smokeping/probes/AnotherDNS.pm | 11 +---------- lib/Smokeping/probes/Curl.pm | 6 +++--- lib/Smokeping/probes/EchoPingHttp.pm | 2 ++ lib/Smokeping/probes/LDAP.pm | 20 ++++++++++++++++++-- 5 files changed, 30 insertions(+), 29 deletions(-) (limited to 'lib') 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 "
".(shift)."
"; }; - $SIG{__DIE__} = sub { print "
".(shift)."
"; 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 => <{udp}; delete $h->{fill}; delete $h->{size}; + $h->{timeout}{default} = 10; + $h->{timeout}{example} = 20; return $class->_makevars($h, { url => { _doc => < { _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 => { -- cgit v1.2.3-24-g4f1b