I am facing the error "Undefined subroutine &main::header called at /opt/alu-rp/www/cgi/munin-cgi-html line 54." while opening the munin page(http://localhost/munin)
Perl version: v5.32.0 Munin version: v2.0.65
With the error, able to see the header is not initiated due to the new condition added in munin-cgi-html
# grab config
html_startup(\@params);
while(new CGI::Fast){
print header("text/html");
$config = get_config(1);
show_page();
}
:
:
# CGI in perl 5.20 is now seriously broken as it doesn't import into the namespace.
# So we have to delegate explicitly. It's easier than prefixing with CGI:: each use.
# This workaround is applied only if "header" is undefined (i.e. for perl >= 5.20).
if(!defined &header){
*header = sub { return CGI::header(@_); };
*path_info = sub { return CGI::path_info(@_); };
*url = sub { return CGI::url(@_); };
*script_name = sub { return CGI::script_name(@_); };
}
Adding a line in munin-cgi-html able to solve the issue.
sub header { return CGI::header(@_); }
But not sure what will be the impact of adding this line. Is there anything specific configuration or package needs to install for Munin to work?
The block on the bottom is importing symbols from CGI. Unfortunately, you are trying to use
headerbefore executing this block to import it. You need to execute the imports before all uses ofheaderand such.Note that
is better written as
as it avoids a needless extra sub call.
Note that you can ask CGI.pm to export those symbols for you. Instead of manually importing the symbols, you can simply use either of following:
No need to clunckily import the symbols yourself.