fix rrd history patch for compilation

This commit is contained in:
Meliox 2026-06-09 23:02:46 +02:00
parent 94742a5620
commit 576032a269

View File

@ -8,60 +8,11 @@
{ name => 'scan' },
{ name => 'sdn' },
{ name => 'services' },
@@ -878,6 +879,108 @@
@@ -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
+" unless $card =~ /^[a-zA-Z0-9]+$/;
+ return PVE::RRD::create_rrd_data(
+ "pve-mod-gpu/$nodename/$card", $param->{timeframe}, $param->{cf},
+ );
+ },
-});
+});
+
+__PACKAGE__->register_method({
@ -107,13 +58,11 @@
+ my ($param) = @_;
+ my $nodename = PVE::INotify::nodename();
+ my $card = $param->{card};
+ die "invalid card name
+" unless $card =~ /^[a-zA-Z0-9]+$/;
+ 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({
__PACKAGE__->register_method({