Index: lib/Smokeping.pm =================================================================== --- lib/Smokeping.pm (revision 1039) +++ lib/Smokeping.pm (working copy) @@ -2,6 +2,7 @@ package Smokeping; use strict; +use warnings; use CGI; use Getopt::Long; use Pod::Usage; @@ -1547,16 +1548,27 @@ sub display_webpage($$){ my $cfg = shift; my $q = shift; - my $trag = ''; + my $targ = ''; + my $path; + my $slave; if ( $q->param('target') and $q->param('target') !~ /\.\./ and $q->param('target') =~ /(\S+)/){ $targ = $1; } - my ($path,$slave) = split(/~/,$targ); - if ($slave and $slave ~= /(\S+)/){ + my @slaves = split(/~/,$targ); +# my ($slave,$path) = @slaves; +# if ($slave and $slave ~= /(\S+)/){ +# die "ERROR: slave '$slave' is not defined in the '*** Slaves ***' section!\n" +# unless defined $cfg->{Slaves}{$slave}; +# $slave = $1; +# } + for my $slave (@slaves) { + #$slave ~= /(\S+)/); die "ERROR: slave '$slave' is not defined in the '*** Slaves ***' section!\n" - unless defined $cfg->{Slaves}{$slave}; + unless $slave eq '' or defined $cfg->{Slaves}{$slave}; $slave = $1; + $path = $1; # no idea what that should be set to } + my $hierarchy = $q->param('hierarchy'); die "ERROR: unknown hierarchy $hierarchy\n" if $hierarchy and not $cfg->{Presentation}{hierarchies}{$hierarchy}; @@ -1810,8 +1822,8 @@ do_log("Alert $_ $what for $line"); my $urlline = $line; $urlline = $cfg->{General}{cgiurl}."?target=".$line; - my $loss = "loss: ".join ", ",map {defined $_ ? (/^\d/ ? sprintf "%.0f%%", $_ :$_):"U" } @{$x->{loss}}; - my $rtt = "rtt: ".join ", ",map {defined $_ ? (/^\d/ ? sprintf "%.0fms", $_*1000 :$_):"U" } @{$x->{rtt}}; + $loss = "loss: ".join ", ",map {defined $_ ? (/^\d/ ? sprintf "%.0f%%", $_ :$_):"U" } @{$x->{loss}}; + $rtt = "rtt: ".join ", ",map {defined $_ ? (/^\d/ ? sprintf "%.0fms", $_*1000 :$_):"U" } @{$x->{rtt}}; my $time = time; my @stamp = localtime($time); my $stamp = localtime($time); @@ -3587,13 +3599,14 @@ } sub daemonize_me ($) { - my $pidfile = shift; + my $pidfile = shift; + my $pid; if (defined $pidfile){ if (-f $pidfile ) { open PIDFILE, "<$pidfile"; =~ /(\d+)/; close PIDFILE; - my $pid = $1; + $pid = $1; die "ERROR: I Quit! Another copy of $0 ($pid) seems to be running.\n". " Check $pidfile\n" if kill 0, $pid; @@ -3602,7 +3615,7 @@ print "Warning: no logging method specified. Messages will be lost.\n" unless $logging; print "Daemonizing $0 ...\n"; - defined (my $pid = fork) or die "Can't fork: $!"; + defined ($pid = fork) or die "Can't fork: $!"; if ($pid) { exit; } else { @@ -4153,6 +4166,9 @@ my $myprobe; my $multiprocessmode; my $forkprobes = $cfg->{General}{concurrentprobes} || 'yes'; + my $gothup = 0; + my $sig; + my $step; if ($forkprobes eq "yes" and keys %$probes > 1 and not $opt{debug}) { $multiprocessmode = 1; my %probepids; @@ -4165,7 +4181,7 @@ do_log("All probe processes started successfully."); my $exiting = 0; my $reloading = 0; - for my $sig (qw(INT TERM)) { + for $sig (qw(INT TERM)) { $SIG{$sig} = sub { do_log("Got $sig signal, terminating child processes."); $exiting = 1; @@ -4191,7 +4207,7 @@ delete $probepids{$dead}; } }; - my $gothup = 0; + $SIG{HUP} = sub { do_debuglog("Got HUP signal."); $gothup = 1; @@ -4218,7 +4234,7 @@ $i++; my %termsent; for (keys %probepids) { - my $step = $oldprobes->{$probepids{$_}}->step; + $step = $oldprobes->{$probepids{$_}}->step; if ($i > $step) { do_log("Child process $_ took over its step value to terminate, killing it with SIGTERM"); if (kill SIGTERM, $_ == 0 and exists $probepids{$_}) { @@ -4266,14 +4282,13 @@ } KID: my $offset; - my $step; - my $gothup = 0; + $gothup = 0; my $changeprocessnames = $cfg->{General}{changeprocessnames} ne "no"; $SIG{HUP} = sub { do_log("Got HUP signal, " . ($multiprocessmode ? "exiting" : "restarting") . " gracefully."); $gothup = 1; }; - for my $sig (qw(INT TERM)) { + for $sig (qw(INT TERM)) { $SIG{$sig} = sub { do_log("got $sig signal, terminating."); exit 1; @@ -4340,8 +4355,9 @@ } exit 0 if $opt{debug}; my $runtime = time - $now; + my $warn; if ($runtime > $step) { - my $warn = "WARNING: smokeping took $runtime seconds to complete 1 round of polling. ". + $warn = "WARNING: smokeping took $runtime seconds to complete 1 round of polling. ". "It should complete polling in $step seconds. ". "You may have unresponsive devices in your setup.\n"; if (defined $myprobe) { @@ -4351,7 +4367,7 @@ } } elsif ($runtime > $step * 0.8) { - my $warn = "NOTE: smokeping took $runtime seconds to complete 1 round of polling. ". + $warn = "NOTE: smokeping took $runtime seconds to complete 1 round of polling. ". "This is over 80% of the max time available for a polling cycle ($step seconds).\n"; if (defined $myprobe) { $probes->{$myprobe}->do_log($warn); Index: bin/tSmoke.dist =================================================================== --- bin/tSmoke.dist (revision 1039) +++ bin/tSmoke.dist (working copy) @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/bin/env perl # #----------------------------------------------- # tSmoke.pl @@ -43,6 +43,7 @@ # Tobias Oetiker, or course, the author of Smokeping, RRDTool and MRTG # use strict; +use warnings; # We need to use # -- Smokeping libraries Index: bin/smokeping.dist =================================================================== --- bin/smokeping.dist (revision 1039) +++ bin/smokeping.dist (working copy) @@ -1,6 +1,8 @@ -#!/usr/sepp/bin/perl-5.8.4 -w +#!/bin/env perl # -*-perl-*- +use strict; +use warnings; use lib qw(/usr/pack/rrdtool-1.2.23-mo/lib/perl); use lib qw(lib); Index: Makefile =================================================================== --- Makefile (revision 1039) +++ Makefile (working copy) @@ -9,11 +9,14 @@ NUMVERSION = 2.004000 IGNORE = ~|CVS|var/|smokeping-$(VERSION)/smokeping-$(VERSION)|cvsignore|rej|orig|DEAD|pod2htm[di]\.tmp|\.svn|tar\.gz|DEADJOE|svn-commit\.tmp GROFF = groff -PERL = perl-5.8.8 +PERL = perl +PERLLIB = -I/usr/pack/rrdtool-1.2svn-to/lib/perl .PHONY: man html txt ref examples check-examples patch killdoc doc tar rename-man symlinks remove-symlinks .SUFFIXES: .SUFFIXES: .pm .pod .txt .html .man .1 .3 .5 .7 +default: doc + DOCS = $(filter-out doc/smokeping_config.pod doc/smokeping.pod doc/smokeping.cgi.pod,$(wildcard doc/*.pod)) doc/smokeping_examples.pod # section 7 DOCSCONFIG := doc/smokeping_config.pod # section 5 PM := lib/Config/Grammar.pm lib/Smokeping.pm lib/Smokeping/Examples.pm lib/Smokeping/RRDtools.pm @@ -40,8 +43,8 @@ # pod2html apparently needs to be in the target directory to get L<> links right POD2HTML= cd $(dir $@); top="$(shell echo $(dir $@)|sed -e 's,doc/,,' -e 's,[^/]*/,../,g' -e 's,/$$,,')"; top=$${top:-.}; pod2html --infile=$(CURDIR)/$< --noindex --htmlroot=. --podroot=. --podpath=$${top} --title=$* | $${top}/../util/fix-pod2html.pl > $(notdir $@) # we go to this trouble to ensure that MAKEPOD only uses modules in the installation directory -MAKEPOD= $(PERL) -I/home/oetiker/lib/fake-perl/ -Ilib -I/usr/pack/rrdtool-1.2svn-to/lib/perl -mSmokeping -e 'Smokeping::main()' -- --makepod -GENEX= $(PERL) -I/home/oetiker/lib/fake-perl/ -Ilib -I/usr/pack/rrdtool-1.2svn-to/lib/perl -mSmokeping -e 'Smokeping::main()' -- --gen-examples +MAKEPOD= $(PERL) -I/home/oetiker/lib/fake-perl/ -Ilib $(PERLLIB) -mSmokeping -e 'Smokeping::main()' -- --makepod +GENEX= $(PERL) -I/home/oetiker/lib/fake-perl/ -Ilib $(PERLLIB) -mSmokeping -e 'Smokeping::main()' -- --gen-examples doc/%.7: doc/%.pod $(POD2MAN) --section 7 > $@ @@ -144,9 +147,17 @@ $(GENEX) killdoc: - -rm doc/*.[1357] doc/*.txt doc/*.html doc/Smokeping/* doc/Smokeping/probes/* doc/Smokeping/matchers/* doc/Smokeping/sorters/* doc/Config/* doc/examples/* doc/smokeping_examples.pod doc/smokeping_config.pod doc/smokeping.pod doc/smokeping.cgi.pod + -rm -f doc/*.[1357] doc/*.txt doc/*.html \ + doc/Smokeping/* doc/Smokeping/probes/* \ + doc/Smokeping/matchers/* \ + doc/Smokeping/sorters/* \ + doc/Config/* \ + doc/examples/* \ + doc/smokeping_examples.pod \ + doc/smokeping_config.pod \ + doc/smokeping.pod doc/smokeping.cgi.pod -doc: killdoc ref examples man html txt rename-man +doc: killdoc ref examples man html txt rename-man docdirs: for d in doc/Config doc/examples doc/Smokeping/probes \ @@ -154,6 +165,8 @@ [ -d $$d ] || mkdir -p $$d; \ done +clean: killdoc + # patch first so Smokeping.pm is older than smokeping_config.pod in the tarball smokeping-$(VERSION).tar.gz: $(PERL) -i~ -p -e 's/VERSION="\d.*?"/VERSION="$(NUMVERSION)"/' lib/Smokeping.pm