mirror of https://github.com/mikaku/Monitorix.git
fixed in 'lmsens' to not use the returned value if 'nvidia-smi' is not installed
This commit is contained in:
parent
a4b8372901
commit
a9a0876914
|
@ -95,6 +95,7 @@ sub httpd_setup {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub get_nvidia_data {
|
sub get_nvidia_data {
|
||||||
|
my $myself = (caller(0))[3];
|
||||||
my ($gpu) = @_;
|
my ($gpu) = @_;
|
||||||
my $total = 0;
|
my $total = 0;
|
||||||
my $used = 0;
|
my $used = 0;
|
||||||
|
@ -106,9 +107,13 @@ sub get_nvidia_data {
|
||||||
my $check_temp = 0;
|
my $check_temp = 0;
|
||||||
my $l;
|
my $l;
|
||||||
|
|
||||||
open(IN, "nvidia-smi -q -i $gpu -d MEMORY,UTILIZATION,TEMPERATURE |");
|
my @data = ();
|
||||||
my @data = <IN>;
|
if(open(IN, "nvidia-smi -q -i $gpu -d MEMORY,UTILIZATION,TEMPERATURE |")) {
|
||||||
close(IN);
|
@data = <IN>;
|
||||||
|
close(IN);
|
||||||
|
} else {
|
||||||
|
logger("$myself: ERROR: 'nvidia-smi' command is not installed.");
|
||||||
|
}
|
||||||
for($l = 0; $l < scalar(@data); $l++) {
|
for($l = 0; $l < scalar(@data); $l++) {
|
||||||
if($data[$l] =~ /Memory Usage/) {
|
if($data[$l] =~ /Memory Usage/) {
|
||||||
$check_mem = 1;
|
$check_mem = 1;
|
||||||
|
|
|
@ -240,9 +240,13 @@ sub lmsens_update {
|
||||||
(undef, undef, $gpu[$n]) = split(' ', get_nvidia_data($n));
|
(undef, undef, $gpu[$n]) = split(' ', get_nvidia_data($n));
|
||||||
if(!$gpu[$n]) {
|
if(!$gpu[$n]) {
|
||||||
# attempt to get data using the old driver version
|
# attempt to get data using the old driver version
|
||||||
open(IN, "nvidia-smi -g $n |");
|
my @data = ();
|
||||||
my @data = <IN>;
|
if(open(IN, "nvidia-smi -g $n |")) {
|
||||||
close(IN);
|
@data = <IN>;
|
||||||
|
close(IN);
|
||||||
|
} else {
|
||||||
|
logger("$myself: ERROR: 'nvidia-smi' command is not installed.");
|
||||||
|
}
|
||||||
for($l = 0; $l < scalar(@data); $l++) {
|
for($l = 0; $l < scalar(@data); $l++) {
|
||||||
if($data[$l] =~ /Temperature/) {
|
if($data[$l] =~ /Temperature/) {
|
||||||
my (undef, $tmp) = split(':', $data[$l]);
|
my (undef, $tmp) = split(':', $data[$l]);
|
||||||
|
|
Loading…
Reference in New Issue