From edcd445e596a9b227dc652e0b03c45751c64a049 Mon Sep 17 00:00:00 2001 From: Meliox <5264368+Meliox@users.noreply.github.com> Date: Sun, 5 Jul 2026 18:59:10 +0200 Subject: [PATCH] fix intel gpu debug (#231) * fix intel debug * set path to the same --------- Co-authored-by: Meliox --- src/node_info/files/Collector/Intel.pm | 60 ++++++++++++-------------- src/node_info/files/Config.pm | 4 +- src/node_info/node_info.configure.sh | 2 +- 3 files changed, 30 insertions(+), 36 deletions(-) diff --git a/src/node_info/files/Collector/Intel.pm b/src/node_info/files/Collector/Intel.pm index f747060..2122ede 100644 --- a/src/node_info/files/Collector/Intel.pm +++ b/src/node_info/files/Collector/Intel.pm @@ -5,7 +5,7 @@ use warnings; use Exporter 'import'; use PVE::PVEMod::Config qw(%config $process_type $pve_mod_working_dir); -use PVE::PVEMod::Utils qw(debug check_executable setup_collector_signals safe_read_json safe_write_json); +use PVE::PVEMod::Utils qw(debug check_executable setup_collector_signals safe_write_json); use PVE::PVEMod::Store qw(update_intel_gpu_rrd); our @EXPORT_OK = qw( @@ -19,47 +19,41 @@ our @EXPORT_OK = qw( sub get_intel_gpu_devices { my @devices = (); + my $fh; + + # Parse: "card0 Intel Alderlake_n (Gen12) pci:vendor=8086,device=46D0,card=0" + # or: "card0 Intel Alderlake_n (Gen12) pci:0000:00:02.0" if ($config{debug}{intel_mode} && -f $config{debug}{intel_devices_file}) { - debug(__LINE__, "Debug mode: reading Intel GPU devices from $config{debug}{intel_devices_file}"); - my $data = safe_read_json($config{debug}{intel_devices_file}); - if ($data && ref $data eq 'ARRAY') { - for my $dev (@$data) { - push @devices, { - card => $dev->{card}, - name => $dev->{name}, - path => $dev->{path}, - drm_path => $dev->{drm_path}, - }; - debug(__LINE__, "Found Intel device (debug): $dev->{card} -> $dev->{name} ($dev->{path})"); - } - } else { - debug(__LINE__, "Failed to parse debug file $config{debug}{intel_devices_file}"); + my $file = $config{debug}{intel_devices_file}; + debug(__LINE__, "Debug mode: reading Intel GPU devices from $file"); + unless (open $fh, '<', $file) { + debug(__LINE__, "Failed to open debug file $file: $!"); + return @devices; } } else { debug(__LINE__, "Getting Intel GPU devices"); - if (open my $fh, '-|', 'intel_gpu_top -L') { - while (<$fh>) { - chomp; - # Parse: "card0 Intel Alderlake_n (Gen12) pci:vendor=8086,device=46D0,card=0" - # or: "card0 Intel Alderlake_n (Gen12) pci:0000:00:02.0" - if (/^(card\d+)\s+(.+?)\s+(pci:[^\s]+)/) { - my ($card, $name, $path) = ($1, $2, $3); - push @devices, { - card => $card, - name => $name, - path => $path, - drm_path => "/dev/dri/$card", - }; - debug(__LINE__, "Found Intel device: $card -> $name ($path)"); - } - } - close $fh; - } else { + unless (open $fh, '-|', 'intel_gpu_top -L') { debug(__LINE__, "Failed to run intel_gpu_top -L: $!"); + return @devices; } } + while (<$fh>) { + chomp; + if (/^(card\d+)\s+(.+?)\s+(pci:[^\s]+)/) { + my ($card, $name, $path) = ($1, $2, $3); + push @devices, { + card => $card, + name => $name, + path => $path, + drm_path => "/dev/dri/$card", + }; + debug(__LINE__, "Found Intel device: $card -> $name ($path)"); + } + } + close $fh; + return @devices; } diff --git a/src/node_info/files/Config.pm b/src/node_info/files/Config.pm index 5d31db2..f60d448 100644 --- a/src/node_info/files/Config.pm +++ b/src/node_info/files/Config.pm @@ -48,8 +48,8 @@ our %config = ( lm_sensors_mode => 0, lm_sensors_output_file => '/tmp/sensors-output.json', intel_mode => 0, - intel_devices_file => '/tmp/intel-gpu-devices.json', - intel_output_file => '/tmp/intel-gpu-output.json', + intel_devices_file => '/tmp/intel-gpu-devices.txt', + intel_output_file => '/tmp/intel-gpu-top-output.txt', nvidia_mode => 0, nvidia_devices_file => '/tmp/nvidia-smi-devices.csv', nvidia_output_file => '/tmp/nvidia-smi-output.csv', diff --git a/src/node_info/node_info.configure.sh b/src/node_info/node_info.configure.sh index 3362cd8..c7d32ee 100644 --- a/src/node_info/node_info.configure.sh +++ b/src/node_info/node_info.configure.sh @@ -71,7 +71,7 @@ node_info_defaults() { ENABLE_UPS=0; UPS_DEVICE_NAME="ups@localhost" ENABLE_SYSTEM_INFO=0; SYSTEM_INFO_TYPE=1 DEBUG_LM_SENSORS=0; DEBUG_LM_SENSORS_FILE="/tmp/sensors-output.json" - DEBUG_INTEL=0; DEBUG_INTEL_FILE="/tmp/intel-gpu-devices.json" + DEBUG_INTEL=0; DEBUG_INTEL_FILE="/tmp/intel-gpu-devices.txt" DEBUG_INTEL_OUTPUT_FILE="/tmp/intel-gpu-top-output.txt" DEBUG_NVIDIA=0; DEBUG_NVIDIA_OUTPUT_FILE="/tmp/nvidia-smi-output.csv" DEBUG_NVIDIA_DEVICES_FILE="/tmp/nvidia-smi-devices.csv"