Update status.inc

This commit is contained in:
2023-12-06 19:22:21 -06:00
parent 1626f2fed8
commit 00cb61497e

View File

@@ -4,7 +4,7 @@ STATUS(){
PRI_CW=40; PRI_CW=40;
ST_ACTION=${1} ST_ACTION=${1}
[ "${ST_ACTION}" = "sync" ] && ST_ACTION=repl [ "${ST_ACTION}" == "sync" ] && ST_ACTION=repl
declare -i cw; declare -i spc1; declare -i c declare -i cw; declare -i spc1; declare -i c
ntypesel="" ntypesel=""
@@ -21,9 +21,9 @@ STATUS(){
## REPLICATION CHECK SETUP ## REPLICATION CHECK SETUP
############################ ############################
[ ! -f ${NM_TMPFOLDER}/.replcheck ] || [ $(expr $(date +%s) - $(stat -c %Y ${NM_TMPFOLDER}/.replcheck)) -ge 300 ] && REPLRUN=1 || REPLRUN=0 ([ ! -f ${NM_TMPFOLDER}/.replcheck ] || [ $(expr $(date +%s) - $(stat -c %Y ${NM_TMPFOLDER}/.replcheck)) -ge 300 ]) && REPLRUN=1 || REPLRUN=0
# 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" ] || [ "${ST_ACTION}" == "" ] || [ ${REPLRUN} -eq 1 ]; then if [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "" ] || ([ "${ST_ACTION}" == "report" ] && [ ${REPLRUN} -eq 1 ]); 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
@@ -39,7 +39,7 @@ STATUS(){
######################## ########################
## LOCALHOST CHECK ## LOCALHOST CHECK
######################## ########################
if [ "${ST_ACTION}" = "" ] || [ "${ST_ACTION}" = "report" ] || [ "${ST_ACTION}" = "services" ] || [ "${ST_ACTION}" = "dockers" ] || [ "${ST_ACTION}" = "check" ] || [ "${ST_ACTION}" == "all" ]; 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
@@ -140,7 +140,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" ] || [ "${ST_ACTION}" == "" ] || [ ${REPLRUN} -eq 1 ]; then if [ "${ST_ACTION}" == "repl" ] || [ "${ST_ACTION}" == "" ] || ([ "${ST_ACTION}" == "report" ] && [ ${REPLRUN} -eq 1 ]); 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]}"
@@ -254,7 +254,7 @@ It was down for $(SHOW_TIME $(expr $(date +%s) - $(stat -c %Y ${NM_TMPFOLDER}/${
var=${NTYPE}_REPL_CHECK[@] var=${NTYPE}_REPL_CHECK[@]
if [ ! -z ${!var+x} ]; then if [ ! -z ${!var+x} ]; then
for rcheck in "${!var}"; do for rcheck in "${!var}"; do
if [ "${PH_CMD}" = "" ]; then if [ "${PH_CMD}" == "" ]; then
rm -f ${NM_FOLDER}/test.${STATUS_START//-/}.repl & rm -f ${NM_FOLDER}/test.${STATUS_START//-/}.repl &
rm -f ${NM_REPL_CHECK_LOC[${rcheck}]}/test.${STATUS_START//-/}.repl & rm -f ${NM_REPL_CHECK_LOC[${rcheck}]}/test.${STATUS_START//-/}.repl &
else else
@@ -273,8 +273,8 @@ It was down for $(SHOW_TIME $(expr $(date +%s) - $(stat -c %Y ${NM_TMPFOLDER}/${
######################## ########################
## FREE SPACE CHECK ## FREE SPACE CHECK
######################## ########################
#if [ "${ST_ACTION}" = "" ] || [ "${ST_ACTION}" = "report" ] || [ "${ST_ACTION}" = "freespace" ]; then #if [ "${ST_ACTION}" == "" ] || [ "${ST_ACTION}" == "report" ] || [ "${ST_ACTION}" == "freespace" ]; then
if [ "${ST_ACTION}" = "freespace" ]; then if [ "${ST_ACTION}" == "freespace" ]; then
for NTYPE in "${ntypesel[@]}"; do for NTYPE in "${ntypesel[@]}"; do
if [ "${ST_ACTION}" != "check" ]; then if [ "${ST_ACTION}" != "check" ]; then
echo -e "${idsST[Bold]}"; DIVIDER echo -e "${idsST[Bold]}"; DIVIDER
@@ -384,7 +384,7 @@ It was down for $(SHOW_TIME $(expr $(date +%s) - $(stat -c %Y ${NM_TMPFOLDER}/${
######################## ########################
if [ "${ST_ACTION}" != "check" ]; then if [ "${ST_ACTION}" != "check" ]; then
echo echo
if [ -z ${ACTION} ] || [ "${ACTION}" = "gui" ]; then if [ -z ${ACTION} ] || [ "${ACTION}" == "gui" ]; then
DIVIDER true DIVIDER true
ENTER2CONTINUE ENTER2CONTINUE
fi fi
@@ -512,7 +512,7 @@ STATUS_NODE(){
srvctest=${srvctst[$sr]} srvctest=${srvctst[$sr]}
if [ "${srvctest}" != "active" ] && [ "${srvc}" == "mysql" ]; then if [ "${srvctest}" != "active" ] && [ "${srvc}" == "mysql" ]; then
[ "$(${NCMD} systemctl is-active mariadb)" == "active" ] && mysqlgo=true || mysqlgo=false [ "$(${NCMD} systemctl is-active mariadb)" == "active" ] && mysqlgo=true || mysqlgo=false
elif [ "${srvctest}" != "active" ] && [ "${srvc}" = "mariadb" ]; then elif [ "${srvctest}" != "active" ] && [ "${srvc}" == "mariadb" ]; then
[ "$(${NCMD} systemctl is-active mysql)" == "active" ] && mysqlgo=true || mysqlgo=false [ "$(${NCMD} systemctl is-active mysql)" == "active" ] && mysqlgo=true || mysqlgo=false
elif [ "${srvctest}" == "active" ] && ([ "${srvc}" == "mysql" ] || [ "${srvc}" == "mariadb" ]); then elif [ "${srvctest}" == "active" ] && ([ "${srvc}" == "mysql" ] || [ "${srvc}" == "mariadb" ]); then
mysqlgo=true mysqlgo=true
@@ -559,7 +559,7 @@ STATUS_NODE(){
rm -f ${NM_TMPFOLDER}/${nip}~${srvc}.* & rm -f ${NM_TMPFOLDER}/${nip}~${srvc}.* &
fi fi
fi fi
[ "${mysqlgo}" = "true" ] && unset mysqlgo [ "${mysqlgo}" == "true" ] && unset mysqlgo
[ "${SSCHK}" == "primary" ] && echo -e "${idsCL[LightCyan]} - Primary Node${idsCL[Default]}" || echo -e "${idsCL[Default]}" [ "${SSCHK}" == "primary" ] && echo -e "${idsCL[LightCyan]} - Primary Node${idsCL[Default]}" || echo -e "${idsCL[Default]}"
elif [ "${srvc}" == "keepalived" ] && ([ "${nip}" == "10.2.1.2" ] || [ "${nip}" == "10.2.1.51" ]); then elif [ "${srvc}" == "keepalived" ] && ([ "${nip}" == "10.2.1.2" ] || [ "${nip}" == "10.2.1.51" ]); then