[-]
[+]
|
Changed |
munin.changes
|
|
[-]
[+]
|
Changed |
munin.spec
^
|
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/ChangeLog
^
|
@@ -1,5 +1,74 @@
-*- text -*-
+munin-2.0.13, 2013-04-26
+
+-------
+Summary
+-------
+
+Bugfix & perf release.
+
+- Fixes for munin-async
+- Enhanced perf for munin-html
+- Relaxed the timeout for munin-node
+ 2.0.12 fixed the timeout code. But it had a nasty side-effect as the timeout
+ setting is shared for global timeout and plugin timout. This version
+ decouples both by introducing a new global_timeout munin-node.conf variable
+ that defaults to 15 min.
+
+
+Closes: #775, #947, #1267, D:558800
+
+------------------
+Detailed Changelog
+------------------
+
+Jens Holzkämper:
+ different state files for cron job & as plugin
+
+Kenyon Ralph:
+ ntp_: rewrite plugin to support IPv6
+ ntp_states: decrease timeouts so DNS queries don't cause node timeout
+ ntp_states: don't use this silly plugin loading method
+ node.d/ntp_states: improve compatibility with older perls
+
+Kim B. Heino:
+ plugin/diskstats: fix negative stats, relax limits
+ plugins/http_loadtime: more wget/time fixes
+ plugins/lpstat: fix autodetection
+ plugins/snmp__if_multi: prefer ifAlias for alias name
+ plugins/postfix_mailstats: support proxy-rejected (amavis) log lines
+ asyncd: add more signal handlers.
+
+Steve Schnepp:
+ master: whitespace fix in Utils.pm
+ master: avoid having 2 concurrent $htmlconfig
+ master: undef the config pre-reload (frees mem)
+ master: RAM usage for $cache
+ master: remove weaken on storable::read
+ master: remove auto_weaken()
+ contrib: add a test for memory leaks
+ contrib: complete test with Storable dump/load
+ plugins: add doc about conntrack
+ plugins: use $PATH for external commands in shell
+ plugins/postfix_mailstats: using a per-minute graph
+ plugins/snmp_if: replace 32b counters by 64b ones
+ node: set the global timeout to 15 min
+ node: add timeout documentation in sample conf
+ master: add --debug to munin-graph
+ master: fix end date when predicting
+ plugins/Plugin.pm: fix a security issue on state
+ plugins/Plugin.pm: fix bad state file handling
+ p/http_loadtime: fix failure on FreeBSD
+ p/http_loadtime: do not reuse $TMPDIR
+ dev_scripts: run should only run executable files
+ node: add a lock to spoolreader
+ node: update doc to show negative args
+
+Stig Sandbeck Mathisen:
+ Use a more efficient sort on the list of nodes
+
+
munin-2.0.12, 2013-03-21
-------
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/RELEASE
^
|
@@ -1 +1 @@
-2.0.12
+2.0.13
|
[-]
[+]
|
Added |
munin-2.0.13.tar.bz2/contrib/perf/test_weak.pl
^
|
@@ -0,0 +1,35 @@
+#! /usr/bin/perl
+
+use warnings;
+use strict;
+
+use File::Temp;
+use Data::Dumper;
+use Storable qw(nstore_fd fd_retrieve);
+use Scalar::Util qw(weaken isweak);
+
+my $number = shift || 10;
+my $a = {};
+
+for my $i (0 .. $number) {
+ $a->{$i} = {
+ "$i$i" => "$i$i",
+ "$i$i" => "$i$i",
+ };
+}
+
+for my $i (0 .. $number) {
+ $a->{$i}{next} = $a->{ ($i + 1) % $number };
+ weaken($a->{$i}{next}) if $ENV{WEAKEN};
+}
+
+my $temp_storable = File::Temp->new();
+
+nstore_fd($a, $temp_storable);
+
+for my $j (0 .. ($number * $number)) {
+ $temp_storable->seek( 0, SEEK_SET );
+ $a = fd_retrieve($temp_storable);
+}
+
+print Dumper($a);
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/dev_scripts/run
^
|
@@ -17,7 +17,7 @@
fi
-RUN=$(find $DESTDIR -name $1)
+RUN=$(find $DESTDIR -name $1 -type f -executable)
shift
if [ -z "$RUN" ]; then
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/master/lib/Munin/Master/GraphOld.pm
^
|
@@ -248,6 +248,7 @@
# NOTE! Some of these options are available in graph_main too
# if you make changes here, make them there too.
+ my $debug;
&print_usage_and_exit
unless GetOptions (
"force!" => \$force_graphing,
@@ -280,7 +281,8 @@
"cron!" => \$cron,
"fork!" => \$do_fork,
"n=n" => \$max_running,
- "help" => \$do_usage
+ "help" => \$do_usage,
+ "debug!" => \$debug,
);
if ($do_version) {
@@ -1630,7 +1632,6 @@
# If pinpointing, --end should *NOT* be changed
if (! $pinpoint) {
- if (time - 300 < $lastupdate) {
if (@added) { # stop one period earlier if it's a .sum or .stack
push @complete, "--end",
(int(($enddate-$resolutions{$time}) / $resolutions{$time})) * $resolutions{$time};
@@ -1638,7 +1639,6 @@
push @complete, "--end",
(int($enddate / $resolutions{$time})) * $resolutions{$time};
}
- }
}
return @complete;
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/master/lib/Munin/Master/HTMLConfig.pm
^
|
@@ -34,6 +34,7 @@
sub generate_config {
my $use_cache = shift;
if ($use_cache) {
+ $cache = undef; # undef, for RAM usage
# if there is some cache, use it (for cgi)
my $newcache = munin_readconfig_part('htmlconf', 1);
if (defined $newcache) {
@@ -55,6 +56,7 @@
$limits = munin_readconfig_part("limits");
# if only limits changed, still update our cache
if ($rev != munin_configpart_revision()) {
+ $cache = undef; # undef, for RAM usage
$cache = get_group_tree($config);
}
@@ -614,8 +616,11 @@
my $me = munin_get_node_name($hash);
my $pchildren = munin_get_children($parent);
- foreach my $peer (sort {munin_get_node_name($b) cmp munin_get_node_name($a)}
- @$pchildren) {
+ my @peers = map { $_->[0] }
+ sort { $a->[1] cmp $b->[1] }
+ map { [ $_, munin_get_node_name($_) ] } @$pchildren;
+
+ foreach my $peer (@peers) {
next unless defined $peer and ref($peer) eq "HASH";
next
if defined $category
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/master/lib/Munin/Master/HTMLOld.pm
^
|
@@ -153,6 +153,7 @@
sub get_config {
my $use_cache = shift;
# usecache should match being in a cgi ($ENV{SCRIPT_NAME})
+ $htmlconfig = undef; # avoid double ram usage
if ($use_cache) {
$htmlconfig = generate_config($use_cache);
} else {
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/master/lib/Munin/Master/Utils.pm
^
|
@@ -87,7 +87,6 @@
'exit_if_run_by_super_user',
'look_for_child',
'wait_for_remaining_children',
- 'auto_weaken',
);
my $VERSION = $Munin::Common::Defaults::MUNIN_VERSION;
@@ -125,88 +124,6 @@
my $me = pop(@dircomponents);
-# `auto_weaken` performs a breadth-first descend of all strong references to
-# references (possible cycles). If it encounters a reference to an item it has
-# already seen earlier it will weaken that reference.
-sub auto_weaken {
- my $items = 0;
- my $weakened = 0;
- my %seen = map{ $_ => 1 } @_;
- my @todo = @_;
- while (my $cur = shift @todo) {
- $items++;
- if (ref($cur) eq 'HASH') {
- for my $key (keys %$cur) {
- next unless ref $cur->{$key};
- next if isweak $cur->{$key};
- my $tgt = $cur->{$key};
- if ($seen{$tgt}) {
- $weakened++;
- weaken $cur->{$key};
- } else {
- $seen{$tgt} = 1;
- push @todo, $tgt;
- }
- }
- } elsif (ref($cur) eq 'ARRAY') {
- for (my $i = 0 ; $i < @$cur ; $i++) {
- next unless ref $cur->[$i];
- next if isweak $cur->[$i];
- my $tgt = $cur->[$i];
- if ($seen{$tgt}) {
- $weakened++;
- weaken $cur->[$i];
- } else {
- $seen{$tgt} = 1;
- push @todo, $tgt;
- }
- }
- } elsif (ref($cur) eq 'SCALAR') {
- next unless ref $$cur;
- next if isweak $cur;
- my $tgt = $$cur;
- if ($seen{$tgt}) {
- $weakened++;
- weaken $cur;
- } else {
- $seen{$tgt} = 1;
- push @todo, $tgt;
- }
- }
- }
- # print "items: $items, weakened: $weakened\n";
- return @_;
-}
-
-# based on auto_weaken search, but only cares about #%#parents
-sub weaken_config {
- my @todo = @_;
- while (my $cur = shift @todo) {
- if (ref($cur) eq 'HASH') {
- for my $key (keys %$cur) {
- next unless ref $cur->{$key};
- next if isweak $cur->{$key};
- if ($key eq '#%#parent') {
- weaken($cur->{$key});
- next;
- }
- push @todo, $cur->{$key};
- }
- } elsif (ref($cur) eq 'ARRAY') {
- for (my $i = 0 ; $i < @$cur ; $i++) {
- next unless ref $cur->[$i];
- next if isweak $cur->[$i];
- push @todo, $cur->[$i];
- }
- } elsif (ref($cur) eq 'SCALAR') {
- next unless ref $$cur;
- next if isweak $cur;
- push @todo, $$cur;
- }
- }
- return @_;
-}
-
sub munin_draw_field {
my $hash = shift;
@@ -361,7 +278,6 @@
DEBUG "[DEBUG] munin_readconfig: found Storable version of $file, using it";
$part = Storable::fd_retrieve($CFG_STORABLE);
close ($CFG_STORABLE);
- weaken_config($part);
}
return $part;
@@ -955,9 +871,6 @@
DEBUG "[DEBUG] Writing state to $datafilename";
- # XXX - Refs should be weakened on construction
- auto_weaken($data);
-
munin_write_storable($datafilename, $data);
}
@@ -1053,6 +966,7 @@
my @stat = stat($filename);
if ($config_parts->{$what}{timestamp} < $stat[9]) {
# could use _raw if we wanted to read non-storable fallback
+ $config_parts->{$what}{config} = undef; # Unalloc RAM for old config, since it will be overriden anyway.
$part = munin_readconfig_storable($filename);
$config_parts->{$what}{timestamp} = $stat[9];
$doupdate = 1;
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/node/_bin/munin-asyncd.in
^
|
@@ -126,14 +126,23 @@
@plugins = split(/ /, $plugins_line);
}
+my $keepgoing = 1;
+
+sub termhandler() {
+ $keepgoing = 0;
+}
+
# Q&D child collection
$SIG{CHLD} = 'IGNORE';
+$SIG{HUP} = 'IGNORE';
+$SIG{INT} = 'termhandler';
+$SIG{TERM} = 'termhandler';
# now, update regularly...
# ... but each plugin in its own process to avoid delay-leaking
my %last_updated;
my $last_cleanup=0;
-MAIN: while(1) {
+MAIN: while($keepgoing) {
my $when = time;
{
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/node/lib/Munin/Node/Server.pm
^
|
@@ -132,7 +132,8 @@
# catch and report any system errors in a clean way.
eval {
- $timed_out = !do_with_timeout($services->{timeout}, sub {
+ my $global_timeout = $config->{global_timeout} || (60 * 15); # Defaults to 15 min. Should be enough
+ $timed_out = !do_with_timeout($global_timeout, sub {
while (defined ($line = _net_read($session))) {
chomp $line;
if (! _process_command_line($session, $line)) {
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/node/lib/Munin/Node/SpoolReader.pm
^
|
@@ -8,6 +8,8 @@
use Carp;
use IO::File;
+use Fcntl qw(:DEFAULT :flock);
+
use Munin::Common::Defaults;
use Munin::Common::SyncDictFile;
use Munin::Node::Logger;
@@ -111,6 +113,7 @@
open my $fh, '<', "$self->{spooldir}/$file"
or die "Unable to open spool file: $!";
+ flock($fh, LOCK_SH);
my $epoch;
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/node/munin-node.conf.in
^
|
@@ -12,6 +12,15 @@
user root
group root
+# This is the timeout for the whole transaction.
+# Units are in sec. Default is 15 min
+#
+# global_timeout 900
+
+# This is the timeout for each plugin.
+# Units are in sec. Default is 1 min
+#
+# timeout 60
# Regexps for files to ignore
ignore_file [\#~]$
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/node/sbin/munin-node
^
|
@@ -174,14 +174,14 @@
View this help message.
-=item B< --debug >
+=item B< --[no]debug >
View debug messages. This can be very verbose.
-=item B< --pidebug >
+=item B< --[no]pidebug >
Plugin debug. Sets the environment variable MUNIN_DEBUG to 1 so that plugins
-may enable debugging.
+may enable debugging. [--nopidebug]
=back
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/plugins/lib/Munin/Plugin.pm
^
|
@@ -24,6 +24,9 @@
use warnings;
use strict;
+# Put only core Perl modules here, as we don't want to ask for more deps
+use File::Temp; # File::Temp was first released with perl 5.006001
+
# This file uses subroutine prototypes. This is concidered a bad
# practice according to PBP (see page 194).
@@ -273,12 +276,9 @@
sub save_state (@) {
print "State file: $statefile\n" if $DEBUG;
- if (-l $statefile) {
- die "$me: $statefile is a symbolic link. Refusing to touch it for security reasons.\n";
- }
-
- open my $STATE, '>', $statefile or
- die "$me: Could not open statefile '$statefile' for writing: $!\n";
+ # Open a tempfile, to rename() after. ensures atomic updates.
+ my $STATE = File::Temp->new(DIR => $pluginstatedir, UNLINK => 0 )
+ or die "$me: Could not open temporary statefile in '$pluginstatedir' for writing: $!\n";
# Munin-state 1.0 encodes %, \n and \r in URL encoding and leaves
# the rest.
@@ -286,6 +286,8 @@
print $STATE join("\n",_encode_state(@_)),"\n";
close $STATE;
+
+ rename($STATE->filename, $statefile);
}
=head3 @state_vector = restore_state()
@@ -300,20 +302,29 @@
=cut
sub restore_state {
- # Read a state vector from a plugin appropriate state file
- local $/;
+ my @state;
- open my $STATE, '<', $statefile or return;
+ # Protects _restore_state_raw() with an eval()
+ eval { @state = return _restore_state_raw(); };
+ if ($@) { @state = (); }
- my @state = split(/\n/, <$STATE>);
+ return @state;
+}
- my $filemagic = shift(@state);
+sub _restore_state_raw {
+ open my $STATE, '<', $statefile or return;
- if ($filemagic ne '%MUNIN-STATE1.0') {
+ # Test the 1rst line
+ my $filemagic = <$STATE>;
+ if ($filemagic ne "%MUNIN-STATE1.0\n") {
warn "$me: Statefile $statefile has unrecognized magic number: '$filemagic'\n";
return;
}
+ # Slurp the rest
+ local $/;
+
+ my @state = split(/\n/, <$STATE>);
return _decode_state(@state);
}
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/plugins/node.d.linux/apt_all.in
^
|
@@ -52,7 +52,7 @@
$ENV{'LANG'}="C";
$ENV{'LC_ALL'}="C";
-my $statefile = ($ENV{MUNIN_PLUGSTATE} || '@@PLUGSTATE@@/root/') . "/plugin-apt.state";
+my $statefile = ($ENV{MUNIN_PLUGSTATE} || '@@PLUGSTATE@@/nobody/') . "/plugin-apt.state";
my @releases = ("stable", "testing","unstable");
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/plugins/node.d.linux/diskstats.in
^
|
@@ -195,6 +195,13 @@
my $average_rd_wait_in_sec = $read_ios ? $rd_ticks / $read_ios / 1000 : 0;
my $average_wr_wait_in_sec = $write_ios ? $wr_ticks / $write_ios / 1000 : 0;
+ if ( $average_rd_wait_in_sec < 0 ) {
+ $average_rd_wait_in_sec = 0;
+ }
+ if ( $average_wr_wait_in_sec < 0 ) {
+ $average_wr_wait_in_sec = 0;
+ }
+
my $average_rd_rq_size_in_kb =
$read_ios ? $rd_sectors * $bytes_per_sector / 1000 / $read_ios : 0;
my $average_wr_rq_size_in_kb =
@@ -837,13 +844,13 @@
avgrdwait.type GAUGE
avgrdwait.info Average wait time for a read I/O from request start to finish (includes queue times et al)
avgrdwait.min 0
-avgrdwait.warning 0:1
+avgrdwait.warning 0:3
avgrdwait.draw LINE1
avgwrwait.label Write IO Wait time
avgwrwait.type GAUGE
avgwrwait.info Average wait time for a write I/O from request start to finish (includes queue times et al)
avgwrwait.min 0
-avgwrwait.warning 0:1
+avgwrwait.warning 0:3
avgwrwait.draw LINE1
EOF
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/plugins/node.d.linux/fw_conntrack.in
^
|
@@ -32,6 +32,9 @@
ASSURED is after ACK is seen after SYN_RECV. Therefore ASSURED is
plotted but not UNREPLIED.
+Note that the plugin depends on the netfilter "conntrack" userspace tool.
+It comes from http://conntrack-tools.netfilter.org/
+
=head1 AUTHORS
=over
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/plugins/node.d/http_loadtime.in
^
|
@@ -38,12 +38,12 @@
if [ "$1" = "autoconf" ]; then
result="yes"
- command -v wget 2>/dev/null || result=1
+ command -v wget 2>/dev/null >/dev/null || result=1
if [ "$result" != "yes" ]; then
echo "no (need time and wget programs)"
exit 0
fi
- if ! $wget_bin -q -O /dev/null $target; then
+ if ! wget -q -O /dev/null $target; then
echo "no (Cannot run wget against \"$target\")"
exit 0
fi
@@ -62,12 +62,12 @@
exit 0
fi
-TMPDIR=`mktemp -d` || exit 1
+TEMPO_DIR=$(mktemp -dt munin_http_loadtime.XXXXXX) || exit 1
-trap "rm -rf $TMPDIR" EXIT
+trap "rm -rf $TEMPO_DIR" EXIT
-cd $TMPDIR || exit 1
-loadtime=$((time -p wget -p --no-cache --delete-after $target -q) 2>&1 | awk '/^real / { print $2 }')
+cd $TEMPO_DIR || exit 1
+loadtime=$((/usr/bin/time -p wget -p --no-cache --delete-after $target -q) 2>&1 | awk '/^real / { print $2 }')
cd ..
echo "loadtime.value $loadtime"
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/plugins/node.d/lpstat.in
^
|
@@ -77,13 +77,13 @@
print "no (lpstat not found)\n";
exit 0;
}
- if( ! open(LPSTAT_R, "$lpstat $host -r 2>/dev/null |") ) {
+ if( ! open(LPSTAT_R, "$lpstat $host -v 2>/dev/null |") ) {
print "no (could not execute lpstat)\n";
exit 0;
}
$_ = <LPSTAT_R>;
- if (! m/is running/mi) {
- print "no (scheduler is not running)\n";
+ if (! m/device for /mi) {
+ print "no (no printers configured)\n";
exit 0;
}
print "yes\n";
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/plugins/node.d/mhttping.in
^
|
@@ -38,7 +38,6 @@
my $datafile = "$ENV{MUNIN_PLUGSTATE}/mhttping.data" ;
my $resultsdir = "/home/gconnor/mhttping/results/" ;
-my $httping = "/usr/local/bin/httping" ;
my $timeout = 30 ;
my $count = 3 ;
my $options = "-c $count -s -t $timeout" ;
@@ -170,7 +169,7 @@
# Visit each site and grab the average time
for $site ( keys(%url) ) {
- $command="$httping $options $proxy{$site} -g $url{$site} 2>&1 " ;
+ $command="httping $options $proxy{$site} -g $url{$site} 2>&1 " ;
$debug && print "$command\n" ;
$result= `$command` ;
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/plugins/node.d/ntp_.in
^
|
@@ -1,146 +1,185 @@
#!@@PERL@@ -w
-# -*- perl -*-
+# -*- mode: cperl; cperl-indent-level: 8; -*-
=head1 NAME
-ntp_ - Plugin to monitor NTP statistics
+ntp_ - Wildcard plugin to monitor NTP statistics for a particular remote NTP peer
=head1 CONFIGURATION
-The following environment variables are used by this plugin:
+This is a wildcard plugin. The wildcard suffix in the symlink is the
+hostname, IPv4, or IPv6 address of the NTP peer that you want to
+monitor. The IP address must be one which appears in C<ntpq -np>
+output. If given a hostname, it must resolve to an IP address which
+appears in C<ntpq -np> output; this plugin will try all of the A or
+AAAA records returned. If you use a dynamic association method, such
+as "pool" or one of the broadcast or multicast methods, this plugin
+will probably not work very well for you, as your NTP peers could be
+changing frequently.
- [ntp_*]
- env.lowercase - lowercase hostnames after lookup
- env.nodelay 1 - Set to 1 to remove delay
+Examples:
+
+=over
-=head1 NOTES
+=item ntp_time.example.com
-This plugin is now "legacy" because it's not very useful, it is
-imposible to determine which peer is used as "master". The other ntp_*
-plugins are better. This one is no longer maintained.
+=item ntp_203.0.113.1
+
+=item ntp_2001:db8::1
+
+=back
+
+The following environment variables are used by this plugin:
+
+ [ntp_*]
+ env.lowercase - Lowercase hostnames after lookup
+ env.nodelay 1 - Set to 1 to disable graphing of delay
=head1 AUTHOR
-Author unknown
+Original author unknown. Rewritten by Kenyon Ralph <kenyon@kenyonralph.com>.
=head1 LICENSE
-License unknown
+Same as munin.
=head1 MAGIC MARKERS
- #%# family=legacy
- #%# capabilities=autoconf suggest
+ #%# family=auto
+ #%# capabilities=autoconf suggest
=cut
+use English qw( -no_match_vars );
use strict;
-use Net::hostent;
-use Socket;
-
-my $nodelay = $ENV{'nodelay'} || 0;
+use warnings;
+use Net::DNS;
+use Net::IP;
if ($ARGV[0] and $ARGV[0] eq "autoconf") {
- `ntpq -c help >/dev/null 2>/dev/null`;
- if ($? eq "0") {
- if (`ntpq -c "hostnames no" -c peers | wc -l` > 0) {
- print "yes\n";
- exit 0;
- } else {
- print "no (unable to list peers)\n";
- exit 0;
- }
- } else {
- print "no (ntpq not found)\n";
- exit 0;
- }
+ `ntpq -c help >/dev/null 2>/dev/null`;
+ if ($CHILD_ERROR eq "0") {
+ if (`ntpq -n -c peers | wc -l` > 0) {
+ print "yes\n";
+ exit 0;
+ } else {
+ print "no (ntpq -p returned no peers)\n";
+ exit 0;
+ }
+ } else {
+ print "no (ntpq not found)\n";
+ exit 0;
+ }
}
if ($ARGV[0] and $ARGV[0] eq "suggest") {
- my @lines = `ntpq -c "hostnames no" -c peers`;
- foreach (@lines) {
- next unless /^.(\d+\.\d+\.\d+\.\d+)/;
- next if /^.224\.0\.1\.1/;
- my $addr = $1;
- my $name;
- if( my $lcid= /^.127\.127\.1\.(\d+)/) {
- $lcid = $lcid - 1;
- $name = "LOCAL($lcid)";
- } else {
- $name = gethostbyaddr(inet_aton($addr));
- $name = defined $name ? $name->name : $addr;
- }
- $name = lc $name if exists $ENV{"lowercase"};
- $name =~ s/[\.\-()]/_/g;
- print $name, "\n";
- }
- exit 0;
+ foreach my $line (`ntpq -c associations`) {
+ if ($line =~ m/^\s*\d+/) {
+ my (undef, undef, $assid, undef, undef, undef, undef, undef, undef, undef) = split(/\s+/, $line);
+ chomp(my $peerinfo = `ntpq -n -c "readvar $assid srcadr"`);
+ $peerinfo =~ s/\R/ /g;
+ my ($peer_addr) = ($peerinfo =~ m/srcadr=(.*)/);
+ print $peer_addr, "\n" unless $peer_addr eq "0.0.0.0";
+ }
+ }
+ exit 0;
}
-$0 =~ /ntp_(.+)*$/;
+my $nodelay = $ENV{'nodelay'} || 0;
+$0 =~ /ntp_(.+)*$/;
my $name = $1;
-die "No hostname provided" unless defined $name;
+die "No hostname or IP address provided" unless defined $name;
if ($ARGV[0] and $ARGV[0] eq "config") {
- my @lines = `ntpq -c "hostnames no" -c peers`;
- my $host;
- foreach (@lines) {
- next unless /^.(\d+\.\d+\.\d+\.\d+)/;
- next if /^.224\.0\.1\.1/;
- my $addr = $1;
- my $host;
- if( my $lcid= /^.127\.127\.1\.(\d+)/) {
- $lcid = $lcid - 1;
- $host = "LOCAL($lcid)"
- } else {
- $host = gethostbyaddr(inet_aton($addr));
- $host = defined $host ? $host->name : $addr;
- }
- $host = lc $host if exists $ENV{"lowercase"};
- my $host_ = $host;
- $host_ =~ s/[\.\-()]/_/g;
- next unless $host_ eq $name;
- print "graph_title NTP statistics for peer $host\n";
- }
- print "graph_args --base 1000 --vertical-label seconds --lower-limit 0\n";
- print "graph_category time\n";
- print "delay.label Delay\n";
- print "delay.draw LINE\n";
- print "delay.graph no\n" if $nodelay;
- print "delay.cdef delay,1000,/\n";
+ print "graph_title NTP statistics for peer $name\n";
+ print "graph_args --base 1000 --vertical-label seconds --lower-limit 0\n";
+ print "graph_category time\n";
+ print "delay.label Delay\n";
+ print "delay.graph no\n" if $nodelay;
+ print "delay.cdef delay,1000,/\n";
print "offset.label Offset\n";
- print "offset.draw LINE\n";
- print "offset.cdef offset,1000,/\n";
+ print "offset.cdef offset,1000,/\n";
print "jitter.label Jitter\n";
- print "jitter.draw LINE\n";
- print "jitter.cdef jitter,1000,/\n";
+ print "jitter.cdef jitter,1000,/\n";
exit 0;
}
-my @lines = `ntpq -c "hostnames no" -c peers`;
-foreach (@lines) {
- next unless /^.(\d+\.\d+\.\d+\.\d+)/;
- next if /^.224\.0\.1\.1/;
- my $addr = $1;
- my $host;
- if( my $lcid= /^.127\.127\.1\.(\d+)/) {
- $lcid = $lcid - 1;
- $host = "LOCAL($lcid)"
- } else {
- $host = gethostbyaddr(inet_aton($addr));
- $host = defined $host ? $host->name : $addr;
- }
- $host = lc $host if exists $ENV{"lowercase"};
- $host =~ s/[\.\-()]/_/g;
- next unless $host eq $name;
- my @F = split;
- print <<"EOT";
-delay.value $F[7]
-offset.value $F[8]
-jitter.value $F[9]
-EOT
+my $srcadr;
+my $delay;
+my $offset;
+my $jitter;
+my @associations = `ntpq -c associations`;
+
+foreach my $line (@associations) {
+ if ($line =~ m/^\s*\d+/) {
+ my (undef, undef, $assid, undef, undef, undef, undef, undef, undef, undef) = split(/\s+/, $line);
+ chomp(my $peerinfo = `ntpq -n -c "readvar $assid srcadr,delay,offset,jitter"`);
+ $peerinfo =~ s/\R/ /g;
+ ($srcadr, $delay, $offset, $jitter) = split(/, /, $peerinfo);
+ ($srcadr) = ($srcadr =~ m/srcadr=(.*)/);
+ ($delay) = ($delay =~ m/delay=(.*)/);
+ ($offset) = ($offset =~ m/offset=(.*)/);
+ ($jitter) = ($jitter =~ m/jitter=(.*)/);
+ last if lc($srcadr) eq lc($name);
+ }
+}
+
+my $matched = 0;
+
+if (lc($srcadr) ne lc($name)) {
+ my @addresses;
+ my $resolver = Net::DNS::Resolver->new;
+ my $query = $resolver->search($name, "AAAA");
+
+ if ($query) {
+ foreach my $rr ($query->answer) {
+ if ("AAAA" eq $rr->type) {
+ push(@addresses, new Net::IP($rr->address));
+ }
+ }
+ }
+
+ $query = $resolver->search($name, "A");
+
+ if ($query) {
+ foreach my $rr ($query->answer) {
+ if ("A" eq $rr->type) {
+ push(@addresses, new Net::IP($rr->address));
+ }
+ }
+ }
+
+ ASSOCS: foreach my $line (@associations) {
+ if ($line =~ m/^\s*\d+/) {
+ my (undef, undef, $assid, undef, undef, undef, undef, undef, undef, undef) = split(/\s+/, $line);
+ chomp(my $peerinfo = `ntpq -n -c "readvar $assid srcadr,delay,offset,jitter"`);
+ $peerinfo =~ s/\R/ /g;
+ ($srcadr, $delay, $offset, $jitter) = split(/, /, $peerinfo);
+ ($srcadr) = new Net::IP($srcadr =~ m/srcadr=(.*)/);
+ ($delay) = ($delay =~ m/delay=(.*)/);
+ ($offset) = ($offset =~ m/offset=(.*)/);
+ ($jitter) = ($jitter =~ m/jitter=(.*)/);
+
+ ADDRS: foreach my $addr (@addresses) {
+ if (defined($srcadr->overlaps($addr)) and $srcadr->overlaps($addr) == $IP_IDENTICAL) {
+ $matched = 1;
+ last ASSOCS;
+ }
+ }
+ }
+ }
+}
+
+if (lc($srcadr) ne lc($name) and $matched == 0) {
+ die "$name is not a peer of this ntpd";
}
+print <<"EOT";
+delay.value $delay
+offset.value $offset
+jitter.value $jitter
+EOT
+
exit 0;
# vim:syntax=perl
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/plugins/node.d/ntp_states.in
^
|
@@ -40,16 +40,7 @@
use strict;
use warnings;
use File::Spec;
-
-my $ret = undef;
-
-if (!eval "require Net::DNS;")
-{
- $ret = "Net::DNS not found";
- if (!defined $ARGV[0]) {
- die $ret;
- }
-}
+use Net::DNS;
# Include /usr/local/sbin in the path to use the ntpq installed by
# ports on FreeBSD instead of the base system, which is probably
@@ -68,6 +59,8 @@
);
my %peers_condition;
my $resolver = Net::DNS::Resolver->new;
+$resolver->tcp_timeout(5);
+$resolver->udp_timeout(5);
# Returns a hash whose keys are peer IP addresses and values are
# condition numbers.
@@ -83,7 +76,7 @@
if ($line =~ m/^\s*\d+/) {
my (undef, undef, $assid, undef, undef, undef, undef, $condition_str, undef, undef) = split(/\s+/, $line);
chomp(my $peerinfo = `ntpq -n -c "readvar $assid srcadr"`);
- $peerinfo =~ s/\R//g;
+ $peerinfo =~ s/\s//g;
my ($peer_addr) = ($peerinfo =~ m/srcadr=(.*)/);
# some states get the last letter cut off in
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/plugins/node.d/postfix_mailstats.in
^
|
@@ -137,6 +137,7 @@
print "graph_scale no\n";
print "graph_total Total\n";
print "graph_category postfix\n";
+ print "graph_period minute\n";
print "delivered.label delivered\n";
print "delivered.type DERIVE\n";
print "delivered.draw AREA\n";
@@ -185,7 +186,8 @@
{
$delivered++;
}
- elsif ($line =~ /postfix\/smtpd.*reject: \S+ \S+ \S+ (\S+)/ ||
+ elsif ($line =~ /postfix\/smtpd.*proxy-reject: \S+ (\S+)/ ||
+ $line =~ /postfix\/smtpd.*reject: \S+ \S+ \S+ (\S+)/ ||
$line =~ /postfix\/cleanup.* reject: (\S+)/)
{
$rejects->{$1}++;
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/plugins/node.d/snmp__if_multi.in
^
|
@@ -596,7 +596,7 @@
sub do_config_if {
my ($host,$version,$if) = @_;
- my $alias = $snmpinfo->{$if}->{ifDescr} || "Interface $if";
+ my $alias = $snmpinfoX->{$if}->{ifAlias} || $snmpinfo->{$if}->{ifDescr} || "Interface $if";
if (! ($alias =~ /\d+/) ) {
# If there are no numbers in the $alias add the if index
@@ -715,17 +715,10 @@
# interfaces with a "fishy" status. That is a possible bug.
# Or a feature. We'll see.
- $in += $snmpinfoX->{$if}->{ifHCInOctets} ||
- $snmpinfo->{$if}->{ifInOctets};
-
- $out += $snmpinfoX->{$if}->{ifHCOutOctets} ||
- $snmpinfo->{$if}->{ifOutOctets};
-
- $inerr += ( $snmpinfo->{$if}->{ifInErrors} || 0 ) +
- ( $snmpinfo->{$if}->{ifInDiscards} || 0 );
-
- $outerr += ( $snmpinfo->{$if}->{ifOutErrors} || 0 ) +
- ( $snmpinfo->{$if}->{ifOutDiscards} || 0 );
+ $in += $snmpinfoX->{$if}->{ifHCInOctets} || $snmpinfo->{$if}->{ifInOctets} || 0;
+ $out += $snmpinfoX->{$if}->{ifHCOutOctets} || $snmpinfo->{$if}->{ifOutOctets} || 0;
+ $inerr += $snmpinfoX->{$if}->{ifInErrors} || $snmpinfo->{$if}->{ifInDiscards} || 0;
+ $outerr += $snmpinfoX->{$if}->{ifOutErrors} || $snmpinfo->{$if}->{ifOutDiscards} || 0;
}
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/plugins/node.d/squeezebox_.in
^
|
@@ -19,9 +19,10 @@
SqueezeCenter. If the plugin is run from another unit or in a
non-default configuration, please use the environment variables
'squeezebox_host' and 'squeezebox_port' to connect. Also, if your
-netcat(1) binary is anywhere else than /bin/nc please define it in the
-plugin's environment file (@@CONFDIR@@/squeezebox or
-similar). Sample follows:
+nc(1) binary is not called "nc", or not the one in $PATH, please define it
+in the plugin's environment file (@@CONFDIR@@/squeezebox or similar).
+
+Sample follows:
[squeezebox_*]
env.squeezebox_host 192.168.100.10
@@ -58,7 +59,7 @@
HOST=${squeezecenter_host:-localhost}
PORT=${squeezecenter_port:-9090}
-NC=${netcat:-/bin/nc}
+NC=${netcat:-nc}
if [ "$1" = "autoconf" ]; then
if [ ! "which $NC 1>/dev/null 2>&1" ]; then
|
[-]
[+]
|
Changed |
munin-2.0.13.tar.bz2/plugins/plugins.history.in
^
|
@@ -357,3 +357,4 @@
[2.0.11]
[2.0.11.1]
[2.0.12]
+[2.0.13]
|