Skip to content

Instantly share code, notes, and snippets.

@sebastiandeutsch
Created November 28, 2020 13:49
Show Gist options
  • Save sebastiandeutsch/16e4a463bcfafe1595da60aa056ad683 to your computer and use it in GitHub Desktop.
Save sebastiandeutsch/16e4a463bcfafe1595da60aa056ad683 to your computer and use it in GitHub Desktop.
ETH2 Telegram Stuff
[Unit]
Description=Ethereum go client
After=network.target
Wants=network.target
OnFailure=unit-status-telegram@geth.service
StartLimitBurst=5
StartLimitIntervalSec=33
[Service]
User=goeth
Group=goeth
Type=simple
Restart=always
RestartSec=5
ExecStart=geth --http --cache 4096 --datadir /var/lib/goethereum
[Install]
WantedBy=default.target
export TELEGRAM_KEY="..."
export CHAT_ID=12345
[Unit]
Description=Lighthouse Beacon Node
Wants=network-online.target
After=network-online.target
OnFailure=unit-status-telegram@lighthousebeacon.service
StartLimitBurst=5
StartLimitIntervalSec=33
[Service]
Type=simple
User=lighthousebeacon
Group=lighthousebeacon
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/lighthouse bn --network mainnet --staking --metrics --datadir /var/lib/lighthouse --eth1-endpoint http://127.0.0.1:8545
[Install]
WantedBy=multi-user.target
[Unit]
Description=Lighthouse Validator
Wants=network-online.target
After=network-online.target
OnFailure=unit-status-telegram@lighthousevalidator.service
StartLimitBurst=5
StartLimitIntervalSec=33
[Service]
Type=simple
User=lighthousevalidator
Group=lighthousevalidator
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/lighthouse vc --network mainnet --datadir /var/lib/lighthouse --graffiti "https://eth2.9elements.com"
[Install]
WantedBy=multi-user.target
#!/bin/bash
source /etc/telegram/key
URL="https://api.telegram.org/bot$TELEGRAM_KEY/sendMessage"
curl -s -d "chat_id=$CHAT_ID&disable_web_page_preview=1&text=$1" $URL > /dev/null
#!/bin/bash
UNIT=$1
UNITSTATUS=$(systemctl status $UNIT)
ALERT=$(echo -e "\u26A0")
telegram "$ALERT Unit failed $UNIT $ALERT
Status:
$UNITSTATUS"
[Unit]
Description=Unit Status Telegram Service
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/unit-status-telegram %i
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment