Fold alerts under their host, recurring maintenance, run playbooks from alerts, and an Updates page
- Servers can say what they run on (or it is worked out from the Proxmox node); when the host is down the guests' offline alerts fold under it: held back, not counted, not notified, still recorded. - Recurring maintenance schedules made into ordinary windows a week ahead (maintenance_schedules). - Run a Semaphore template limited to a server from its page or an alert, and watch the run. - Agents report pending updates (apt, dnf, zypper, Windows Update); an Updates page lists them. - Migrations 0024 and 0025. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
44e393f172
commit
171511c6db
45 files changed
+6772
-44
No files matched your search
@@ -182,6 +182,46 @@ collect_systemd_timers() {
|
||||
done < <(jq -c '.[]' <<<"$timers_json")
|
||||
}
|
||||
|
||||
# Updates waiting to be installed, as JSON in UPDATES_JSON ("null" when this host's package manager isn't one we know, or couldn't answer).
|
||||
# Nothing is installed or refreshed: this reads what the package manager already knows about, so it is quick and changes nothing.
|
||||
collect_updates() {
|
||||
UPDATES_JSON="null"
|
||||
local manager="" count="" security="null" reboot="false" out="" status=0
|
||||
|
||||
if command -v apt-get >/dev/null 2>&1; then
|
||||
manager="apt"
|
||||
# -s simulates: "Inst" lines are what an upgrade would install. Security ones come from a "-security" or "Security" archive.
|
||||
if out=$(LC_ALL=C timeout 60 apt-get -s -o Debug::NoLocking=true upgrade 2>/dev/null); then
|
||||
count=$(grep -c '^Inst ' <<<"$out" || true)
|
||||
security=$(grep '^Inst ' <<<"$out" | grep -ci 'security' || true)
|
||||
fi
|
||||
[[ -f /var/run/reboot-required ]] && reboot="true"
|
||||
elif command -v dnf >/dev/null 2>&1; then
|
||||
manager="dnf"
|
||||
# check-update exits 100 when there are updates, 0 when none, 1 on an error. --cacheonly: never goes to the network from here.
|
||||
out=$(LC_ALL=C timeout 120 dnf -q check-update --cacheonly 2>/dev/null) || status=$?
|
||||
if [[ "$status" -eq 0 || "$status" -eq 100 ]]; then
|
||||
count=$(awk 'NF >= 3 && $1 ~ /^[A-Za-z0-9_.+-]+\.[A-Za-z0-9_]+$/ && /Obsoleting/ == 0 { n++ } /^Obsoleting/ { exit } END { print n + 0 }' <<<"$out")
|
||||
security=$(LC_ALL=C timeout 120 dnf -q updateinfo list --security --cacheonly 2>/dev/null | grep -c '/Sec\.' || true)
|
||||
fi
|
||||
if command -v needs-restarting >/dev/null 2>&1; then
|
||||
needs-restarting -r >/dev/null 2>&1 || reboot="true"
|
||||
fi
|
||||
elif command -v zypper >/dev/null 2>&1; then
|
||||
manager="zypper"
|
||||
if out=$(LC_ALL=C timeout 120 zypper -q --no-refresh list-updates 2>/dev/null); then
|
||||
count=$(grep -c '^v |' <<<"$out" || true)
|
||||
fi
|
||||
[[ -f /run/reboot-needed ]] && reboot="true"
|
||||
fi
|
||||
|
||||
if [[ -n "$manager" && "$count" =~ ^[0-9]+$ ]]; then
|
||||
[[ "$security" =~ ^[0-9]+$ ]] || security="null"
|
||||
UPDATES_JSON=$(jq -n --arg manager "$manager" --argjson count "$count" --argjson security "$security" --argjson reboot "$reboot" \
|
||||
'{manager: $manager, count: $count, security: $security, reboot_required: $reboot}')
|
||||
fi
|
||||
}
|
||||
|
||||
collect_system_info() {
|
||||
local ip_json="[]"
|
||||
if command -v ip >/dev/null 2>&1; then
|
||||
@@ -243,7 +283,12 @@ collect_system_info() {
|
||||
')
|
||||
fi
|
||||
|
||||
# Best-effort like the rest: a package manager that misbehaves must not cost the report.
|
||||
UPDATES_JSON="null"
|
||||
collect_updates || UPDATES_JSON="null"
|
||||
|
||||
SYSTEM_JSON=$(jq -n \
|
||||
--argjson updates "$UPDATES_JSON" \
|
||||
--argjson ip_addresses "$ip_json" \
|
||||
--argjson listening_ports "$ports_json" \
|
||||
--arg cpu_model "$cpu_model" \
|
||||
@@ -257,7 +302,8 @@ collect_system_info() {
|
||||
cpu: { model: $cpu_model, cores: $cpu_cores, load_percent: $cpu_load_percent },
|
||||
memory: { total_bytes: $mem_total_bytes, used_bytes: $mem_used_bytes },
|
||||
disks: $disks,
|
||||
listening_ports: $listening_ports
|
||||
listening_ports: $listening_ports,
|
||||
updates: $updates
|
||||
}')
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user