Skip to content

Instantly share code, notes, and snippets.

@blockpane
Created September 16, 2021 18:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blockpane/cd7644a347379696f41e8cc51b7a92e5 to your computer and use it in GitHub Desktop.
Save blockpane/cd7644a347379696f41e8cc51b7a92e5 to your computer and use it in GitHub Desktop.
monit checks for osmosis
#!/bin/bash
PROMETHEUS=http://localhost:26660
NUM_PEERS=$(curl -s ${PROMETHEUS}/stats |grep 'p2p_peers{' |awk '{print $NF}')
# if we can't connect don't alarm, that is done in another check.
[ -z $NUM_PEERS ] && exit 0
if [ $NUM_PEERS -eq 0 ] ; then
echo NO PEERS ARE CONNECTED
exit 1
fi
echo $NUM_PEERS peers are connected.
exit 0
# /etc/monit/conf.d/osmosis.conf
check process osmosisd matching osmosisd
start program = "/usr/bin/systemctl start osmosisd.service"
restart program = "/usr/bin/systemctl restart osmosisd.service"
stop program = "/usr/bin/systemctl stop osmosisd.service"
check host osmosisd-syncing with address 127.0.0.1
if failed
port 26657 protocol http
request /status with content = '"catching_up": false'
then alert
depends on osmosisd
check program osmosisd-peers with path "/etc/monit/scripts/no-peers.sh"
restart program = "/usr/bin/systemctl restart osmosisd.service"
if status != 0 then alert
IF status != 0 FOR 2 CYCLES THEN RESTART
depends on osmosisd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment