mirror of https://github.com/mikaku/Monitorix.git
added the ability to include an alert for each defined sensor in 'gensens.pm'
This commit is contained in:
parent
582e6b0471
commit
421cd024b7
3
Changes
3
Changes
|
@ -26,13 +26,14 @@
|
|||
- Added support of Postgrey (Postfix Greylisting) in 'mail.pm'. [#102]
|
||||
(thanks to Malte Kubat, M.Kubat AT csb-it.de)
|
||||
- Updated to 4.01 the HTML DOCTYPE declarations.
|
||||
- Added more precision to the values in 'gensens.pm.
|
||||
- Added more precision to the values in 'gensens.pm'.
|
||||
- Added string encoding to avoid the message 'Wide character in print at
|
||||
./monitorix.cgi line ...'. [#186]
|
||||
- Added to force a standard locale in 'port.pm'. in order to be able for
|
||||
Monitorix to read the output of system commands (netstat, ...). [#186]
|
||||
- Added the new option 'stats_rate' in 'mail.pm' to be able to choose between
|
||||
'real' (new default) and 'per_second'.
|
||||
- Added the ability to include an alert for each defined sensor in 'gensens.pm'.
|
||||
- Fixed an undeclared global symbol "$imgfmt_lc" in 'traffacct.pm'.
|
||||
- Fixed the MIME type of graphs in 'emailreports.pm' and in 'traffacct.pm' to
|
||||
honor the 'image_format' option. [#174]
|
||||
|
|
|
@ -119,6 +119,7 @@ sub gensens_init {
|
|||
}
|
||||
}
|
||||
|
||||
$config->{gensens_hist_alerts} = ();
|
||||
push(@{$config->{func_update}}, $package);
|
||||
logger("$myself: Ok") if $debug;
|
||||
}
|
||||
|
@ -156,6 +157,33 @@ sub gensens_update {
|
|||
logger("$myself: ERROR: unable to open '$gensens->{desc}->{$str}'.");
|
||||
}
|
||||
}
|
||||
|
||||
# check alerts for each sensor defined
|
||||
my @al = split(',', $gensens->{alerts}->{$str} || "");
|
||||
if(scalar(@al)) {
|
||||
my $timeintvl = trim($al[0]);
|
||||
my $threshold = trim($al[1]);
|
||||
my $script = trim($al[2]);
|
||||
|
||||
if(!$threshold || $val < $threshold) {
|
||||
$config->{gensens_hist_alerts}->{$str} = 0;
|
||||
} else {
|
||||
if(!$config->{gensens_hist_alerts}->{$str}) {
|
||||
$config->{gensens_hist_alerts}->{$str} = time;
|
||||
}
|
||||
if($config->{gensens_hist_alerts}->{$str} > 0 && (time - $config->{gensens_hist_alerts}->{$str}) >= $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} = time;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$rrdata .= ":$val";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -880,6 +880,43 @@ With this option you can optionally rename any of the sensor names defined in th
|
|||
.P
|
||||
All names are limited to 20 characters.
|
||||
.RE
|
||||
.P
|
||||
.BI alerts
|
||||
.RS
|
||||
This optional list enables the alert capabilities for this graph and complements with the \fBlist\fP option. Each alert has three fields separated by comma: the \fItime interval\fP, the \fIthreshold\fP and the path to the \fIscript\fP to be executed.
|
||||
.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.
|
||||
.P
|
||||
The \fIscript\fP is the full path name of the script that will be executed by this alert.
|
||||
.P
|
||||
Each defined sensor has its own alert.
|
||||
.P
|
||||
The default Monitorix installation includes an example of a shell-script alert called \fImonitorix-alert.sh\fP which you can use as a base for your own script.
|
||||
.P
|
||||
The following is an example of an alert defined for the first temperature sensor:
|
||||
.P
|
||||
.RS
|
||||
<alerts>
|
||||
.br
|
||||
temp0 = 3600, 40, /path/to/script
|
||||
.br
|
||||
</alerts>
|
||||
.P
|
||||
.RE
|
||||
Such alert means that if the value of the sensor temp0 reaches or exceeds 40 during at least one hour (3600 seconds) the script in \fI/path/to/script\fP will be executed.
|
||||
.P
|
||||
The external script will receive the following arguments:
|
||||
.P
|
||||
.RS
|
||||
1st - the value defined as \fItime interval\fP.
|
||||
.br
|
||||
2nd - the value defined as \fIthreshold\fP.
|
||||
.br
|
||||
3rd - the value of the sensor.
|
||||
.P
|
||||
.RE
|
||||
.SS IPMI sensor statistics (ipmi.rrd)
|
||||
This graph is able to monitor an unlimited number of IPMI sensors (temperatures, fans and voltages).
|
||||
.P
|
||||
|
|
|
@ -220,6 +220,8 @@ secure_log_date_format = %b %e
|
|||
temp0 = Temperature Zone 0
|
||||
cpu0 = CPU0 frequency
|
||||
</map>
|
||||
<alerts>
|
||||
</alerts>
|
||||
rigid = 0, 0
|
||||
limit = 100, 100
|
||||
</gensens>
|
||||
|
|
Loading…
Reference in New Issue