Changeset 1345

Show
Ignore:
Timestamp:
10/21/07 20:37:58 (4 years ago)
Author:
jo
Message:

Service pages are now created properly for multilevel group structure.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • people/jo/multilevel-groups-2/server/Munin.pm.in

    r1344 r1345  
    4848           'munin_category_status', 
    4949           'munin_get_picture_filename', 
     50           'munin_get_html_filename', 
    5051           'munin_get_filename', 
    5152           'munin_graph_column_headers', 
     
    5556           'munin_find_field', 
    5657           'munin_get_node_name', 
     58           'munin_get_parent_name', 
    5759           'munin_get_node_loc', 
    5860           'munin_get_node', 
     
    6163           'munin_get_separated_node', 
    6264           'munin_mkdir_p', 
     65           'munin_get_parent', 
    6366           'munin_get_node_partialpath' 
    6467           ); 
     
    464467} 
    465468 
     469# munin_get_parent_name: Return the name of the parent of the hash node supplied 
     470# Parameters:  
     471# - $hash: A ref to the hash node 
     472# Returns: 
     473# - Success: The name of the parent node 
     474# - Failure: If no parent node exists, "none" is returned. 
     475sub munin_get_parent_name 
     476{ 
     477    my $hash = shift; 
     478 
     479    if (ref ($hash) eq "HASH" and defined $hash->{'#%#parent'}) { 
     480        return munin_get_node_name ($hash->{'#%#parent'}); 
     481    } else {  
     482        return "none"; 
     483    } 
     484} 
     485 
    466486# munin_get_node_name: Return the name of the hash node supplied 
    467487# Parameters:  
     
    480500} 
    481501 
     502 
    482503# munin_get_node_loc: Get location array for hash node 
    483504# Parameters:  
     
    486507# - Success: Ref to an array with the full path of the variable 
    487508# - Failure: undef 
    488 sub munin_get_node_loc 
    489 
     509sub munin_get_node_loc { 
    490510    my $hash = shift; 
    491511    my $res = []; 
     
    499519    } 
    500520    return $res; 
     521} 
     522 
     523# munin_get_parent: Get parent node of a hash 
     524# Parameters:  
     525# - $hash: A ref to the node 
     526# Returns: 
     527# - Success: Ref to an parent 
     528# - Failure: undef 
     529sub munin_get_parent { 
     530    my $hash = shift; 
     531 
     532    if (ref ($hash) ne "HASH") { # Not a has node 
     533        return undef; 
     534    } 
     535    if (defined $hash->{'#%#parent'}) { 
     536        return $hash->{'#%#parent'}; 
     537    } else { 
     538        return undef; 
     539    } 
    501540} 
    502541 
     
    747786} 
    748787 
     788# munin_get_html_filename: Get the full path-name of an html file 
     789# Parameters: 
     790# - $hash: A ref to the service hash node 
     791# Returns: 
     792# - Success: The file name with full path 
     793# - Failure: undef 
     794sub munin_get_html_filename { 
     795    my $hash    = shift; 
     796    my $loc     = munin_get_node_loc ($hash); 
     797    my $ret     = munin_get ($hash, 'htmldir'); 
     798 
     799    # Sanitise 
     800    $ret =~ s/[^\w_\/"'\[\]\(\)+=-]\./_/g; 
     801    $hash =~ s/[^\w_\/"'\[\]\(\)+=-]/_/g; 
     802    @$loc = map { s/\//_/g; $_ } @$loc; 
     803    @$loc = map { s/^\./_/g; $_ } @$loc; 
     804         
     805    my $plugin = pop @$loc or return undef; 
     806    my $node   = pop @$loc or return undef; 
     807 
     808    if (@$loc) { # The rest is used as directory names... 
     809        $ret .= "/" . join ('/', @$loc); 
     810    } 
     811 
     812    return "$ret/$node/$plugin.html"; 
     813} 
     814 
    749815# munin_get_picture_filename: Get the full path+name of a picture file 
    750816# Parameters: 
     
    777843 
    778844    if (defined $sum and $sum) { 
    779             return "$ret/$node-$plugin-$scale-sum.png"; 
     845            return "$ret/$node/$plugin-$scale-sum.png"; 
    780846    } else { 
    781             return "$ret/$node-$plugin-$scale.png"; 
     847            return "$ret/$node/$plugin-$scale.png"; 
    782848    } 
    783849} 
     
    10771143} 
    10781144 
    1079 sub munin_service_status 
    1080 
    1081     my ($config, $limits, $domain, $node, $service, $check_draw) = @_; 
     1145# munin_field_status: Gets current status of a field 
     1146# Parameters:  
     1147# - $hash: A ref to the field hash node 
     1148# - $limits: A ref to the root node of the limits tree 
     1149# - $check_draw: [optional] Ignore undrawn fields 
     1150# Returns: 
     1151# - Success: The status of the field 
     1152# - Failure: undef 
     1153sub munin_service_status { 
     1154    my ($config, $limits, $check_draw) = @_; 
    10821155    my $state = "ok"; 
    10831156 
    1084     return undef unless defined $config->{domain}->{$domain}->{node}->{$node}->{client}->{$service}; 
    1085     foreach my $key (keys %{$config->{domain}->{$domain}->{node}->{$node}->{client}->{$service}}) 
    1086     { 
    1087         next unless $key =~ /^([^\.]+)\.label$/; 
    1088         my $field = $1; 
    1089         my $fres  = &munin_field_status ($config, $limits, $domain, $node, $service, $field, $check_draw); 
    1090         if (defined $fres) 
    1091         { 
    1092             if ($fres eq "critical") 
    1093             { 
     1157    return undef unless defined $config; 
     1158    for my $fieldnode (@{munin_find_field ($config, "label")}) { 
     1159        my $field = munin_get_node_name ($fieldnode); 
     1160        my $fres  = munin_field_status ($fieldnode, $limits, $check_draw); 
     1161        if (defined $fres) { 
     1162            if ($fres eq "critical") { 
    10941163                $state = $fres; 
    10951164                last; 
    1096             } 
    1097             elsif ($fres eq "warning") 
    1098             { 
     1165            } elsif ($fres eq "warning") { 
    10991166                $state = $fres; 
    11001167            } 
     
    11051172} 
    11061173 
    1107 sub munin_field_status 
    1108 
    1109     my ($config, $limits, $domain, $node, $service, $field, $check_draw) = @_; 
     1174# munin_field_status: Gets current status of a field 
     1175# Parameters:  
     1176# - $hash: A ref to the field hash node 
     1177# - $limits: A ref to the root node of the limits tree 
     1178# - $check_draw: [optional] Ignore undrawn fields 
     1179# Returns: 
     1180# - Success: The status of the field 
     1181# - Failure: undef 
     1182sub munin_field_status { 
     1183    my ($config, $limits, $check_draw) = @_; 
    11101184    my $state = undef; 
    11111185 
    11121186    # Return undef if nagios is turned off, or the field doesn't have any limits 
    1113     unless ((defined $config->{domain}->{$domain}->{node}->{$node}->{client}->{$service}->{"$field.warning"}) or 
    1114         (defined $config->{domain}->{$domain}->{node}->{$node}->{client}->{$service}->{"$field.critical"})) 
    1115     { 
     1187    if ((!defined munin_get ($config, "warning", undef)) and (!defined munin_get ($config, "critical"))) { 
    11161188        return undef; 
    11171189    } 
    11181190 
    1119     if (defined $limits->{domain}->{$domain}->{node}->{$node}->{client}->{$service}->{"$field.critical"} and (!defined $check_draw or !$check_draw or  
    1120                 &munin_draw_field ($config->{domain}->{$domain}->{node}->{$node}, $service, $field))) 
    1121    
     1191    my $loc = munin_get_node_loc ($config); 
     1192 
     1193    if (defined munin_get_node ($limits, [$loc,"critical"]) and (!defined $check_draw or !$check_draw or munin_draw_field ($config)))
    11221194        return "critical"; 
    1123     } 
    1124     elsif (defined $limits->{domain}->{$domain}->{node}->{$node}->{client}->{$service}->{"$field.warning"} and (!defined $check_draw or !$check_draw or  
    1125                 &munin_draw_field ($config->{domain}->{$domain}->{node}->{$node}, $service, $field))) 
    1126     { 
     1195    } elsif (defined munin_get_node ($limits, [$loc,"warning"]) and (!defined $check_draw or !$check_draw or munin_draw_field ($config))) { 
    11271196        return "warning"; 
    1128     } 
    1129     else 
    1130     { 
     1197    } else { 
    11311198        return "ok"; 
    11321199    } 
  • people/jo/multilevel-groups-2/server/munin-html.in

    r1286 r1345  
    2828use Time::HiRes; 
    2929use Munin; 
     30use Data::Dumper; 
    3031use POSIX qw(strftime); 
    3132 
    3233my @times = ( "day", "week", "month", "year" ); 
    3334 
     35my @limit_hosts; 
    3436my $DEBUG=0; 
    35 my $VERSION="@@VERSION@@"; 
     37my $VERSION = "@@VERSION@@"; 
    3638my $conffile = "@@CONFDIR@@/munin.conf"; 
    3739my $force_root = 0; 
     
    164166} 
    165167 
     168# Make array of what services 
     169my $work_array = []; 
     170if (@limit_hosts) { # Limit what to update if needed 
     171        foreach my $nodename (@limit_hosts) { 
     172                    push @$work_array, map { @{munin_find_field ($_->{$nodename}, "graph_title")} } @{munin_find_field($config, $nodename)}; 
     173                        } 
     174} else { # ...else just search for all adresses to update 
     175        push @$work_array, @{munin_find_field($config, "graph_title")}; 
     176} 
     177 
     178# For timestamping graphs 
     179my $timestamp = strftime("%Y-%m-%d T %T", localtime); 
     180 
     181# Draw service pages 
     182for my $service (@$work_array) { 
     183 
     184    next unless munin_get_bool ($service, "graph", 1); 
     185 
     186    my %srv; 
     187    my $fieldnum = 0; 
     188    my @graph_info; 
     189    my @field_info; 
     190    my @loc = munin_get_node_loc ($service); 
     191    my $pathnodes = get_path_nodes ($service); 
     192    my $peers     = get_peer_nodes ($service, lc munin_get ($service, "graph_category", "other")); 
     193    (my $csspath  = $pathnodes->[0]->{'link'}) =~ s/index.html$/style.css/; 
     194 
     195    $srv{'node'}     = munin_get_node_name ($service); 
     196    logger("processing service: $srv{node}"); 
     197    $srv{'service'}  = $service; 
     198    $srv{'label'}    = munin_get ($service, "graph_title"); 
     199    $srv{'category'} = lc( munin_get ($service, "graph_category", "other") ); 
     200 
     201    my $method = munin_get ($service, "graph_strategy", "cron"); 
     202 
     203    $srv{'url'}      = "$srv{node}.html"; 
     204 
     205    my $path = join ('/', @loc); 
     206 
     207    if ($method eq "cgi") { 
     208        $srv{'imgday'}  =$config->{'cgiurl_graph'}."/$path-day.png"; 
     209        $srv{'imgweek'} =$config->{'cgiurl_graph'}."/$path-week.png"; 
     210        $srv{'imgmonth'}=$config->{'cgiurl_graph'}."/$path-month.png"; 
     211        $srv{'imgyear'} =$config->{'cgiurl_graph'}."/$path-year.png"; 
     212 
     213        if (munin_get_bool ($service, "graph_sums", 0)) { 
     214            $srv{'imgweeksum'} = $config->{'cgiurl_graph'}."/$path-week-sum.png"; 
     215            $srv{'imgyearsum'} = $config->{'cgiurl_graph'}."/$path-year-sum.png"; 
     216        } 
     217    } else { 
     218        # graph strategy cron 
     219          
     220        $srv{'imgday'}  ="$srv{node}-day.png"; 
     221        $srv{'imgweek'} ="$srv{node}-week.png"; 
     222        $srv{'imgmonth'}="$srv{node}-month.png"; 
     223        $srv{'imgyear'} ="$srv{node}-year.png"; 
     224 
     225        for my $scale (@times) { 
     226            if (my ($w, $h) = get_png_size(munin_get_picture_filename($service, $scale))) { 
     227                $srv{"img".$scale."width"} = $w; 
     228                $srv{"img".$scale."height"} = $h; 
     229            } 
     230        } 
     231 
     232        if (munin_get_bool ($service, "graph_sums", 0)) { 
     233            $srv{imgweeksum} = "$srv{node}-week-sum.png"; 
     234            $srv{imgyearsum} = "$srv{node}-year-sum.png"; 
     235            for my $scale (["week", "year"]) { 
     236                if (my ($w, $h) = get_png_size (munin_get_picture_filename($service, $scale, 1))) { 
     237                    $srv{"img".$scale."sumwidth"} = $w; 
     238                    $srv{"img".$scale."sumheight"} = $h; 
     239                } 
     240            } 
     241        } 
     242    } 
     243 
     244    # Do "help" section 
     245    if (my $info = munin_get ($service, "graph_info")) { 
     246        my %graph_info; 
     247        $graph_info{info} = $info; 
     248        push @{$srv{graphinfo}}, \%graph_info; 
     249    } 
     250 
     251    $srv{fieldlist} .= "<tr><th align='left' valign='top'>Field</th><th align='left' valign='top'>Type</th><th align='left' valign='top'>Warn</th><th align='left' valign='top'>Crit</th><th></tr>"; 
     252    foreach my $f (@{munin_get_field_order ($service)}) { 
     253        $f =~ s/=(.*)$//; 
     254        my $path = $1; 
     255        next if (!defined $service->{$f}); 
     256        my $fieldobj = $service->{$f}; 
     257        next if (ref ($fieldobj) != "HASH" or !defined $fieldobj->{'label'}); 
     258        next if (!munin_draw_field ($fieldobj)); 
     259 
     260        logger ("DEBUG: single_value: Checking field \"$f\" ($path).") 
     261            if $DEBUG; 
     262 
     263        if (defined $path) { 
     264            # This call is to make sure field settings are copied 
     265            # for aliases, .stack, et al. Todo: put that part of 
     266            # munin_get_rrd_filename into its own functino. 
     267            munin_get_rrd_filename ($f, $path); 
     268        } 
     269 
     270        my %field_info; 
     271        $fieldnum++; 
     272 
     273        $field_info{'hr'}    = 1 unless ($fieldnum % 3); 
     274        $field_info{'field'} = $f; 
     275        $field_info{'label'} = munin_get ($fieldobj, "label", $f); 
     276        $field_info{'type'}  = lc( munin_get ($fieldobj, "type", "GAUGE") ); 
     277        $field_info{'warn'}  = munin_get ($fieldobj, "warning"); 
     278        $field_info{'crit'}  = munin_get ($fieldobj, "critical"); 
     279        $field_info{'info'}  = munin_get ($fieldobj, "info"); 
     280 
     281        my $state = munin_field_status ($config, $limits, 1); 
     282 
     283        if (defined $state) { 
     284            $field_info{'state_warning'}  = 1 if $state eq "warning"; 
     285            $field_info{'state_critical'} = 1 if $state eq "critical"; 
     286            $field_info{'state_unknown'}  = 1 if $state eq "unknown"; 
     287        } 
     288        push @{$srv{'fieldinfo'}}, \%field_info; 
     289    } 
     290 
     291    my $state = munin_service_status ($service, $limits, 1); 
     292    if (defined $state) { 
     293        $srv{'state_warning'}  = 1 if $state eq "warning"; 
     294        $srv{'state_critical'} = 1 if $state eq "critical"; 
     295        $srv{'state_unknown'}  = 1 if $state eq "unknown"; 
     296    } 
     297 
     298    $servicetemplate->param(SERVICES  => [\%srv], 
     299                            PATH      => $pathnodes, 
     300                            PEERS     => $peers, 
     301                            CSS       => $csspath, 
     302                            CATEGORY  => ucfirst $srv{'category'}, 
     303                            TIMESTAMP => $timestamp); 
     304    my $filename = munin_get_html_filename ($service); 
     305    open (FILE, ">$filename") or 
     306        die "Cannot open $filename for writing: $!"; 
     307    print FILE $servicetemplate->output; 
     308    close FILE; 
     309} 
     310 
     311exit 0; 
    166312#make domain list 
    167313my @domainlist = map { { DOMAIN => $_ } } @domainorder; 
     
    200346    } 
    201347 
    202     for my $service (@serviceorder) { 
    203       logger("processing service: $service"); 
    204       next unless 
    205         defined($config->{domain}->{$domain}->{node}->{$node}->{client}->{$service} ) 
    206         &&  $config->{domain}->{$domain}->{node}->{$node}->{client}->{$service} ne ""; 
    207  
    208       next unless 
    209         munin_get_bool ($config, "graph", 1, $domain, $node, $service); 
    210  
    211       my @service; 
    212       my %service; 
    213       my $fieldnum = 0; 
    214       my @graph_info; 
    215       my @field_info; 
    216       $service{service}=$service; 
    217       $service{label}= 
    218         $config->{domain}->{$domain}->{node}->{$node}->{client}-> 
    219           {$service}->{graph_title}; 
    220  
    221       my $method = &munin_get ($config, "graph_strategy", "cron"); 
    222       if ($method eq "cgi") { 
    223         $service{imgday}=$config->{'cgiurl_graph'}. 
    224           "/$domain/$node/$service-day.png"; 
    225         $service{imgweek}=$config->{'cgiurl_graph'}. 
    226           "/$domain/$node/$service-week.png"; 
    227         $service{imgmonth}=$config->{'cgiurl_graph'}. 
    228           "/$domain/$node/$service-month.png"; 
    229         $service{imgyear}=$config->{'cgiurl_graph'}. 
    230           "/$domain/$node/$service-year.png"; 
    231  
    232         if (&munin_get_bool_val($config->{domain}->{$domain}-> 
    233                                 {node}->{$node}-> 
    234                                 {client}->{$service}->{"graph_sums"}, 0)) { 
    235           $service{imgweeksum} = 
    236             $config->{'cgiurl_graph'}."/$domain/$node/$service-week-sum.png"; 
    237           $service{imgyearsum} = 
    238             $config->{'cgiurl_graph'}."/$domain/$node/$service-year-sum.png"; 
    239         } 
    240  
    241 # There is a disturbance in the force here, the sizes are off. 
    242 #       if (my ($w, $h) = 
    243 #           &calculate_png_size ($config, $domain, $node, $service)) { 
    244 #         for my $scale (@times) { 
    245 #           $service{"img".$scale."width"} = $w; 
    246 #           $service{"img".$scale."height"} = $h; 
    247 #         } 
    248 #         if (&munin_get_bool_val($config->{domain}->{$domain}-> 
    249 #                                 {node}->{$node}-> 
    250 #                                 {client}->{$service}->{"graph_sums"}, 0)) { 
    251 #           for my $scale (["week", "year"]) { 
    252 #             $service{"img".$scale."sumwidth"} = $w; 
    253 #             $service{"img".$scale."sumheight"} = $h; 
    254 #           } 
    255 #         } 
    256 #       } 
    257       } else { 
    258         # graph strategy cron 
    259         $service{imgday}="$node-$service-day.png"; 
    260         $service{imgweek}="$node-$service-week.png"; 
    261         $service{imgmonth}="$node-$service-month.png"; 
    262         $service{imgyear}="$node-$service-year.png"; 
    263  
    264         for my $scale (@times) { 
    265           if (my ($w, $h) = 
    266               &get_png_size(&munin_get_picture_filename($config, $domain, 
    267                                                         $node, $service, 
    268                                                         $scale))) { 
    269             $service{"img".$scale."width"} = $w; 
    270             $service{"img".$scale."height"} = $h; 
    271           } 
    272         } 
    273  
    274         if (&munin_get_bool_val ($config->{domain}->{$domain}-> 
    275                                  {node}->{$node}->{client}-> 
    276                                  {$service}->{"graph_sums"}, 0)) { 
    277           $service{imgweeksum} = "$node-$service-week-sum.png"; 
    278           $service{imgyearsum} = "$node-$service-year-sum.png"; 
    279           for my $scale (["week", "year"]) { 
    280             if (my ($w, $h) = 
    281                 &get_png_size (&munin_get_picture_filename($config,$domain, 
    282                                                            $node, $service, 
    283                                                            $scale, 1))) { 
    284               $service{"img".$scale."sumwidth"} = $w; 
    285               $service{"img".$scale."sumheight"} = $h; 
    286             } 
    287           } 
    288         } 
    289       } 
    290       $service{url}="$node-$service.html"; 
    291       $service{domain}="$domain"; 
    292       $service{node}=$node; 
    293       $service{category}= lc( $config->{domain}->{$domain}-> 
    294                               {node}->{$node}->{client}-> 
    295                               {$service}->{graph_category} || "other" ); 
    296  
    297       # Do "help" section 
    298       if (defined($config->{domain}->{$domain}-> 
    299                   {node}->{$node}-> 
    300                   {client}->{$service}->{graph_info})) { 
    301         my %graph_info; 
    302  
    303         $graph_info{info} = $config->{domain}->{$domain}-> 
    304           {node}->{$node}->{client}->{$service}->{graph_info}; 
    305  
    306         push @{$service{graphinfo}}, \%graph_info; 
    307       } 
    308  
    309       $service{fieldlist} .= "<tr><th align='left' valign='top'>Field</th><th align='left' valign='top'>Type</th><th align='left' valign='top'>Warn</th><th align='left' valign='top'>Crit</th><th></tr>"; 
    310       # foreach my $field (keys %{$config->{domain}->{$domain}->{node}->{$node}->{client}->{$service}}) 
    311       foreach my $f (@{&munin_get_field_order ($config->{domain}->{$domain}->{node}->{$node}, $config, $domain, $node, $service)}) { 
    312         $f =~ s/=(.*)$//; 
    313         my $path = $1; 
    314         next unless &munin_draw_field ($config->{domain}->{$domain}-> 
    315                                        {node}->{$node}, $service, $f); 
    316  
    317         print "DEBUG: single_value: Checking field \"$f\" ($path).\n" 
    318           if $DEBUG; 
    319  
    320         if (defined $path) { 
    321           # HUH? Get the filename and then forget? Some side effect here? 
    322           munin_get_rrd_filename ($config->{domain}->{$domain}-> 
    323                                   {node}->{$node}, $config, $domain, 
    324                                   $node, $service, $f, $path); 
    325         } 
    326  
    327         my %field_info; 
    328         $fieldnum++; 
    329  
    330         $field_info{'hr'}    = 1 unless ($fieldnum % 3); 
    331         $field_info{'field'} = $f; 
    332         $field_info{'label'} = $config->{domain}->{$domain}-> 
    333           {node}->{$node}->{client}->{$service}->{$f.".label"} || $f; 
    334  
    335         $field_info{'type'}  = lc( $config->{domain}->{$domain}-> 
    336                                    {node}->{$node}->{client}->{$service}-> 
    337                                    {$f.".type"} || "GAUGE" ); 
    338  
    339         $field_info{'warn'}  = $config->{domain}->{$domain}-> 
    340           {node}->{$node}->{client}->{$service}->{$f.".warning"} || "None"; 
    341         $field_info{'crit'}  = $config->{domain}->{$domain}-> 
    342           {node}->{$node}->{client}->{$service}->{$f.".critical"} || "None"; 
    343         $field_info{'info'}  = $config->{domain}->{$domain}-> 
    344           {node}->{$node}->{client}->{$service}->{$f.".info"} || ""; 
    345  
    346         my $state = &munin_field_status ($config, $limits, $domain, 
    347                                          $node, $service, $f, 1); 
    348  
    349         if (defined $state) { 
    350           $field_info{'state_warning'}  = 1 if $state eq "warning"; 
    351           $field_info{'state_critical'} = 1 if $state eq "critical"; 
    352           $field_info{'state_unknown'}  = 1 if $state eq "unknown"; 
    353         } 
    354         push @{$service{fieldinfo}}, \%field_info; 
    355       } 
    356  
    357       { 
    358         my $state = &munin_service_status ($config, $limits, $domain, 
    359                                            $node, $service, 1); 
    360         if (defined $state) { 
    361           $service{'state_warning'}  = 1 if $state eq "warning"; 
    362           $service{'state_critical'} = 1 if $state eq "critical"; 
    363           $service{'state_unknown'}  = 1 if $state eq "unknown"; 
    364         } 
    365       } 
    366  
    367       push @services, \%service; 
    368       push @service, \%service; 
    369       push @{$tmp_cats{$service{'category'}}}, \%service; 
    370       $servicetemplate->param(SERVICES => \@service, 
    371                               SERVICE => $service, 
    372                               NODE => $node, 
    373                               DOMAIN => $domain,  
    374                               DOMAINS => \@domainlist,  
    375                               TIMESTAMP => $timestamp); 
    376       open (FILE, ">$config->{htmldir}/$domain/$node-$service.html") or 
    377         die "Cannot open $config->{htmldir}/$domain/$node-$service.html: $!"; 
    378       print FILE $servicetemplate->output; 
    379       close FILE; 
    380     } 
    381348    foreach my $key (keys %tmp_cats) { 
    382349      next if $key eq "other"; 
     
    637604} 
    638605 
     606sub get_peer_nodes { 
     607    my $hash     = shift || return undef; 
     608    my $category = shift; 
     609    my $ret      = []; 
     610    my $link     = "index.html"; 
     611    my $parent   = munin_get_parent ($hash) || return undef; 
     612    my $me       = munin_get_node_name ($hash); 
     613 
     614    foreach my $peer (sort keys %$parent) { 
     615        next unless defined $peer and defined $parent->{$peer} and ref ($parent->{$peer}) eq "HASH"; 
     616        next if $peer =~ /^#%#/; 
     617        next if defined $category and lc (munin_get ($parent->{$peer}, "graph_category", "other")) ne $category; 
     618        if ($peer eq $me) { 
     619            unshift @$ret, { "name" => munin_get_node_name ($parent->{$peer}), "link" => undef }; 
     620        } else { 
     621            unshift @$ret, { "name" => munin_get_node_name ($parent->{$peer}), "link" => "$peer.html" }; 
     622        } 
     623    } 
     624    return $ret; 
     625} 
     626 
     627sub get_path_nodes { 
     628    my $hash = shift || return undef; 
     629    my $ret  = []; 
     630    my $link = "index.html"; 
     631 
     632    unshift @$ret, { "name" => munin_get_node_name ($hash), "link" => undef }; 
     633    while ($hash = munin_get_parent ($hash)) { 
     634        unshift @$ret, { "name" => munin_get_node_name ($hash), "link" => $link }; 
     635        $link = "../" . $link; 
     636    } 
     637    $ret->[0]->{'name'} = undef; 
     638    return $ret; 
     639} 
     640 
    639641$update_time = sprintf("%.2f",(Time::HiRes::time - $update_time)); 
    640642 
  • people/jo/multilevel-groups-2/server/munin-serviceview.tmpl.in

    r860 r1345  
    44<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 
    55<head> 
    6   <link rel="stylesheet" href="../style.css" type="text/css" />  
     6  <link rel="stylesheet" href="<TMPL_VAR NAME="CSS">" type="text/css" />  
    77  <meta http-equiv="refresh" content="300" /> 
    8   <title>Munin :: <TMPL_VAR NAME="DOMAIN"> :: <TMPL_VAR NAME="NODE"> :: <TMPL_VAR ESCAPE="HTML" NAME="SERVICE"></title> 
     8  <title><TMPL_LOOP NAME="PATH"><TMPL_IF NAME="name"> :: <TMPL_VAR ESCAPE="HTML" NAME="name"></a><TMPL_ELSE>Munin</TMPL_IF></TMPL_LOOP></title> 
    99  <meta http-equiv="content-type" content="application/xhtml+xml; charset=iso-8859-1" /> 
    1010  <meta name="author" content="Auto-generated by Munin" /> 
     
    1515     <td><div class="logo">&nbsp;</div></td> 
    1616     <td valign="top"> 
    17          <h2><a href="../index.html">Overview</a> :: <a href="index.html"> 
    18 <TMPL_VAR NAME="DOMAIN"></a> ::  
    19 <a href="<TMPL_VAR NAME="NODE">.html"><TMPL_VAR NAME="NODE"></a> :: <TMPL_VAR ESCAPE="HTML" NAME="SERVICE"></h2> 
     17         <h2> 
     18         <TMPL_LOOP NAME="PATH"> 
     19           <TMPL_IF NAME="name"> :: 
     20             <TMPL_IF NAME="link"><A HREF="<TMPL_VAR NAME="link">"></TMPL_IF> 
     21               <TMPL_VAR NAME="name"> 
     22             <TMPL_IF NAME="link"></A></TMPL_IF> 
     23           <TMPL_ELSE> 
     24             <TMPL_IF NAME="link"><A HREF="<TMPL_VAR NAME="link">"></TMPL_IF> 
     25               Overview 
     26             <TMPL_IF NAME="link"></A></TMPL_IF> 
     27           </TMPL_IF> 
     28         </TMPL_LOOP></h2> 
    2029     </td>     
    2130    </tr> 
     
    8291  <tr> 
    8392    <td colspan="2" class="linkbox"> 
    84       <TMPL_LOOP NAME="DOMAINS"> 
    85         <a href="../<TMPL_VAR NAME="DOMAIN">/index.html"><TMPL_VAR NAME="DOMAIN"></a> : 
    86       </TMPL_LOOP> 
     93      <TMPL_VAR NAME="CATEGORY"> :<TMPL_LOOP NAME="PEERS">: <TMPL_IF NAME="LINK"><a href="<TMPL_VAR NAME="LINK">"></TMPL_IF><TMPL_VAR NAME="NAME"><TMPL_IF NAME="LINK"></a></TMPL_IF> </TMPL_LOOP> 
    8794    </td> 
    8895  </tr>