diff --git a/agent/linux/report-tasks.sh b/agent/linux/report-tasks.sh index 33e7496..8df7337 100644 --- a/agent/linux/report-tasks.sh +++ b/agent/linux/report-tasks.sh @@ -191,7 +191,10 @@ collect_system_info() { fi local cpu_model="" cpu_cores=0 cpu_load_percent="null" - cpu_model=$(grep -m1 "model name" /proc/cpuinfo 2>/dev/null | cut -d: -f2- | sed 's/^ *//') + # Some ARM kernels (e.g. Raspberry Pi) have no "model name" line in + # /proc/cpuinfo at all — grep then finds no match and exits 1, which is not + # a real error here, just an absent field. + cpu_model=$(grep -m1 "model name" /proc/cpuinfo 2>/dev/null | cut -d: -f2- | sed 's/^ *//' || true) cpu_cores=$(nproc 2>/dev/null || echo 0) if [[ -r /proc/loadavg && "$cpu_cores" -gt 0 ]]; then local load1 @@ -233,7 +236,19 @@ collect_system_info() { collect_cron collect_systemd_timers + +# Hardware/network facts are best-effort: a quirk on any given host (e.g. no +# "model name" line in /proc/cpuinfo on some ARM boards) must never abort the +# whole report over it, so errexit is relaxed just for this call. +SYSTEM_JSON="null" +set +e collect_system_info +system_info_status=$? +set -e +if [[ "$system_info_status" -ne 0 ]]; then + echo "Warning: collecting hardware/network info failed (exit $system_info_status) — reporting tasks without it." >&2 + SYSTEM_JSON="null" +fi HOSTNAME_VALUE=$(hostname -f 2>/dev/null || hostname) PAYLOAD=$(jq -n \ diff --git a/server/src/routes/agentReport.ts b/server/src/routes/agentReport.ts index d197e52..c9f561b 100644 --- a/server/src/routes/agentReport.ts +++ b/server/src/routes/agentReport.ts @@ -18,7 +18,7 @@ const reportSchema = z.object({ hostname: z.string().max(255).optional(), os_type: z.string().optional(), reported_at: z.string().optional(), - system: systemSchema.optional(), + system: systemSchema.nullable().optional(), tasks: z.array( z.object({ schedule_type: z.enum(["cron", "systemd_timer"]), diff --git a/server/src/services/taskSync.ts b/server/src/services/taskSync.ts index af8b195..c2520d9 100644 --- a/server/src/services/taskSync.ts +++ b/server/src/services/taskSync.ts @@ -22,7 +22,7 @@ export interface IncomingSystemInfo { export interface AgentReport { hostname?: string; - system?: IncomingSystemInfo; + system?: IncomingSystemInfo | null; tasks: IncomingTask[]; }