Added basic Monitoring

This commit is contained in:
Martin Berghaus
2025-03-07 18:28:57 +01:00
parent e782848efd
commit bf19c05148
9 changed files with 486 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
#!/bin/bash
_SERVER="${1:?"FQDN of server missing"}"
_PORT="${2:-"22"}"
_USER="monitoring"
#grep:
# -F Use fixed text, no regexp which has to be interpreted
#cut:
# -d Delimiter, marker where to cut (here ;)
# -f Index of column to show (One based, so there is no -f0)
_RESULT="$(ssh -p "${_PORT}" "${_USER}"@"${_SERVER}" 'systemctl status nginx.service' | grep -F Active: | grep -F running | cut -d';' -f2)"
! [ -z "${_RESULT}" ] && echo "OK#UPTIME:${_RESULT}" || echo "FAIL"

View File

@@ -0,0 +1,9 @@
#!/bin/bash
_SERVER="${1:?"FQDN of server missing"}"
# -4 Use IPv4
# -W SECONDS Wait seconds for an answer
# -c COUNT_VALUE Count of pings being executed
_RESULT="$(ping -4 -W 1 -c 1 "${_SERVER}" | grep "time=" | cut -d'=' -f4)"
! [ -z "${_RESULT}" ] && echo "OK#RTT: ${_RESULT}" || echo "FAIL#PLEASE USE FALLBACK!"

View File

@@ -0,0 +1,13 @@
#!/bin/bash
SERVER="${1:?"FQDN of server missing"}"
FILE="pool-size.txt"
# --connect-timeout SECONDS Maximum time allowed for connection
# -k Allow connections to SSL sites without certs (H)
# -L Follow redirects (H)
# --max-time SECONDS Maximum time allowed for the transfer
# -s Silent mode. Don't output anything
# -f Fail fast with no output on HTTP errors (otherwise no exit-code > 0 on 404)
RESULT="$(curl --connect-timeout 10 --max-time 10 -k -s -f https://$SERVER/monitoring/$FILE || echo WARN#404 on $FILE check HTTPS)"
echo $RESULT

View File

@@ -0,0 +1,17 @@
#!/bin/bash
# --connect-timeout SECONDS Maximum time allowed for connection
# -k Allow connections to SSL sites without certs (H)
# -L Follow redirects (H)
# --max-time SECONDS Maximum time allowed for the transfer
# -s Silent mode. Don't output anything
URL="${1:?"URL missing"}"
RESULTS="$(curl --connect-timeout 10 --max-time 10 -k -s "$URL" 2>/dev/null)"
CURTIME="$[ $(date +%s) - 10 * 60 ]"
TIME="$(echo "$RESULTS" | tail -n 1)"
if (echo $TIME | grep -E "[^0-9"] > /dev/null); then echo "FAIL"; exit; fi
RES="$(([ "$CURTIME" -gt "$TIME" ] && echo "TIMEOUT") || (echo "$RESULTS" | head -n 1))"
echo $RES
echo "$RESULTS" | tail -n +2 | head -n -1

View File

@@ -0,0 +1,17 @@
#!/bin/bash
_URL="${1:?"URL of site missing"}"
#curl:
# --connect-timeout SECONDS Maximum time allowed for connection
# -k Allow connections to SSL sites without certs (H)
# -L Follow redirects (H)
# --max-time SECONDS Maximum time allowed for the transfer
# -s Silent mode. Don't output anything
# --head Show head information only
# --no-progress-meter Clean output for grep
#grep:
# -q Quite, no output just status codes
# -F Interpret search term as plain text
((curl --connect-timeout 10 --max-time 10 -k -s --head --no-progress-meter "${_URL}" | grep -qF '200 OK') && echo OK) || echo FAIL