mirror of https://github.com/mikaku/Monitorix.git
added the ability, in the alerts of 'gensens.pm', to support a range of two values separated by a dash in the threshold #221
This commit is contained in:
parent
5ff7f1bda4
commit
6a63750d74
2
Changes
2
Changes
|
@ -2,6 +2,8 @@
|
|||
====================
|
||||
- Added a complete graph to support PHP-FPM statistics ('phpfpm.pm'). [#167]
|
||||
- Added a warning if a process vanished during the accouting in 'process.pm'
|
||||
- Added the ability, in the alerts of 'gensens.pm', to support a range of two
|
||||
values separated by a dash in the threshold. [#221]
|
||||
- Fixed the copyright year in 'monitorix.cgi'.
|
||||
- Fixed in 'mail.pm to use the option 'mail_log' instead the hard coded path I
|
||||
forgot to remove when adding the Exim support.
|
||||
|
|
|
@ -192,7 +192,43 @@ sub gensens_update {
|
|||
}
|
||||
}
|
||||
} elsif(scalar(@range) == 2) {
|
||||
logger("$myself: range values are not supported yet.");
|
||||
if($when) {
|
||||
logger("$myself: the forth parameter ('$when') in '$str' is irrelevant when there are range values defined.");
|
||||
}
|
||||
if($range[0] == $range[1]) {
|
||||
logger("$myself: ERROR: range values are identical.");
|
||||
} else {
|
||||
if($val <= $range[0]) {
|
||||
$config->{gensens_hist_alerts}->{$str}->{above} = 0;
|
||||
if($val < $range[0] && !$config->{gensens_hist_alerts}->{$str}->{below}) {
|
||||
$config->{gensens_hist_alerts}->{$str}->{below} = time;
|
||||
}
|
||||
}
|
||||
if($val >= $range[1]) {
|
||||
$config->{gensens_hist_alerts}->{$str}->{below} = 0;
|
||||
if($val > $range[1] && !$config->{gensens_hist_alerts}->{$str}->{above}) {
|
||||
$config->{gensens_hist_alerts}->{$str}->{above} = time;
|
||||
}
|
||||
}
|
||||
if($config->{gensens_hist_alerts}->{$str}->{below} > 0 && (time - $config->{gensens_hist_alerts}->{$str}->{below}) >= $timeintvl) {
|
||||
if(-x $script) {
|
||||
logger("$myself: alert on Generic Sensor ($str): executing script '$script'.");
|
||||
system($script . " " . $timeintvl . " " . $threshold . " " . $val);
|
||||
} else {
|
||||
logger("$myself: ERROR: script '$script' doesn't exist or don't has execution permissions.");
|
||||
}
|
||||
$config->{gensens_hist_alerts}->{$str}->{below} = time;
|
||||
}
|
||||
if($config->{gensens_hist_alerts}->{$str}->{above} > 0 && (time - $config->{gensens_hist_alerts}->{$str}->{above}) >= $timeintvl) {
|
||||
if(-x $script) {
|
||||
logger("$myself: alert on Generic Sensor ($str): executing script '$script'.");
|
||||
system($script . " " . $timeintvl . " " . $threshold . " " . $val);
|
||||
} else {
|
||||
logger("$myself: ERROR: script '$script' doesn't exist or don't has execution permissions.");
|
||||
}
|
||||
$config->{gensens_hist_alerts}->{$str}->{above} = time;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logger("$myself: ERROR: invalid threshold value '$threshold'");
|
||||
}
|
||||
|
|
|
@ -977,11 +977,11 @@ This optional list enables the alert capabilities for this graph and complements
|
|||
.P
|
||||
The \fItime interval\fP is the period of time (in seconds) that the \fIthreshold\fP needs to be exceeded before the external script is executed.
|
||||
.P
|
||||
The \fIthreshold\fP is the value (either temperature or HZ) that needs to be reached or exceeded within the specified time in \fItime interval\fP to execute the external script.
|
||||
The \fIthreshold\fP is the value (either temperature or HZ) that needs to be reached or exceeded within the specified time in \fItime interval\fP to execute the external script. It can be specified as a unique value or as a range of two values separated by a dash.
|
||||
.P
|
||||
The \fIscript\fP is the full path name of the script that will be executed by this alert.
|
||||
.P
|
||||
The \fIwhen\fP value specifies when the alert must be triggered (\fIabove\fP or \fIbelow\fP) the threshold, being \fIabove\fP the default value when it's not specified.
|
||||
The \fIwhen\fP value specifies when the alert must be triggered (\fIabove\fP or \fIbelow\fP) the threshold, being \fIabove\fP the default value when it's not specified. This forth option is only relevant when the \fIthreshold\fP value is not a range.
|
||||
.P
|
||||
Each defined sensor has its own alert.
|
||||
.P
|
||||
|
@ -995,6 +995,8 @@ The following is an example of an alert defined for the first temperature sensor
|
|||
temp0 = 3600, 40, /path/to/script.sh, above
|
||||
.br
|
||||
temp1 = 3600, 10, /path/to/script.sh, below
|
||||
.br
|
||||
temp2 = 3600, 40-60, /path/to/script.sh
|
||||
.br
|
||||
</alerts>
|
||||
.P
|
||||
|
@ -1003,6 +1005,8 @@ The first alert means that if the value of the sensor temp0 exceeds above 40 dur
|
|||
.P
|
||||
The second alert means that if the value of the sensor temp1 exceeds below 10 during at least one hour (3600 seconds) the script in \fI/path/to/script.sh\fP will be executed.
|
||||
.P
|
||||
The third alert means that if the value of the sensor temp2 exceeds either below 40 or above of 60 during at least one hour (3600 seconds) the script in \fI/path/to/script.sh\fP will be executed.
|
||||
.P
|
||||
The external script will receive the following arguments:
|
||||
.P
|
||||
.RS
|
||||
|
|
Loading…
Reference in New Issue