From c579b265b15b601f0df9e6bd1c97d1708fa006b2 Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Wed, 6 Dec 2023 17:12:56 -0600 Subject: [PATCH] update --- defaults.inc | 18 ------------------ inc/status.inc | 19 ++++++------------- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/defaults.inc b/defaults.inc index 6f9759f0..e209a2ec 100755 --- a/defaults.inc +++ b/defaults.inc @@ -206,24 +206,6 @@ DISP_HEADER(){ 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(){ [ "${PUSHOVER_USER_TOKEN}" != "" ] && PUSH_TO_MOBILE "${2} diff --git a/inc/status.inc b/inc/status.inc index 07bdd464..c8414682 100755 --- a/inc/status.inc +++ b/inc/status.inc @@ -3,11 +3,8 @@ STATUS(){ start=`date +%s` PRI_CW=40; - ST_ACTION=${1} - if [ "${ST_ACTION}" = "sync" ]; then - ST_ACTION=repl - fi + [ "${ST_ACTION}" = "sync" ] && ST_ACTION=repl declare -i cw; declare -i spc1; declare -i c ntypesel="" @@ -18,18 +15,14 @@ STATUS(){ break fi done - if [ "${ntypesel}" != "" ]; then - ntypesel=(${ntypesel}) - else - ntypesel=(${NM_NODE_TYPES[@]}) - fi + [ "${ntypesel}" != "" ] && ntypesel=(${ntypesel}) || ntypesel=(${NM_NODE_TYPES[@]}) ############################ ## REPLICATION CHECK SETUP ############################ # 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 echo -en "${idsCL[LightCyan]}Setting up replication checks ... ${idsCL[Default]}" fi @@ -45,7 +38,7 @@ STATUS(){ ######################## ## 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') 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}" == "repl" ]; then + if [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "all" ]; then if [ "${ST_ACTION}" != "check" ]; then echo -e "${idsST[Bold]}"; DIVIDER 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 ########################## # 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 echo -en "${idsCL[LightCyan]} Cleaning up status checks... ${idsCL[Default]}" fi