From 39eded37581cfe09d85d1225355fd1e22264cbf3 Mon Sep 17 00:00:00 2001 From: Tobi Oetiker Date: Mon, 2 Jun 2008 20:52:26 +0000 Subject: mtr integration --- lib/Smokeping.pm | 49 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 11 deletions(-) (limited to 'lib/Smokeping.pm') diff --git a/lib/Smokeping.pm b/lib/Smokeping.pm index 8437944..2c51954 100644 --- a/lib/Smokeping.pm +++ b/lib/Smokeping.pm @@ -631,16 +631,30 @@ sub target_menu($$$$;$){ my $menu = $key; my $title = $key; my $hide; + my $host; + my $menuextra; if ($tree->{$key}{__tree_link} and $tree->{$key}{__tree_link}{menu}){ $menu = $tree->{$key}{__tree_link}{menu}; $title = $tree->{$key}{__tree_link}{title}; - next if $tree->{$key}{__tree_link}{hide} and $tree->{$key}{__tree_link}{hide} eq 'yes'; - } elsif ($tree->{$key}{menu}) { + $host = $tree->{$key}{__tree_link}{host}; + $menuextra = $tree->{$key}{__tree_link}{menuextra}; + next if $tree->{$key}{__tree_link}{hide} and $tree->{$key}{__tree_link}{hide} eq 'yes'; + } elsif ($tree->{$key}{menu}) { $menu = $tree->{$key}{menu}; $title = $tree->{$key}{title}; - next if $tree->{$key}{hide} and $tree->{$key}{hide} eq 'yes'; + $host = $tree->{$key}{host}; + $menuextra = $tree->{$key}{menuextra}; + next if $tree->{$key}{hide} and $tree->{$key}{hide} eq 'yes'; }; - + # no menuextra for multihost + if (not $host or $host =~ m|^/|){ + $menuextra = undef; + } + if ($menuextra){ + $menuextra =~ s/##host##/$host/g; + } else { + $menuextra = ''; + } my $class = 'menuitem'; if ($key eq $current ){ if ( @$open ) { @@ -659,12 +673,13 @@ sub target_menu($$$$;$){ else { $menu =~ s/ / /g; my $menuadd =""; - $menuadd = " " x (20 - length($menu)) if length($menu) < 20; + $menuadd = " " x (20 - length($menu.$menuextra)) if length($menu.$menuextra) < 20; my $menuclass = "menulink"; if ($key eq $current and !@$open) { $menuclass = "menulinkactive"; } - $print .= qq{ - $menu$menuadd\n}; + + $print .= qq{ - $menu$menuextra$menuadd\n}; if ($key eq $current){ my $prline = target_menu $tree->{$key}, $open, "$path$key.",$filter, $suffix; $print .= qq{  $prline} @@ -2016,11 +2031,11 @@ sub get_parser () { # the part of target section syntax that doesn't depend on the selected probe my $TARGETCOMMON; # predeclare self-referencing structures # the common variables - my $TARGETCOMMONVARS = [ qw (probe menu title alerts note email host remark rawlog alertee slaves parents hide nomasterpoll) ]; + my $TARGETCOMMONVARS = [ qw (probe menu title alerts note email host remark rawlog alertee slaves menuextra parents hide nomasterpoll) ]; $TARGETCOMMON = { _vars => $TARGETCOMMONVARS, - _inherited=> [ qw (probe alerts alertee slaves nomasterpoll) ], + _inherited=> [ qw (probe alerts alertee slaves menuextra nomasterpoll) ], _sections => [ "/$KEYD_RE/" ], _recursive=> [ "/$KEYD_RE/" ], _sub => sub { @@ -2205,6 +2220,11 @@ DOC _re_error => 'Use the format: slaves='.${KEYDD_RE}.' [slave2]', _doc => < { + _doc => <. +This entry does get inherited. Use this for example to add a link to your mtr service. DOC probe => { _sub => sub { @@ -3421,10 +3441,10 @@ END_DOC The Target Section defines the actual work of SmokePing. It contains a hierarchical list of hosts which mark the endpoints of the network connections the system should monitor. Each section can contain one host as -well as other sections. By adding slaves you can measure the connectivity of -an endpoint looking from several sources. +well as other sections. By adding slaves you can measure the connection to +an endpoint from multiple locations. DOC - _vars => [ qw(probe menu title remark alerts slaves parents) ], + _vars => [ qw(probe menu title remark alerts slaves menuextra parents) ], _mandatory => [ qw(probe menu title) ], _order => 1, _sections => [ "/$KEYD_RE/" ], @@ -3494,6 +3514,13 @@ DOC remark => { _doc => < { _doc => < { _doc => < entry will be replaces by the +host of the relevant section if there is one. DOC } -- cgit v1.2.3-24-g4f1b