Created
May 28, 2025 21:01
-
-
Save ilyaevseev/00ba6eaf9613a7e0fa4cd591ced7cc2e to your computer and use it in GitHub Desktop.
Cassandra NoSQL quick+dirty watchdog script
This file contains hidden or 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
#!/bin/sh | |
test "$(systemctl is-active cassandra)" = "active" || exit 0 | |
pid="$(systemctl show -p MainPID --value cassandra)" | |
test "$pid" = "" && exit 0 | |
test "$pid" = "0" && exit 0 | |
UPTIME="$(ps -o etimes:1 --no-headers -p $pid)" | |
test "$UPTIME" = "" && exit 0 | |
test "$UPTIME" -lt "600" && exit 0 | |
ACTIVE="$(timeout 20 nodetool -Dcom.sun.jndi.rmiURLParsing=legacy info | egrep -c 'active *: true')" | |
test "$ACTIVE" -ge 3 && exit 0 | |
logger -p user.notice -t "${0##*/}" -- "restart" | |
systemctl restart cassandra | |
## END ## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment