diff --git a/lib/Monitorix.pm b/lib/Monitorix.pm index 215f83c..8b14f95 100644 --- a/lib/Monitorix.pm +++ b/lib/Monitorix.pm @@ -95,6 +95,7 @@ sub httpd_setup { } sub get_nvidia_data { + my $myself = (caller(0))[3]; my ($gpu) = @_; my $total = 0; my $used = 0; @@ -106,9 +107,13 @@ sub get_nvidia_data { my $check_temp = 0; my $l; - open(IN, "nvidia-smi -q -i $gpu -d MEMORY,UTILIZATION,TEMPERATURE |"); - my @data = ; - close(IN); + my @data = (); + if(open(IN, "nvidia-smi -q -i $gpu -d MEMORY,UTILIZATION,TEMPERATURE |")) { + @data = ; + close(IN); + } else { + logger("$myself: ERROR: 'nvidia-smi' command is not installed."); + } for($l = 0; $l < scalar(@data); $l++) { if($data[$l] =~ /Memory Usage/) { $check_mem = 1; diff --git a/lib/lmsens.pm b/lib/lmsens.pm index 2a8626b..b896e52 100644 --- a/lib/lmsens.pm +++ b/lib/lmsens.pm @@ -240,9 +240,13 @@ sub lmsens_update { (undef, undef, $gpu[$n]) = split(' ', get_nvidia_data($n)); if(!$gpu[$n]) { # attempt to get data using the old driver version - open(IN, "nvidia-smi -g $n |"); - my @data = ; - close(IN); + my @data = (); + if(open(IN, "nvidia-smi -g $n |")) { + @data = ; + close(IN); + } else { + logger("$myself: ERROR: 'nvidia-smi' command is not installed."); + } for($l = 0; $l < scalar(@data); $l++) { if($data[$l] =~ /Temperature/) { my (undef, $tmp) = split(':', $data[$l]);