mirror of
https://github.com/m8tin/cis.git
synced 2025-12-06 15:58:26 +01:00
Added basic Monitoring
This commit is contained in:
14
script/monitor/checks/GENERIC_NGINX_CHECK.sh
Executable file
14
script/monitor/checks/GENERIC_NGINX_CHECK.sh
Executable 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"
|
||||
9
script/monitor/checks/GENERIC_PING_CHECK.sh
Executable file
9
script/monitor/checks/GENERIC_PING_CHECK.sh
Executable 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!"
|
||||
13
script/monitor/checks/GENERIC_POOL_SIZE_CHECK.sh
Executable file
13
script/monitor/checks/GENERIC_POOL_SIZE_CHECK.sh
Executable 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
|
||||
17
script/monitor/checks/GENERIC_REMOTECHECK
Executable file
17
script/monitor/checks/GENERIC_REMOTECHECK
Executable 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
|
||||
|
||||
|
||||
17
script/monitor/checks/GENERIC_URL_CHECK.sh
Executable file
17
script/monitor/checks/GENERIC_URL_CHECK.sh
Executable 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
|
||||
Reference in New Issue
Block a user