add check_systemd_service, update service files, other minor adjustments
This commit is contained in:
parent
85c6156f97
commit
87d752780a
|
@ -12,7 +12,7 @@ from checker.types import try_int
|
||||||
## MySQL User Setup ##
|
## MySQL User Setup ##
|
||||||
|
|
||||||
Attention: The DB-user you type in must have CLIENT REPLICATION rights on the DB-server. Example:
|
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:
|
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';
|
GRANT REPLICA MONITOR ON *.* TO 'nagios'@'monitoringhost' IDENTIFIED BY 'secret';
|
||||||
|
@ -25,7 +25,7 @@ Warning deviation = 10%
|
||||||
Critical deviation = 15%
|
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.
|
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.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ from proxmoxer import ProxmoxAPI, ResourceException
|
||||||
|
|
||||||
import checker.nagios as nagios
|
import checker.nagios as nagios
|
||||||
from checker.markdown import list_to_markdown_table
|
from checker.markdown import list_to_markdown_table
|
||||||
|
from checker.result import quit_check
|
||||||
from checker.units import filesize
|
from checker.units import filesize
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='Check the Proxmox API for network traffic for a host.')
|
parser = argparse.ArgumentParser(description='Check the Proxmox API for network traffic for a host.')
|
||||||
|
@ -142,6 +143,9 @@ def main():
|
||||||
continue
|
continue
|
||||||
check_data[metric]['value'] = avg
|
check_data[metric]['value'] = avg
|
||||||
|
|
||||||
|
if not avg:
|
||||||
|
quit_check('no data', nagios.STATE_UNKNOWN)
|
||||||
|
|
||||||
if metrics_levels[metric]['type'] == 'filesize':
|
if metrics_levels[metric]['type'] == 'filesize':
|
||||||
check_data[metric]['value_str'] = filesize(avg)
|
check_data[metric]['value_str'] = filesize(avg)
|
||||||
check_data[metric]['value'] = f'{int(avg)}B'
|
check_data[metric]['value'] = f'{int(avg)}B'
|
||||||
|
|
|
@ -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
|
|
@ -7,7 +7,8 @@ Requires=icinga2.service icinga-director.service
|
||||||
User=flask
|
User=flask
|
||||||
ExecStart=/opt/venvs/icinga2/icinga2_checks/bin/python3 /opt/icinga2-checks/Other/fail-overdue.py --password XXXXX --insecure
|
ExecStart=/opt/venvs/icinga2/icinga2_checks/bin/python3 /opt/icinga2-checks/Other/fail-overdue.py --password XXXXX --insecure
|
||||||
SyslogIdentifier=failoverdue
|
SyslogIdentifier=failoverdue
|
||||||
Restart=always
|
Restart=on-failure
|
||||||
|
RestartSec=5s
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
@ -9,7 +9,8 @@ Environment="ICINGA2KUMA_ICINGA2_PW=[your icinga2 API password]"
|
||||||
WorkingDirectory=/opt/icinga2-checks/Other
|
WorkingDirectory=/opt/icinga2-checks/Other
|
||||||
ExecStart=/opt/venvs/icinga2/icinga2_checks/bin/gunicorn -b 0.0.0.0:8081 -w 4 icinga2kuma:app
|
ExecStart=/opt/venvs/icinga2/icinga2_checks/bin/gunicorn -b 0.0.0.0:8081 -w 4 icinga2kuma:app
|
||||||
SyslogIdentifier=icinga2kuma
|
SyslogIdentifier=icinga2kuma
|
||||||
Restart=always
|
Restart=on-failure
|
||||||
|
RestartSec=5s
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
Loading…
Reference in New Issue