PVE-mods/src/node_info/patches/02-nodes-pm-GPU-RRD-history.patch
2026-06-11 22:20:28 +02:00

68 lines
2.1 KiB
Diff

--- a/usr/share/perl5/PVE/API2/Nodes.pm
+++ b/usr/share/perl5/PVE/API2/Nodes.pm
@@ -251,6 +251,7 @@
{ name => 'report' },
{ name => 'rrd' }, # fixme: remove?
{ name => 'rrddata' },
+ { name => 'gpurrddata' },
{ name => 'scan' },
{ name => 'sdn' },
{ name => 'services' },
@@ -878,6 +879,57 @@
"pve-node-9.0/$param->{node}", $param->{timeframe}, $param->{cf},
);
},
-});
+});
+
+__PACKAGE__->register_method({
+ name => 'gpurrddata',
+ path => 'gpurrddata',
+ method => 'GET',
+ protected => 1,
+ proxyto => 'node',
+ permissions => {
+ check => ['perm', '/nodes/{node}', ['Sys.Audit']],
+ },
+ description => "Read GPU RRD statistics",
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ card => {
+ description => "The GPU card identifier (e.g. card0, nvidia0).",
+ type => 'string',
+ pattern => '[a-zA-Z0-9]+',
+ },
+ timeframe => {
+ description => "Specify the time frame you are interested in.",
+ type => 'string',
+ enum => ['hour', 'day', 'week', 'month', 'year', 'decade'],
+ },
+ cf => {
+ description => "The RRD consolidation function",
+ type => 'string',
+ enum => ['AVERAGE', 'MAX'],
+ optional => 1,
+ },
+ },
+ },
+ returns => {
+ type => "array",
+ items => {
+ type => "object",
+ properties => {},
+ },
+ },
+ code => sub {
+ my ($param) = @_;
+ my $nodename = PVE::INotify::nodename();
+ my $card = $param->{card};
+ die "invalid card name\n" unless $card =~ /^[a-zA-Z0-9]+$/;
+ return PVE::RRD::create_rrd_data(
+ "pve-mod-gpu/$nodename/$card", $param->{timeframe}, $param->{cf},
+ );
+ },
+});
__PACKAGE__->register_method({