mirror of https://github.com/mikaku/Monitorix.git
last update for 3.0.0beta1
This commit is contained in:
parent
6197f62cd0
commit
d4693a320d
|
@ -47,7 +47,9 @@ install -m 0644 docs/monitorix.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/mo
|
||||||
mkdir -p %{buildroot}%{_sysconfdir}
|
mkdir -p %{buildroot}%{_sysconfdir}
|
||||||
install -m 0644 monitorix.conf %{buildroot}%{_sysconfdir}/monitorix.conf
|
install -m 0644 monitorix.conf %{buildroot}%{_sysconfdir}/monitorix.conf
|
||||||
mkdir -p %{buildroot}%{_bindir}
|
mkdir -p %{buildroot}%{_bindir}
|
||||||
install -m 0755 monitorix %{buildroot}%{_bindir}
|
install -m 0755 monitorix %{buildroot}%{_bindir}/monitorix
|
||||||
|
mkdir -p %{buildroot}%{_libdir}/monitorix
|
||||||
|
install -m 0644 lib/*.pm %{buildroot}%{_libdir}/monitorix
|
||||||
mkdir -p %{buildroot}%{_datadir}/monitorix
|
mkdir -p %{buildroot}%{_datadir}/monitorix
|
||||||
install -m 0644 logo_top.png %{buildroot}%{_datadir}/monitorix
|
install -m 0644 logo_top.png %{buildroot}%{_datadir}/monitorix
|
||||||
install -m 0644 logo_bot.png %{buildroot}%{_datadir}/monitorix
|
install -m 0644 logo_bot.png %{buildroot}%{_datadir}/monitorix
|
||||||
|
@ -57,7 +59,6 @@ mkdir -p %{buildroot}%{_datadir}/monitorix/cgi-bin
|
||||||
install -m 0755 monitorix.cgi %{buildroot}%{_datadir}/monitorix/cgi-bin
|
install -m 0755 monitorix.cgi %{buildroot}%{_datadir}/monitorix/cgi-bin
|
||||||
mkdir -p %{buildroot}%{_localstatedir}/lib/monitorix/reports
|
mkdir -p %{buildroot}%{_localstatedir}/lib/monitorix/reports
|
||||||
install -m 0644 reports/*.html %{buildroot}%{_localstatedir}/lib/monitorix/reports
|
install -m 0644 reports/*.html %{buildroot}%{_localstatedir}/lib/monitorix/reports
|
||||||
install -m 0755 reports/send_reports %{buildroot}%{_localstatedir}/lib/monitorix/reports
|
|
||||||
mkdir -p %{buildroot}%{_localstatedir}/lib/monitorix/usage
|
mkdir -p %{buildroot}%{_localstatedir}/lib/monitorix/usage
|
||||||
mkdir -p %{buildroot}%{_mandir}/man5
|
mkdir -p %{buildroot}%{_mandir}/man5
|
||||||
mkdir -p %{buildroot}%{_mandir}/man8
|
mkdir -p %{buildroot}%{_mandir}/man8
|
||||||
|
@ -78,6 +79,7 @@ rm -rf %{buildroot}
|
||||||
%config(noreplace) %{_sysconfdir}/sysconfig/monitorix
|
%config(noreplace) %{_sysconfdir}/sysconfig/monitorix
|
||||||
%config(noreplace) %{_sysconfdir}/monitorix.conf
|
%config(noreplace) %{_sysconfdir}/monitorix.conf
|
||||||
%{_bindir}/monitorix
|
%{_bindir}/monitorix
|
||||||
|
%{_libdir}/monitorix/*.pm
|
||||||
%{_datadir}/monitorix/logo_top.png
|
%{_datadir}/monitorix/logo_top.png
|
||||||
%{_datadir}/monitorix/logo_bot.png
|
%{_datadir}/monitorix/logo_bot.png
|
||||||
%{_datadir}/monitorix/monitorixico.png
|
%{_datadir}/monitorix/monitorixico.png
|
||||||
|
@ -85,7 +87,6 @@ rm -rf %{buildroot}
|
||||||
%attr(777,apache,apache) %{_datadir}/monitorix/imgs
|
%attr(777,apache,apache) %{_datadir}/monitorix/imgs
|
||||||
%attr(755,root,root) %{_localstatedir}/lib/monitorix/usage
|
%attr(755,root,root) %{_localstatedir}/lib/monitorix/usage
|
||||||
%config(noreplace) %{_localstatedir}/lib/monitorix/reports/*.html
|
%config(noreplace) %{_localstatedir}/lib/monitorix/reports/*.html
|
||||||
%{_localstatedir}/lib/monitorix/reports/send_reports
|
|
||||||
%doc %{_mandir}/man5/monitorix.conf.5.gz
|
%doc %{_mandir}/man5/monitorix.conf.5.gz
|
||||||
%doc %{_mandir}/man8/monitorix.8.gz
|
%doc %{_mandir}/man8/monitorix.8.gz
|
||||||
%doc Changes COPYING README README.nginx README.FreeBSD README.OpenBSD README.NetBSD docs/monitorix-alert.sh docs/monitorix-lighttpd.conf
|
%doc Changes COPYING README README.nginx README.FreeBSD README.OpenBSD README.NetBSD docs/monitorix-alert.sh docs/monitorix-lighttpd.conf
|
||||||
|
|
63
monitorix
63
monitorix
|
@ -24,10 +24,11 @@ require 5.006;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use FindBin qw($Bin);
|
use FindBin qw($Bin);
|
||||||
use lib $Bin . '/lib';
|
use lib "$Bin/lib";
|
||||||
|
use lib "/usr/lib/monitorix";
|
||||||
|
|
||||||
use Monitorix;
|
use Monitorix;
|
||||||
use POSIX qw(WNOHANG LC_TIME setlocale uname pause);
|
use POSIX qw(WNOHANG LC_TIME setlocale uname pause setsid);
|
||||||
use Config::General;
|
use Config::General;
|
||||||
use Getopt::Std;
|
use Getopt::Std;
|
||||||
use Cwd 'abs_path';
|
use Cwd 'abs_path';
|
||||||
|
@ -75,12 +76,8 @@ sub HUP_handler {
|
||||||
# upon receiving a SIGHUP signal the logfile is re-opened
|
# upon receiving a SIGHUP signal the logfile is re-opened
|
||||||
close(STDOUT);
|
close(STDOUT);
|
||||||
close(STDERR);
|
close(STDERR);
|
||||||
unless(open(STDOUT, ">> $config{log_file}")) {
|
open(STDOUT, ">> $config{log_file}") || logger("Can't write to LOG: $!");
|
||||||
logger("Can't write to LOG: $!");
|
open(STDERR, ">> $config{log_file}") || logger("Can't write to LOG: $!");
|
||||||
}
|
|
||||||
unless(open(STDERR, ">> $config{log_file}")) { # >>&STDOUT XXX
|
|
||||||
logger("Can't write to LOG: $!");
|
|
||||||
}
|
|
||||||
logger("$myself: reopening log file.");
|
logger("$myself: reopening log file.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,29 +132,13 @@ sub ALRM_handler {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub daemonize {
|
sub daemonize {
|
||||||
if(fork) {
|
chdir("/") || die "Can't chdir to /: $!";
|
||||||
exit(0); # parent exits
|
open(STDIN, "< /dev/null") || die "Can't read /dev/null: $!";
|
||||||
}
|
open(STDOUT, ">> $config{log_file}") || die "Can't write to LOG: $!";
|
||||||
|
umask(022) || die "Unable to umask 022: $!";
|
||||||
setsid();
|
exit if fork(); # parent exits
|
||||||
foreach(0 .. (sysconf(&POSIX::_SC_OPEN_MAX) || 1024)) {
|
(setsid() != -1) || die "Can't start a new session: $!";
|
||||||
close($_);
|
open(STDERR, ">> $config{log_file}") || die "Can't write to LOG: $!";
|
||||||
}
|
|
||||||
unless(chdir("/")) {
|
|
||||||
die("Can't chdir to /: $!");
|
|
||||||
}
|
|
||||||
unless(umask(022)) {
|
|
||||||
die("Unable to umask 022: $!");
|
|
||||||
}
|
|
||||||
# unless(open(STDIN, "< /dev/null")) {
|
|
||||||
# die("Can't read /dev/null: $!");
|
|
||||||
# }
|
|
||||||
unless(open(STDOUT, ">> $config{log_file}")) {
|
|
||||||
die("Can't write to LOG: $!");
|
|
||||||
}
|
|
||||||
unless(open(STDERR, ">> $config{log_file}")) { # >>&STDOUT XXX
|
|
||||||
die("Can't write to LOG: $!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub usage {
|
sub usage {
|
||||||
|
@ -194,7 +175,7 @@ sub create_index {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!open(OUT, "> $config{base_dir}/index.html")) {
|
if(!open(OUT, "> $config{base_dir}/index.html")) {
|
||||||
die "unable to create '${config{base_dir}}index.html'. $!";
|
die "unable to create '${config{base_dir}}index.html': $!";
|
||||||
}
|
}
|
||||||
print(OUT <<EOF);
|
print(OUT <<EOF);
|
||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||||
|
@ -387,7 +368,7 @@ if(!$options{c}) {
|
||||||
}
|
}
|
||||||
$options{c} = abs_path($options{c}) unless $^V lt 5.6.2;
|
$options{c} = abs_path($options{c}) unless $^V lt 5.6.2;
|
||||||
if(!stat($options{c})) {
|
if(!stat($options{c})) {
|
||||||
die("can't open file '$options{c}'.\n");
|
die "can't open file '$options{c}': $!";
|
||||||
}
|
}
|
||||||
|
|
||||||
# load configuration file
|
# load configuration file
|
||||||
|
@ -404,7 +385,7 @@ my $release;
|
||||||
my ($major, $minor) = split('\.', $release);
|
my ($major, $minor) = split('\.', $release);
|
||||||
$config{kernel} = $major . "." . $minor;
|
$config{kernel} = $major . "." . $minor;
|
||||||
if(!grep {$_ eq $config{os}} @suppsys) {
|
if(!grep {$_ eq $config{os}} @suppsys) {
|
||||||
die("FATAL: your operating system ($config{os}) is not supported.\n");
|
die "FATAL: your operating system ($config{os}) is not supported.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(grep {$_ eq $config{os}} ("FreeBSD", "OpenBSD", "NetBSD")) {
|
if(grep {$_ eq $config{os}} ("FreeBSD", "OpenBSD", "NetBSD")) {
|
||||||
|
@ -418,13 +399,13 @@ $0 = sprintf("%s %s%s%s%s",
|
||||||
$options{d} ? " -d $options{d}" : "",
|
$options{d} ? " -d $options{d}" : "",
|
||||||
$options{v} ? " -v" : "");
|
$options{v} ? " -v" : "");
|
||||||
|
|
||||||
#daemonize();
|
daemonize();
|
||||||
logger("Starting Monitorix version " . VERSION . " (pid $$).");
|
logger("Starting Monitorix version " . VERSION . " (pid $$).");
|
||||||
|
|
||||||
if($options{p}) {
|
if($options{p}) {
|
||||||
$options{p} = abs_path($options{p});
|
$options{p} = abs_path($options{p});
|
||||||
open(OUT, "> $options{p}")
|
open(OUT, "> $options{p}")
|
||||||
|| die("could not open '$options{p}' for writing");
|
|| die "could not open '$options{p}' for writing: $!";
|
||||||
print(OUT "$$");
|
print(OUT "$$");
|
||||||
close(OUT);
|
close(OUT);
|
||||||
}
|
}
|
||||||
|
@ -432,9 +413,7 @@ if($options{p}) {
|
||||||
# change to a safety directory
|
# change to a safety directory
|
||||||
unless(chdir("/tmp")) {
|
unless(chdir("/tmp")) {
|
||||||
logger("can't chdir to /tmp: $!");
|
logger("can't chdir to /tmp: $!");
|
||||||
unless(chdir("/lost+found")) {
|
chdir("/lost+found") || die "Can't chdir to /lost+found: $!";
|
||||||
die("Can't chdir to /lost+found: $!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if($options{d}) {
|
if($options{d}) {
|
||||||
|
@ -442,7 +421,7 @@ if($options{d}) {
|
||||||
@{$config{debug}} = split(',', $options{d});
|
@{$config{debug}} = split(',', $options{d});
|
||||||
foreach my $t (@{$config{debug}}) {
|
foreach my $t (@{$config{debug}}) {
|
||||||
if(!grep {trim($_) eq $t} (split(',', $config{graph_name} . ", traffacct"))) {
|
if(!grep {trim($_) eq $t} (split(',', $config{graph_name} . ", traffacct"))) {
|
||||||
die("Invalid debug key '$t'");
|
die "Invalid debug key '$t'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -494,8 +473,8 @@ foreach (split(',', $config{graph_name} . ", traffacct")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
# XXX
|
# XXX
|
||||||
use Data::Dumper;
|
#use Data::Dumper;
|
||||||
print Dumper($config{func_update});
|
#print Dumper($config{func_update});
|
||||||
# XXX
|
# XXX
|
||||||
|
|
||||||
if(!scalar($config{func_update})) {
|
if(!scalar($config{func_update})) {
|
||||||
|
|
|
@ -22,7 +22,8 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use FindBin qw($Bin);
|
use FindBin qw($Bin);
|
||||||
use lib $Bin . '/lib';
|
use lib "$Bin/lib";
|
||||||
|
use lib "/usr/lib/monitorix";
|
||||||
|
|
||||||
use Monitorix;
|
use Monitorix;
|
||||||
use CGI qw(:standard);
|
use CGI qw(:standard);
|
||||||
|
|
|
@ -12,10 +12,10 @@ enable_zoom = y
|
||||||
netstats_in_bps = n
|
netstats_in_bps = n
|
||||||
disable_javascript_void = n
|
disable_javascript_void = n
|
||||||
|
|
||||||
base_dir = /usr/share/monitorix3/
|
base_dir = /usr/share/monitorix/
|
||||||
base_lib = /var/lib/monitorix3/
|
base_lib = /var/lib/monitorix/
|
||||||
base_url = /monitorix3
|
base_url = /monitorix
|
||||||
base_cgi = /monitorix-cgi3
|
base_cgi = /monitorix-cgi
|
||||||
|
|
||||||
|
|
||||||
# Log files pathnames
|
# Log files pathnames
|
||||||
|
|
Loading…
Reference in New Issue