mirror of https://github.com/mikaku/Monitorix.git
included alerts in the 'system' graph configuration section
This commit is contained in:
parent
b07ffc96db
commit
cf5f48c189
|
@ -31,6 +31,7 @@ sub system_init {
|
||||||
my $myself = (caller(0))[3];
|
my $myself = (caller(0))[3];
|
||||||
my ($package, $config, $debug) = @_;
|
my ($package, $config, $debug) = @_;
|
||||||
my $rrd = $config->{base_lib} . $package . ".rrd";
|
my $rrd = $config->{base_lib} . $package . ".rrd";
|
||||||
|
my $system = $config->{system};
|
||||||
|
|
||||||
if(!(-e $rrd)) {
|
if(!(-e $rrd)) {
|
||||||
logger("Creating '$rrd' file.");
|
logger("Creating '$rrd' file.");
|
||||||
|
@ -90,8 +91,8 @@ sub system_init {
|
||||||
}
|
}
|
||||||
|
|
||||||
# check dependencies
|
# check dependencies
|
||||||
if(lc($config->{alerts}->{enabled}) eq "y") {
|
if(lc($system->{alerts}->{enabled}) eq "y") {
|
||||||
if(! -x $config->{alerts}->{loadavg_script}) {
|
if(! -x $system->{alerts}->{loadavg_script}) {
|
||||||
logger("$myself: ERROR: script '$config->{alerts}->{loadavg_script}' doesn't exist or don't has execution permissions.");
|
logger("$myself: ERROR: script '$config->{alerts}->{loadavg_script}' doesn't exist or don't has execution permissions.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,6 +106,7 @@ sub system_update {
|
||||||
my $myself = (caller(0))[3];
|
my $myself = (caller(0))[3];
|
||||||
my ($package, $config, $debug) = @_;
|
my ($package, $config, $debug) = @_;
|
||||||
my $rrd = $config->{base_lib} . $package . ".rrd";
|
my $rrd = $config->{base_lib} . $package . ".rrd";
|
||||||
|
my $system = $config->{system};
|
||||||
|
|
||||||
my $load1;
|
my $load1;
|
||||||
my $load5;
|
my $load5;
|
||||||
|
@ -276,16 +278,18 @@ sub system_update {
|
||||||
);
|
);
|
||||||
|
|
||||||
# SYSTEM alert
|
# SYSTEM alert
|
||||||
if(lc($config->{alerts}->{enabled}) eq "y") {
|
if(lc($system->{alerts}->{enabled}) eq "y") {
|
||||||
if(!$config->{alerts}->{loadavg_threshold} || $load15 < $config->{alerts}->{loadavg_threshold}) {
|
if(!$system->{alerts}->{loadavg_threshold} || $load15 < $system->{alerts}->{loadavg_threshold}) {
|
||||||
$config->{system_hist} = 0;
|
$config->{system_hist} = 0;
|
||||||
} else {
|
} else {
|
||||||
if(!$config->{system_hist}) {
|
if(!$config->{system_hist}) {
|
||||||
$config->{system_hist} = time;
|
$config->{system_hist} = time;
|
||||||
}
|
}
|
||||||
if($config->{system_hist} > 0 && (time - $config->{system_hist}) > $config->{alerts}->{loadavg_timeintvl}) {
|
if($config->{system_hist} > 0 && (time - $config->{system_hist}) > $system->{alerts}->{loadavg_timeintvl}) {
|
||||||
if(-x $config->{alerts}->{loadavg_script}) {
|
if(-x $system->{alerts}->{loadavg_script}) {
|
||||||
system($config->{alerts}->{loadavg_script} . " " .$config->{alerts}->{loadavg_timeintvl} . " " . $config->{alerts}->{loadavg_threshold} . " " . $load15);
|
system($system->{alerts}->{loadavg_script} . " " .$system->{alerts}->{loadavg_timeintvl} . " " . $system->{alerts}->{loadavg_threshold} . " " . $load15);
|
||||||
|
} else {
|
||||||
|
logger("$myself: ERROR: script '$config->{alerts}->{loadavg_script}' doesn't exist or don't has execution permissions.");
|
||||||
}
|
}
|
||||||
$config->{system_hist} = time;
|
$config->{system_hist} = time;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue