/usr/lib/munin/cgi/munin-cgi-html is in munin 2.0.37-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | #!/usr/bin/perl -T
# -*- cperl -*-
=begin comment
Copyright (C) 2004-2010 Jimmy Olsen, Steve Schnepp
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; version 2 dated June,
1991.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
=end comment
=cut
use strict;
use warnings;
use POSIX qw(strftime);
use CGI::Fast qw(:cgi);
use CGI::Carp qw(fatalsToBrowser);
use Time::HiRes qw(time);
use Munin::Master::HTMLConfig;
use Munin::Master::HTMLOld;
use Munin::Master::Utils;
use Munin::Master::Logger;
use Log::Log4perl qw( :easy );
use Data::Dumper;
my @times = ("day", "week", "month", "year");
my $config;
my $lastchanged = 0;
my @params;
push @params, "--config", $ENV{'MUNIN_CONFIG'}
if (defined $ENV{'MUNIN_CONFIG'});
# grab config
html_startup(\@params);
while(new CGI::Fast){
print header("text/html");
$config = get_config(1);
show_page();
}
sub show_page {
my @path = split(/\//, $ENV{PATH_INFO});
emit_page(\@path);
}
sub get_next_part {
my $path = shift;
my $part;
do {
$part = shift(@$path);
} while(defined $part && $part eq "");
return $part;
}
sub emit_page {
my $path = shift;
my $group = $config;
#process groups
$group = traverse_groups($path, $group);
update_timestamp();
if(!defined $group->{"depth"} || $group->{"depth"} == 0){ #root url
my $problems = get_next_part($path);
if(defined $problems && $problems eq "problems.html"){
emit_problem_template(1);
} else {
unshift(@$path, $problems);
(my $category, my $time) = get_global_category($path, $group);
if(defined $category){
emit_category_template($category, $time, 1);
} else {
emit_main_index($group->{"groups"},0,1);
}
}
} elsif(!$group->{"ncategories"}) { # group
my $cmp_time = get_comparison_group($path, $group);
if(defined $cmp_time){ # comparison template
emit_comparison_template($group, $cmp_time, 1);
} else { #group page
emit_group_template($group, 1);
}
} else { #node
my $service = get_node_service($path, $group);
if(defined $service){
emit_service_template($service, 1);
} else {
emit_graph_template($group, 1);
}
}
}
sub traverse_groups {
my ($path, $group) = @_;
my $part = get_next_part($path);
while(defined $part && (defined $group->{"groups_hash"}->{$part})) {
$group = $group->{"groups_hash"}->{$part};
$part = get_next_part($path);
}
if(defined $part){
unshift(@$path,$part); # put the unprocessed part back on
}
return $group;
}
sub get_comparison_group {
my ($path, $group) = @_;
if(!$group->{"compare"}){ return undef; } # group is not a comparison group
my $part = get_next_part($path);
if(defined $part && $part =~ m/^comparison-([a-z]+)\.html/i){
if(grep /^$1$/, @times){ return lc $1; }
}
if(defined $part){
unshift(@$path, $part); #put the unprocessed part back on
}
return undef;
}
sub get_global_category {
my ($path, $group) = @_;
my $part = get_next_part($path);
if(!defined $part){
return undef;
}
foreach my $category (@{$group->{"globalcats"}}) {
foreach my $time (@times) {
if($category->{"url" . $time} eq $part){
return ($category, $time);
}
}
}
return undef;
}
sub get_node_service {
my ($path, $group) = @_;
my $part = get_next_part($path);
if(!defined $part){
return undef;
}
foreach my $category (@{$group->{"categories"}}) {
foreach my $service (@{$category->{"services"}}) {
if($part eq $service->{"node"}.".html"){
return $service;
}
}
}
return undef;
}
# CGI in perl 5.20 is now seriously broken as it doesn't import into the namespace.
# So we have to delegate explicitely. It's easier than prefixing with CGI:: each use.
sub header { return CGI::header(@_); }
sub path_info { return CGI::path_info(@_); }
sub url { return CGI::url(@_); }
sub script_name { return CGI::script_name(@_); }
|