#!/bin/bash # space-delimited list of services to check servicelist=(corosync) echo -e "\n" echo -e "$(tput smul)Service Check$(tput sgr0)\n" for service in ${servicelist[@]}; do echo -e "${service}:" systemctl status $service | grep Active: | tr -s [:blank:] echo done echo #Sections: Rows: # Cluster information 4 # Quorum information 6 (5 necessary) # Votequorum information 5 # Membership information 4 colover=30 function uplines { [ -z $1 ] && return lines=$1 while [ $lines -gt 0 ]; do tput cuu1 let lines=lines-1 done } statcmd='pvecm status' currentrow='Cluster information' linec=0 while read -r line; do if [[ "$currentrow" == "Cluster information" ]]; then if [[ "$line" == "Quorum information" ]]; then currentrow="$line" linec=0 continue fi echo $line fi if [[ "$currentrow" == "Quorum information" ]]; then if [[ "$line" == "Votequorum information" ]]; then currentrow="$line" linec=0 echo $line continue fi if [[ "$line" == "Date"* ]]; then continue fi if [ $linec -eq 0 ]; then uplines 7; tput cuf $colover; echo -e "$currentrow" fi tput cuf $colover echo $line let linec=linec+1 fi if [[ "$currentrow" == "Votequorum information" ]]; then if [[ "$line" == "Membership information" ]]; then currentrow="$line" linec=0 continue fi echo $line fi if [[ "$currentrow" == "Membership information" ]]; then if [ $linec -eq 0 ]; then uplines 8; tput cuf $colover; echo -e "$currentrow" fi tput cuf $colover echo $line let linec=linec+1 fi done <<< $($statcmd) echo echo echo "$(tput sitm)run the $(basename $0) script in $(dirname $0) to get these stats again$(tput sgr0)" echo