This commit is contained in:
2023-12-06 17:12:56 -06:00
parent 3cd3213d95
commit c579b265b1
2 changed files with 6 additions and 31 deletions

View File

@@ -206,24 +206,6 @@ DISP_HEADER(){
echo echo
} }
CERT-CHECK(){
TARGET="mysite.example.net";
RECIPIENT="hostmaster@mysite.example.net";
DAYS=7;
echo "checking if $TARGET expires in less than $DAYS days";
expirationdate=$(date -d "$(: | openssl s_client -connect $TARGET:443 -servername $TARGET 2>/dev/null \
| openssl x509 -text \
| grep 'Not After' \
|awk '{print $4,$5,$7}')" '+%s');
in7days=$(($(date +%s) + (86400*$DAYS)));
if [ $in7days -gt $expirationdate ]; then
echo "KO - Certificate for $TARGET expires in less than $DAYS days, on $(date -d @$expirationdate '+%Y-%m-%d')" \
| mail -s "Certificate expiration warning for $TARGET" $RECIPIENT ;
else
echo "OK - Certificate expires on $expirationdate";
fi
}
SENDNOTICE(){ SENDNOTICE(){
[ "${PUSHOVER_USER_TOKEN}" != "" ] && PUSH_TO_MOBILE "${2} [ "${PUSHOVER_USER_TOKEN}" != "" ] && PUSH_TO_MOBILE "${2}

View File

@@ -3,11 +3,8 @@ STATUS(){
start=`date +%s` start=`date +%s`
PRI_CW=40; PRI_CW=40;
ST_ACTION=${1} ST_ACTION=${1}
if [ "${ST_ACTION}" = "sync" ]; then [ "${ST_ACTION}" = "sync" ] && ST_ACTION=repl
ST_ACTION=repl
fi
declare -i cw; declare -i spc1; declare -i c declare -i cw; declare -i spc1; declare -i c
ntypesel="" ntypesel=""
@@ -18,18 +15,14 @@ STATUS(){
break break
fi fi
done done
if [ "${ntypesel}" != "" ]; then [ "${ntypesel}" != "" ] && ntypesel=(${ntypesel}) || ntypesel=(${NM_NODE_TYPES[@]})
ntypesel=(${ntypesel})
else
ntypesel=(${NM_NODE_TYPES[@]})
fi
############################ ############################
## REPLICATION CHECK SETUP ## REPLICATION CHECK SETUP
############################ ############################
# if [ "${ST_ACTION}" == "report" ] || [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "check" ] || [ "${ST_ACTION}" == "" ]; then # if [ "${ST_ACTION}" == "report" ] || [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "check" ] || [ "${ST_ACTION}" == "" ]; then
if [ "${ST_ACTION}" == "repl" ]; then if [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "all" ]; then
if [ "${ST_ACTION}" != "check" ]; then if [ "${ST_ACTION}" != "check" ]; then
echo -en "${idsCL[LightCyan]}Setting up replication checks ... ${idsCL[Default]}" echo -en "${idsCL[LightCyan]}Setting up replication checks ... ${idsCL[Default]}"
fi fi
@@ -45,7 +38,7 @@ STATUS(){
######################## ########################
## LOCALHOST CHECK ## LOCALHOST CHECK
######################## ########################
if [ "${ST_ACTION}" = "" ] || [ "${ST_ACTION}" = "report" ] || [ "${ST_ACTION}" = "services" ] || [ "${ST_ACTION}" = "dockers" ] || [ "${ST_ACTION}" = "check" ]; then if [ "${ST_ACTION}" = "" ] || [ "${ST_ACTION}" = "report" ] || [ "${ST_ACTION}" = "services" ] || [ "${ST_ACTION}" = "dockers" ] || [ "${ST_ACTION}" = "check" ] || [ "${ST_ACTION}" == "all" ]; then
cpu_usage=$(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' <(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat) | sed -e 's/%//g') cpu_usage=$(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' <(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat) | sed -e 's/%//g')
if [ ! -z ${LOCAL_SERVICES+x} ] && [ "${ST_ACTION}" != "dockers" ]; then if [ ! -z ${LOCAL_SERVICES+x} ] && [ "${ST_ACTION}" != "dockers" ]; then
@@ -146,7 +139,7 @@ STATUS(){
######################## ########################
# if [ "${ST_ACTION}" == "report" ] || [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "check" ] || [ "${ST_ACTION}" == "" ]; then # if [ "${ST_ACTION}" == "report" ] || [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "check" ] || [ "${ST_ACTION}" == "" ]; then
if [ "${ST_ACTION}" == "repl" ]; then if [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "all" ]; then
if [ "${ST_ACTION}" != "check" ]; then if [ "${ST_ACTION}" != "check" ]; then
echo -e "${idsST[Bold]}"; DIVIDER echo -e "${idsST[Bold]}"; DIVIDER
echo -e "${idsCL[Yellow]} Replication Status Between the Primary and Secondary Nodes${idsCL[Default]}" echo -e "${idsCL[Yellow]} Replication Status Between the Primary and Secondary Nodes${idsCL[Default]}"
@@ -253,7 +246,7 @@ It was down for $(SHOW_TIME $(expr $(date +%s) - $(stat -c %Y ${NM_TMPFOLDER}/${
# REMOVE REPL CHECK FILES # REMOVE REPL CHECK FILES
########################## ##########################
# if [ "${ST_ACTION}" == "report" ] || [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "check" ] || [ "${ST_ACTION}" == "" ]; then # if [ "${ST_ACTION}" == "report" ] || [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "check" ] || [ "${ST_ACTION}" == "" ]; then
if [ "${ST_ACTION}" == "repl" ]; then if [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "all" ]; then
if [ "${ST_ACTION}" != "check" ]; then if [ "${ST_ACTION}" != "check" ]; then
echo -en "${idsCL[LightCyan]} Cleaning up status checks... ${idsCL[Default]}" echo -en "${idsCL[LightCyan]} Cleaning up status checks... ${idsCL[Default]}"
fi fi