diff --git a/check_mysql_slave.py b/check_mysql_slave.py index 31d34f0..eb9608b 100755 --- a/check_mysql_slave.py +++ b/check_mysql_slave.py @@ -12,7 +12,7 @@ from checker.types import try_int ## MySQL User Setup ## Attention: The DB-user you type in must have CLIENT REPLICATION rights on the DB-server. Example: - GRANT REPLICATION CLIENT on *.* TO 'nagios'@'monitoringhost' IDENTIFIED BY 'secret'; + GRANT REPLICATION CLIENT,SLAVE MONITOR on *.* TO 'nagios'@'monitoringhost' IDENTIFIED BY 'secret'; If you use MariaDB 10.5 or newer, the DB user must have REPLICA MONITOR rights: GRANT REPLICA MONITOR ON *.* TO 'nagios'@'monitoringhost' IDENTIFIED BY 'secret'; @@ -25,7 +25,7 @@ Warning deviation = 10% Critical deviation = 15% This will set the warning levels to 330 and 270 seconds, if the delay is greater or less than these values it will return WARNING. -The critical levels will be 345 and 255 seconds. +The critical levels will be 345 and 255 seconds. """ diff --git a/check_pve_guest_metrics.py b/check_pve_guest_metrics.py index 03783f5..88b5c0f 100755 --- a/check_pve_guest_metrics.py +++ b/check_pve_guest_metrics.py @@ -13,6 +13,7 @@ from proxmoxer import ProxmoxAPI, ResourceException import checker.nagios as nagios from checker.markdown import list_to_markdown_table +from checker.result import quit_check from checker.units import filesize parser = argparse.ArgumentParser(description='Check the Proxmox API for network traffic for a host.') @@ -142,6 +143,9 @@ def main(): continue check_data[metric]['value'] = avg + if not avg: + quit_check('no data', nagios.STATE_UNKNOWN) + if metrics_levels[metric]['type'] == 'filesize': check_data[metric]['value_str'] = filesize(avg) check_data[metric]['value'] = f'{int(avg)}B' diff --git a/check_systemd_service.sh b/check_systemd_service.sh new file mode 100755 index 0000000..2780c7e --- /dev/null +++ b/check_systemd_service.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +function usage { + echo "Usage: + -u [UNIT name] + -t Service is triggered by a timer and is allowed to be inactive" +} + +# Initialize variables +UNIT="" +IS_TIMER=false + +# Parse command line arguments +while getopts "u:t" opt; do + case ${opt} in + u ) + UNIT=$OPTARG + ;; + t ) + IS_TIMER=true + ;; + \? ) + echo "Invalid option: $OPTARG" 1>&2 + exit 1 + ;; + : ) + echo "Invalid option: $OPTARG requires an argument" 1>&2 + exit 1 + ;; + esac +done +shift $((OPTIND -1)) + +# Check if UNIT name is provided +if [ -z "$UNIT" ]; then + usage + exit -1 +fi + +# Check if the unit is enabled +enabled=$(systemctl is-enabled "$UNIT") +if [ "$enabled" != "enabled" ]; then + echo "CRITICAL - $UNIT is not enabled" + exit 2 +fi + +# Check if the unit is active +active=$(systemctl is-active "$UNIT") +substate=$(systemctl show "$UNIT" --property=SubState --value) + +if [ "$active" != "active" ] || { [ "$substate" = "exited" ] && [ "$IS_TIMER" = false ]; }; then + echo "CRITICAL - $UNIT is not active" + exit 2 +fi + +if [ "$IS_TIMER" = true ] && [ "$substate" = "exited" ]; then + echo "OK - $UNIT is active (exited) and enabled" +else + echo "OK - $UNIT is active and enabled" +fi +exit 0 diff --git a/services/failoverdue.service b/services/failoverdue.service index 21c18d7..24e1d56 100644 --- a/services/failoverdue.service +++ b/services/failoverdue.service @@ -7,7 +7,8 @@ Requires=icinga2.service icinga-director.service User=flask ExecStart=/opt/venvs/icinga2/icinga2_checks/bin/python3 /opt/icinga2-checks/Other/fail-overdue.py --password XXXXX --insecure SyslogIdentifier=failoverdue -Restart=always +Restart=on-failure +RestartSec=5s [Install] WantedBy=multi-user.target diff --git a/services/icinga2kuma.service b/services/icinga2kuma.service index 3932bd6..5ab7e45 100644 --- a/services/icinga2kuma.service +++ b/services/icinga2kuma.service @@ -9,7 +9,8 @@ Environment="ICINGA2KUMA_ICINGA2_PW=[your icinga2 API password]" WorkingDirectory=/opt/icinga2-checks/Other ExecStart=/opt/venvs/icinga2/icinga2_checks/bin/gunicorn -b 0.0.0.0:8081 -w 4 icinga2kuma:app SyslogIdentifier=icinga2kuma -Restart=always +Restart=on-failure +RestartSec=5s [Install] WantedBy=multi-user.target