add check_apt_update

This commit is contained in:
Ludovic Cartier
2026-05-22 19:29:32 +02:00
parent 0ca06f7f32
commit affd0964f4
3 changed files with 28 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
#
# Usage: /usr/lib/nagios/plugins/check_apt_update
# Nagios Exit Codes
OK=0
WARNING=1
CRITICAL=2
UNKNOWN=3
OUTPUT=$(sudo apt -o APT::Update::Error-On-NoReleaseUrls=true -q -y update 2>&1)
EXIT_CODE=$?
if [ $EXIT_CODE -eq 0 ] && [[ ! "$OUTPUT" =~ "W:" ]]; then
echo "OK - apt update completed successfully."
exit $OK
else
CLEAN_OUTPUT=$(echo "$OUTPUT" | grep -E "(E:|W:)" | head -n 1)
if [ -z "$CLEAN_OUTPUT" ]; then
CLEAN_OUTPUT=$(echo "$OUTPUT" | head -n 2 | tr '\n' ' ')
fi
echo "WARNING - Issue during apt update | ${CLEAN_OUTPUT}"
exit $WARNING
fi
+1
View File
@@ -22,6 +22,7 @@ command[check_systemd_failed]=/usr/lib/nagios/plugins/check_systemd_failed
command[check_needrestart]=/usr/lib/nagios/plugins/check_needrestart command[check_needrestart]=/usr/lib/nagios/plugins/check_needrestart
command[check_reboot_required]=/usr/lib/nagios/plugins/check_reboot_required command[check_reboot_required]=/usr/lib/nagios/plugins/check_reboot_required
command[check_ntp_time]=/usr/lib/nagios/plugins/check_ntp_time -H {{ nrpe_ntp_host }} -w {{ nrpe_ntp_warning }} -c {{ nrpe_ntp_critical }} command[check_ntp_time]=/usr/lib/nagios/plugins/check_ntp_time -H {{ nrpe_ntp_host }} -w {{ nrpe_ntp_warning }} -c {{ nrpe_ntp_critical }}
command[check_apt_update]=/usr/lib/nagios/plugins/check_apt_update
# disk # disk
# -w <%>: Warning threshold for block usage. # -w <%>: Warning threshold for block usage.
+1
View File
@@ -2,6 +2,7 @@ nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/check_postfix_mailqueue -w {{
nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/check_exim_mailqueue -w {{ nrpe_mailq_warning }} -c {{ nrpe_mailq_critical }} nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/check_exim_mailqueue -w {{ nrpe_mailq_warning }} -c {{ nrpe_mailq_critical }}
nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/check_raid nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/check_raid
nagios ALL=(ALL) NOPASSWD: /usr/sbin/needrestart -b -l nagios ALL=(ALL) NOPASSWD: /usr/sbin/needrestart -b -l
nagios ALL=(ALL) NOPASSWD: /usr/bin/apt -o APT\:\:Update\:\:Error-On-NoReleaseUrls=true -q -y update
{% if nrpe_kubernetes_controlplane is defined %} {% if nrpe_kubernetes_controlplane is defined %}
nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/check_cilium_health nagios ALL=(ALL) NOPASSWD: /usr/lib/nagios/plugins/check_cilium_health