mirror of https://github.com/mikaku/Monitorix.git
added the ability to include an alert for each defined sensor in 'nvidia.pm'
This commit is contained in:
parent
1017f69f58
commit
f992d069a9
1
Changes
1
Changes
|
@ -37,6 +37,7 @@
|
||||||
- Added the ability to include an alert for each defined sensor in 'hptemp.pm'.
|
- Added the ability to include an alert for each defined sensor in 'hptemp.pm'.
|
||||||
- Added the ability to include an alert for each defined sensor in 'ipmi.pm'.
|
- Added the ability to include an alert for each defined sensor in 'ipmi.pm'.
|
||||||
- Added alert capabilities to 'lmsens.pm'. [#171]
|
- Added alert capabilities to 'lmsens.pm'. [#171]
|
||||||
|
- Added the ability to include an alert for each defined sensor in 'nvidia.pm'.
|
||||||
- Fixed an undeclared global symbol "$imgfmt_lc" in 'traffacct.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
|
- Fixed the MIME type of graphs in 'emailreports.pm' and in 'traffacct.pm' to
|
||||||
honor the 'image_format' option. [#174]
|
honor the 'image_format' option. [#174]
|
||||||
|
|
|
@ -133,10 +133,44 @@ sub nvidia_init {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$config->{nvidia_hist_alerts} = ();
|
||||||
push(@{$config->{func_update}}, $package);
|
push(@{$config->{func_update}}, $package);
|
||||||
logger("$myself: Ok") if $debug;
|
logger("$myself: Ok") if $debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub nvidia_alerts {
|
||||||
|
my $myself = (caller(0))[3];
|
||||||
|
my $config = (shift);
|
||||||
|
my $sensor = (shift);
|
||||||
|
my $val = (shift);
|
||||||
|
|
||||||
|
my $nvidia = $config->{nvidia};
|
||||||
|
my @al = split(',', $nvidia->{alerts}->{$sensor} || "");
|
||||||
|
|
||||||
|
if(scalar(@al)) {
|
||||||
|
my $timeintvl = trim($al[0]);
|
||||||
|
my $threshold = trim($al[1]);
|
||||||
|
my $script = trim($al[2]);
|
||||||
|
|
||||||
|
if(!$threshold || $val < $threshold) {
|
||||||
|
$config->{nvidia_hist_alerts}->{$sensor} = 0;
|
||||||
|
} else {
|
||||||
|
if(!$config->{nvidia_hist_alerts}->{$sensor}) {
|
||||||
|
$config->{nvidia_hist_alerts}->{$sensor} = time;
|
||||||
|
}
|
||||||
|
if($config->{nvidia_hist_alerts}->{$sensor} > 0 && (time - $config->{nvidia_hist_alerts}->{$sensor}) >= $timeintvl) {
|
||||||
|
if(-x $script) {
|
||||||
|
logger("$myself: alert on NVIDIA ($sensor): executing script '$script'.");
|
||||||
|
system($script . " " . $timeintvl . " " . $threshold . " " . $val);
|
||||||
|
} else {
|
||||||
|
logger("$myself: ERROR: script '$script' doesn't exist or don't has execution permissions.");
|
||||||
|
}
|
||||||
|
$config->{nvidia_hist_alerts}->{$sensor} = time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub nvidia_update {
|
sub nvidia_update {
|
||||||
my $myself = (caller(0))[3];
|
my $myself = (caller(0))[3];
|
||||||
my ($package, $config, $debug) = @_;
|
my ($package, $config, $debug) = @_;
|
||||||
|
@ -216,12 +250,18 @@ sub nvidia_update {
|
||||||
}
|
}
|
||||||
|
|
||||||
for($n = 0; $n < scalar(@temp); $n++) {
|
for($n = 0; $n < scalar(@temp); $n++) {
|
||||||
|
# check alerts for each sensor defined
|
||||||
|
nvidia_alerts($config, "temp$n", $temp[$n]);
|
||||||
$rrdata .= ":$temp[$n]";
|
$rrdata .= ":$temp[$n]";
|
||||||
}
|
}
|
||||||
for($n = 0; $n < scalar(@gpu); $n++) {
|
for($n = 0; $n < scalar(@gpu); $n++) {
|
||||||
|
# check alerts for each sensor defined
|
||||||
|
nvidia_alerts($config, "gpu$n", $gpu[$n]);
|
||||||
$rrdata .= ":$gpu[$n]";
|
$rrdata .= ":$gpu[$n]";
|
||||||
}
|
}
|
||||||
for($n = 0; $n < scalar(@mem); $n++) {
|
for($n = 0; $n < scalar(@mem); $n++) {
|
||||||
|
# check alerts for each sensor defined
|
||||||
|
nvidia_alerts($config, "mem$n", $mem[$n]);
|
||||||
$rrdata .= ":$mem[$n]";
|
$rrdata .= ":$mem[$n]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -259,6 +259,8 @@ secure_log_date_format = %b %e
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
<nvidia>
|
<nvidia>
|
||||||
max = 1
|
max = 1
|
||||||
|
<alerts>
|
||||||
|
</alerts>
|
||||||
rigid = 1, 2, 2
|
rigid = 1, 2, 2
|
||||||
limit = 50, 100, 100
|
limit = 50, 100, 100
|
||||||
</nvidia>
|
</nvidia>
|
||||||
|
|
Loading…
Reference in New Issue