mirror of https://github.com/mikaku/Monitorix.git
included also the log_file option of the HTTP built-in in this new support #268
This commit is contained in:
parent
48ac929191
commit
30c2e2bfb9
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# Monitorix - A lightweight system monitoring tool.
|
# Monitorix - A lightweight system monitoring tool.
|
||||||
#
|
#
|
||||||
# Copyright (C) 2005-2016 by Jordi Sanfeliu <jordi@fibranet.cat>
|
# Copyright (C) 2005-2020 by Jordi Sanfeliu <jordi@fibranet.cat>
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -32,6 +32,7 @@ use Socket;
|
||||||
sub logger {
|
sub logger {
|
||||||
my ($url, $type) = @_;
|
my ($url, $type) = @_;
|
||||||
|
|
||||||
|
if($main::config{httpd_builtin}->{log_file}) {
|
||||||
if(open(OUT, ">> $main::config{httpd_builtin}->{log_file}")) {
|
if(open(OUT, ">> $main::config{httpd_builtin}->{log_file}")) {
|
||||||
if($type eq "OK") {
|
if($type eq "OK") {
|
||||||
print OUT localtime() . " - $type - [$ENV{REMOTE_ADDR}] \"$ENV{REQUEST_METHOD} $url - " . ($ENV{HTTP_USER_AGENT} || "") . "\"\n";
|
print OUT localtime() . " - $type - [$ENV{REMOTE_ADDR}] \"$ENV{REQUEST_METHOD} $url - " . ($ENV{HTTP_USER_AGENT} || "") . "\"\n";
|
||||||
|
@ -48,6 +49,21 @@ sub logger {
|
||||||
} else {
|
} else {
|
||||||
print STDERR localtime() . " - ERROR: unable to open logfile '$main::config{httpd_builtin}->{log_file}'.\n";
|
print STDERR localtime() . " - ERROR: unable to open logfile '$main::config{httpd_builtin}->{log_file}'.\n";
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
my $msg;
|
||||||
|
if($type eq "OK") {
|
||||||
|
$msg = localtime() . " - $type - [$ENV{REMOTE_ADDR}] \"$ENV{REQUEST_METHOD} $url - " . ($ENV{HTTP_USER_AGENT} || "") . "\"\n";
|
||||||
|
} elsif($type eq "NOTEXIST") {
|
||||||
|
$msg = localtime() . " - $type - [$ENV{REMOTE_ADDR}] File does not exist: $url\n";
|
||||||
|
} elsif($type eq "AUTHERR") {
|
||||||
|
$msg = localtime() . " - $type - [$ENV{REMOTE_ADDR}] Authentication error: $url\n";
|
||||||
|
} elsif($type eq "NOTALLOWED") {
|
||||||
|
$msg = localtime() . " - $type - [$ENV{REMOTE_ADDR}] Access not allowed: $url\n";
|
||||||
|
} else {
|
||||||
|
$msg = localtime() . " - $type - [$ENV{REMOTE_ADDR}] $url\n";
|
||||||
|
}
|
||||||
|
print("$msg");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub check_passwd {
|
sub check_passwd {
|
||||||
|
|
|
@ -130,10 +130,12 @@ sub httpd_setup {
|
||||||
}
|
}
|
||||||
|
|
||||||
# create the HTTPd logfile
|
# create the HTTPd logfile
|
||||||
|
if($config->{log_file}) {
|
||||||
open(OUT, ">> " . $config->{httpd_builtin}->{log_file});
|
open(OUT, ">> " . $config->{httpd_builtin}->{log_file});
|
||||||
close(OUT);
|
close(OUT);
|
||||||
chown($uid, $gid, $config->{httpd_builtin}->{log_file});
|
chown($uid, $gid, $config->{httpd_builtin}->{log_file});
|
||||||
chmod(0600, $config->{httpd_builtin}->{log_file});
|
chmod(0600, $config->{httpd_builtin}->{log_file});
|
||||||
|
}
|
||||||
|
|
||||||
setgid($gid);
|
setgid($gid);
|
||||||
if(getgid() != $gid) {
|
if(getgid() != $gid) {
|
||||||
|
|
Loading…
Reference in New Issue