nagios-nrpe: add some information in check_connections_state.sh check

This commit is contained in:
Jérémy Dubois 2022-09-01 14:44:40 +02:00
parent 3878e1bddc
commit 28b946bd47
2 changed files with 5 additions and 4 deletions

View File

@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- base: use a variable to define ntpd server - base: use a variable to define ntpd server
- base: add entry in doas.conf for sd0 in case we have a hard raid - base: add entry in doas.conf for sd0 in case we have a hard raid
- base: add munin files in newsyslog.conf by default - base: add munin files in newsyslog.conf by default
- nagios-nrpe: add some information in check_connections_state.sh check
### Changed ### Changed

View File

@ -5,8 +5,8 @@ MAIN_CONNECTION_PINGABLE_IP="31.170.8.95"
MAIN_CONNECTION_GATEWAY="IP" MAIN_CONNECTION_GATEWAY="IP"
MAIN_CONNECTION_IP="IP" MAIN_CONNECTION_IP="IP"
SECOND_CONNECTION_PINGABLE_IP="31.170.8.243" SECOND_CONNECTION_PINGABLE_IP="31.170.8.243"
INFO_MAIN_CONNECTION="IP - Description" INFO_MAIN_CONNECTION="IP - Description - interface"
INFO_SECOND_CONNECTION="IP - Description" INFO_SECOND_CONNECTION="IP - Description - interface"
CURRENT_GATEWAY=$(/usr/bin/netstat -nr | /usr/bin/grep "default" | /usr/bin/awk '{print $2}') CURRENT_GATEWAY=$(/usr/bin/netstat -nr | /usr/bin/grep "default" | /usr/bin/awk '{print $2}')
IS_GATEWAY_IN_FILE=1 # Check whether /etc/mygate has the IP of main connection IS_GATEWAY_IN_FILE=1 # Check whether /etc/mygate has the IP of main connection
@ -28,7 +28,7 @@ fi
# If main connection is DOWN (used or not) => warning and exit # If main connection is DOWN (used or not) => warning and exit
if /sbin/ping -c1 -w1 ${MAIN_CONNECTION_PINGABLE_IP} >/dev/null 2>&1; then if /sbin/ping -c1 -w1 ${MAIN_CONNECTION_PINGABLE_IP} >/dev/null 2>&1; then
if [ "${CURRENT_GATEWAY}" != "${MAIN_CONNECTION_GATEWAY}" ]; then if [ "${CURRENT_GATEWAY}" != "${MAIN_CONNECTION_GATEWAY}" ]; then
echo "Main connection is UP but not used as gateway !" echo "Main connection is UP (${INFO_MAIN_CONNECTION}) but not used as gateway !"
STATE=2 STATE=2
fi fi
else else
@ -76,7 +76,7 @@ if [ "${IS_MISCELLANEOUS}" = 1 ]; then
fi fi
if [ "${STATE}" = 0 ]; then if [ "${STATE}" = 0 ]; then
echo "OK - Main connection is UP and used, second connection is UP" echo "OK - Main connection is UP and used (${INFO_MAIN_CONNECTION}), second connection is UP (${INFO_SECOND_CONNECTION})"
fi fi
exit ${STATE} exit ${STATE}