Created
July 15, 2020 14:26
-
-
Save miclip/116a3bc70c750f4dcf5a011c13a7d419 to your computer and use it in GitHub Desktop.
BOSH Monit Health Checks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Monit Process Healthcheck for all vm’s in the foundation: | |
for i in `bosh --tty deployments --json | jq -r '.Tables[].Rows[] | .name'`; do echo -e "\033[1;32mDeployment Name: \033[0m" $i; DEPLOYMENT=$i; bosh --tty -d $DEPLOYMENT instances --ps --json | jq '.Tables[].Rows[] | select(.process != "")' | jq -s -r 'group_by(.process_state)[] | .[0].process_state + ": " + (length | tostring)'; echo; bosh --tty -d $DEPLOYMENT instances --ps --json | jq -r '.Tables[].Rows[] | select((.process_state != "running") and .process_state != "") | "\(.instance) \(.process) \(.process_state)"'; echo ;done | |
Memory health check for all vm’s in the foundation: | |
for i in `bosh --tty deployments --json | jq -r '.Tables[].Rows[] | .name'`; do echo -e "\033[1;32mDeployment Name: \033[0m" $i; DEPLOYMENT=$i; bosh --tty -d $DEPLOYMENT instances --vitals --json | jq -r '.Tables[].Rows[] | select(.memory_usage != "") | select((.memory_usage | split("%") | .[0] | tonumber) >= 70) | "Instance: " + .instance + ", Memory: " + .memory_usage' | column -t; echo ;done | |
Ephemeral disk health check: | |
for i in `bosh --tty deployments --json | jq -r '.Tables[].Rows[] | .name'`; do echo -e "\033[1;32mDeployment Name: \033[0m" $i; DEPLOYMENT=$i; bosh --tty -d $DEPLOYMENT instances --vitals --json | jq -r '.Tables[].Rows[] | select(.ephemeral_disk_usage != "") | select((.ephemeral_disk_usage | split("%") | .[0] | tonumber) >= 70) | "Instance: " + .instance + ", Ephemeral Disk Usage: " + .ephemeral_disk_usage' | column -t; echo ;done | |
Persistent disk health check: | |
for i in `bosh --tty deployments --json | jq -r '.Tables[].Rows[] | .name'`; do echo -e "\033[1;32mDeployment Name: \033[0m" $i; DEPLOYMENT=$i; bosh --tty -d $DEPLOYMENT instances --vitals --json | jq -r '.Tables[].Rows[] | select(.persistent_disk_usage != "") | select((.persistent_disk_usage | split("%") | .[0] | tonumber) >= 70) | "Instance: " + .instance + ", Persistent Disk Usage: " + .persistent_disk_usage' | column -t; echo ;done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment