Restructure repo (#251)

* refactor: restructure src/ into modules/, scripts/, and build/

- src/nag_screen/ and src/node_info/ -> src/modules/  (mods grouped explicitly)
- src/Scripts/ -> src/scripts/                        (lowercase, consistent)
- src/gen-rules.sh -> build/                          (build tool separated from source)

Update all references: debian/rules, .github/workflows/*, build/gen-rules.sh,
src/scripts/test/test-syntax.sh (SRC_DIR now points to src/modules/),
src/scripts/test/test-patches.sh, and files.list comments.

* refactor: move CI test scripts from src/scripts/test/ to build/test/

Test scripts are not installed — they are CI/dev tooling and belong
alongside build/gen-rules.sh. Update workflow references and fix the
SRC_DIR path depth in build/test/test-syntax.sh (../ -> ../..).

* d

---------

Co-authored-by: Meliox <na>
This commit is contained in:
MelioxandMeliox authored and GitHub committed 2026-08-08 23:46:46 +02:00
1 parent 3db6a010df
commit 6585849459
44 files changed
+342 -30

No files matched your search

@@ -0,0 +1,16 @@
--- a/usr/share/perl5/PVE/API2/Nodes.pm
+++ b/usr/share/perl5/PVE/API2/Nodes.pm
@@ -536,6 +536,13 @@
$res->{pveversion} = PVE::pvecfg::package() . "/" . PVE::pvecfg::version_text();
+ # Collect sensor data from PveMod_SensorInfo
+ use PVE::API2::PVEMod_SensorInfo;
+ $res->{PveMod_JsonSensorInfo} = PVE::API2::PVEMod_SensorInfo::get_sensors_info();
+ $res->{PveMod_Version} = PVE::API2::PVEMod_SensorInfo::get_pve_mod_version();
+ $res->{PveMod_upsInfo} = PVE::API2::PVEMod_SensorInfo::get_ups_info();
+ $res->{PveMod_graphicsInfo} = PVE::API2::PVEMod_SensorInfo::get_graphics_info();
+ $res->{PveMod_systemInfo} = PVE::API2::PVEMod_SensorInfo::get_system_information();
my $dinfo = df('/', 1); # output is bytes
$res->{rootfs} = {
@@ -0,0 +1,67 @@
--- usr/share/perl5/PVE/API2/Nodes.pm 2026-05-24 02:05:58.000000000 +0200
+++ /usr/share/perl5/PVE/API2/Nodes.pm 2026-06-13 16:29:47.810720485 +0200
@@ -251,6 +251,7 @@
{ name => 'report' },
{ name => 'rrd' }, # fixme: remove?
{ name => 'rrddata' },
+ { name => 'gpurrddata' },
{ name => 'scan' },
{ name => 'sdn' },
{ name => 'services' },
@@ -879,6 +880,56 @@
);
},
});
+
+__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({
name => 'syslog',
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,9 @@
# pve-mod :: node_info patch manifest
# Format: <patch-file> [section.key=value]
# Patches are applied top-to-bottom. An optional condition (read from this mod's
# conf.d file, /etc/pve-mod/conf.d/node_info.conf) gates a patch; it is applied
# only when the key equals the given value.
01-nodes-pm-sensors.patch
02-nodes-pm-GPU-RRD-history.patch gpu.gpu_history=1
03-pvemanager-js-sensors.patch
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
# post-apply hook for the node_info mod.
# Runs after node_info patches are applied. Provided env: MOD_CONF, STASH_DIR,
# CONFD_DIR. Creates the GPU RRD storage directory when GPU history is enabled.
# Exit codes: 0 = no change, 100 = changed (restart pveproxy), other = error.
set -u
GPU_RRD_DIR="/var/lib/rrdcached/db/pve-mod-gpu"
read_conf() {
local file="$1" section="$2" key="$3" default="${4:-0}"
[[ -f "$file" ]] || { echo "$default"; return; }
local val
val=$(awk -F= -v sec="[$section]" -v k="$key" '
/^\[/ { in_sec = ($0 == sec) }
in_sec && /^[^#=]+=/ {
gsub(/^[[:space:]]+|[[:space:]]+$/, "", $1)
if ($1 == k) { gsub(/^[[:space:]]+|[[:space:]]+$/, "", $2); print $2; exit }
}
' "$file")
echo "${val:-$default}"
}
gpu_history="$(read_conf "${MOD_CONF:-/etc/pve-mod/conf.d/node_info.conf}" gpu gpu_history 0)"
if [[ "$gpu_history" == "1" && ! -d "$GPU_RRD_DIR" ]]; then
mkdir -p "$GPU_RRD_DIR"
chown www-data:www-data "$GPU_RRD_DIR" 2>/dev/null || true
echo "[pve-mod] Created GPU RRD directory: $GPU_RRD_DIR"
exit 100
fi
exit 0