]>
Commit | Line | Data |
---|---|---|
c235887a MM |
1 | --- smokeping-2.6.11.orig/lib/Smokeping.pm 2015-12-21 13:02:15.615786332 +0100 |
2 | +++ smokeping-2.6.11/lib/Smokeping.pm 2015-12-21 20:26:59.387447714 +0100 | |
3 | @@ -10,7 +10,7 @@ | |
4 | use SNMP_Session; | |
5 | # enable locale?? | |
6 | #use locale; | |
7 | -use POSIX qw(locale_h signal_h sys_wait_h); | |
8 | +use POSIX qw(fmod locale_h signal_h sys_wait_h); | |
9 | use Smokeping::Config; | |
10 | use RRDs; | |
11 | use Sys::Syslog qw(:DEFAULT setlogsock); | |
12 | @@ -21,6 +21,7 @@ | |
13 | use Smokeping::RRDhelpers; | |
14 | use Smokeping::Graphs; | |
15 | use URI::Escape; | |
16 | +use Time::HiRes; | |
17 | ||
18 | setlogsock('unix') | |
19 | if grep /^ $^O $/xo, ("linux", "openbsd", "freebsd", "netbsd"); | |
20 | @@ -4395,18 +4396,27 @@ | |
21 | ||
22 | report_probes($probes, $myprobe); | |
23 | ||
24 | + my $now = Time::HiRes::time(); | |
25 | + my $longprobe = 0; | |
26 | while (1) { | |
27 | unless ($opt{nosleep} or $opt{debug}) { | |
28 | - my $sleeptime = $step - (time-$offset) % $step; | |
29 | + my $sleeptime = $step - fmod($now-$offset, $step); | |
30 | + my $logmsg = "Sleeping $sleeptime seconds."; | |
31 | + if ($longprobe && $step-$sleeptime < 0.3) { | |
32 | + $logmsg = "NOT sleeping $sleeptime seconds, running probes immediately."; | |
33 | + $sleeptime = 0; | |
34 | + } | |
35 | if (defined $myprobe) { | |
36 | - $probes->{$myprobe}->do_debug("Sleeping $sleeptime seconds."); | |
37 | + $probes->{$myprobe}->do_debug($logmsg); | |
38 | } else { | |
39 | - do_debuglog("Sleeping $sleeptime seconds."); | |
40 | + do_debuglog($logmsg); | |
41 | + } | |
42 | + if ($sleeptime > 0) { | |
43 | + Time::HiRes::sleep($sleeptime); | |
44 | } | |
45 | - sleep $sleeptime; | |
46 | last if checkhup($multiprocessmode, $gothup) && reload_cfg($cfgfile); | |
47 | } | |
48 | - my $now = time; | |
49 | + my $startts = Time::HiRes::time(); | |
50 | run_probes $probes, $myprobe; # $myprobe is undef if running without 'concurrentprobes' | |
51 | my %sortercache; | |
52 | if ($opt{'master-url'}){ | |
53 | @@ -4430,8 +4440,11 @@ | |
54 | save_sortercache($cfg,\%sortercache,$myprobe); | |
55 | } | |
56 | exit 0 if $opt{debug}; | |
57 | - my $runtime = time - $now; | |
58 | + $now = Time::HiRes::time(); | |
59 | + my $runtime = $now - $startts; | |
60 | + $longprobe = 0; | |
61 | if ($runtime > $step) { | |
62 | + $longprobe = 1; | |
63 | my $warn = "WARNING: smokeping took $runtime seconds to complete 1 round of polling. ". | |
64 | "It should complete polling in $step seconds. ". | |
65 | "You may have unresponsive devices in your setup.\n"; | |
66 | @@ -4442,6 +4455,7 @@ | |
67 | } | |
68 | } | |
69 | elsif ($runtime > $step * 0.8) { | |
70 | + $longprobe = 1; | |
71 | my $warn = "NOTE: smokeping took $runtime seconds to complete 1 round of polling. ". | |
72 | "This is over 80% of the max time available for a polling cycle ($step seconds).\n"; | |
73 | if (defined $myprobe) { |