refactor nvidia collection and cleanup
This commit is contained in:
parent
e19f9174c9
commit
6fb9e1cf75
67
pve-mod.pm
67
pve-mod.pm
@ -271,8 +271,9 @@ sub _collector_for_intel_device {
|
|||||||
sub _parse_graphic_info {
|
sub _parse_graphic_info {
|
||||||
my ($line) = @_;
|
my ($line) = @_;
|
||||||
|
|
||||||
# Create an intel file with
|
# Create a RRD Database (One-Time Setup)
|
||||||
# Timestamp Device index, name, Render/3D, Blitter, Video, VideoEnhance, power consumption
|
|
||||||
|
# Collect intel GPU data and save it into the database
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
@ -304,7 +305,7 @@ sub _collector_for_amd_device {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# NVIDIA GPU Support (Placeholder)
|
# NVIDIA GPU Support
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|
||||||
sub get_nvidia_gpu_devices {
|
sub get_nvidia_gpu_devices {
|
||||||
@ -315,8 +316,6 @@ sub get_nvidia_gpu_devices {
|
|||||||
# 0, NVIDIA GeForce RTX 3080
|
# 0, NVIDIA GeForce RTX 3080
|
||||||
# 1, NVIDIA RTX A4000
|
# 1, NVIDIA RTX A4000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($nvidia_debug_mode && -f $nvidia_debug_devices) {
|
if ($nvidia_debug_mode && -f $nvidia_debug_devices) {
|
||||||
_debug(__LINE__, "Debug mode: reading NVIDIA GPU devices from $nvidia_debug_devices");
|
_debug(__LINE__, "Debug mode: reading NVIDIA GPU devices from $nvidia_debug_devices");
|
||||||
if (open my $fh, '<', $nvidia_debug_devices) {
|
if (open my $fh, '<', $nvidia_debug_devices) {
|
||||||
@ -424,31 +423,8 @@ sub parse_nvidia_gpu_line {
|
|||||||
return $stats;
|
return $stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub _collector_for_nvidia_devices {
|
sub _get_and_write_nvidia_stats {
|
||||||
my ($devices) = @_;
|
my ($devices) = @_;
|
||||||
$process_type = 'collector';
|
|
||||||
|
|
||||||
$0 = "collector-gpu-nvidia-all";
|
|
||||||
|
|
||||||
_debug(__LINE__, "NVIDIA collector started for " . scalar(@$devices) . " GPU(s)");
|
|
||||||
|
|
||||||
# Set up signal handlers for graceful shutdown
|
|
||||||
my $shutdown = 0;
|
|
||||||
$SIG{TERM} = sub {
|
|
||||||
_debug(__LINE__, "NVIDIA collector received SIGTERM");
|
|
||||||
$shutdown = 1;
|
|
||||||
};
|
|
||||||
$SIG{INT} = sub {
|
|
||||||
_debug(__LINE__, "NVIDIA collector received SIGINT");
|
|
||||||
$shutdown = 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Expected CSV format (with header):
|
|
||||||
# index, name, temperature.gpu, utilization.gpu, utilization.memory, memory.used, memory.total, power.draw, power.limit, fan.speed
|
|
||||||
# 0, NVIDIA GeForce RTX 3080, 62, 79, 44, 8260, 10240, 268.12, 320.00, 67
|
|
||||||
# 1, NVIDIA RTX A4000, 58, 45, 32, 4120, 16384, 145.50, 200.00, 55
|
|
||||||
|
|
||||||
while (!$shutdown) {
|
|
||||||
my @all_stats;
|
my @all_stats;
|
||||||
|
|
||||||
if ($nvidia_debug_mode && -f $nvidia_debug_output) {
|
if ($nvidia_debug_mode && -f $nvidia_debug_output) {
|
||||||
@ -543,6 +519,37 @@ sub _collector_for_nvidia_devices {
|
|||||||
_debug(__LINE__, "No valid NVIDIA GPU stats collected");
|
_debug(__LINE__, "No valid NVIDIA GPU stats collected");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return scalar(@all_stats);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub _collector_for_nvidia_devices {
|
||||||
|
my ($devices) = @_;
|
||||||
|
$process_type = 'collector';
|
||||||
|
|
||||||
|
$0 = "collector-gpu-nvidia-all";
|
||||||
|
|
||||||
|
_debug(__LINE__, "NVIDIA collector started for " . scalar(@$devices) . " GPU(s)");
|
||||||
|
|
||||||
|
# Set up signal handlers for graceful shutdown
|
||||||
|
my $shutdown = 0;
|
||||||
|
$SIG{TERM} = sub {
|
||||||
|
_debug(__LINE__, "NVIDIA collector received SIGTERM");
|
||||||
|
$shutdown = 1;
|
||||||
|
};
|
||||||
|
$SIG{INT} = sub {
|
||||||
|
_debug(__LINE__, "NVIDIA collector received SIGINT");
|
||||||
|
$shutdown = 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Expected CSV format (with header):
|
||||||
|
# index, name, temperature.gpu, utilization.gpu, utilization.memory, memory.used, memory.total, power.draw, power.limit, fan.speed
|
||||||
|
# 0, NVIDIA GeForce RTX 3080, 62, 79, 44, 8260, 10240, 268.12, 320.00, 67
|
||||||
|
# 1, NVIDIA RTX A4000, 58, 45, 32, 4120, 16384, 145.50, 200.00, 55
|
||||||
|
|
||||||
|
while (!$shutdown) {
|
||||||
|
# Collect and write NVIDIA GPU stats
|
||||||
|
_get_and_write_nvidia_stats($devices);
|
||||||
|
|
||||||
sleep $data_pull_interval unless $shutdown;
|
sleep $data_pull_interval unless $shutdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -579,8 +586,6 @@ sub _start_child_collector {
|
|||||||
return $pid;
|
return $pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Legacy PID file functions removed - worker now manages collectors directly via %collectors hash
|
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# Temperature Sensors
|
# Temperature Sensors
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user