The script notifies in Telegram when the server resources exceed the specified threshold values for CPU, RAM and Disk. To install, just run the script and enter telegram_bot_token
and chat_id
of the group where you want to send notifications
source <(curl -s https://raw.githubusercontent.com/NodersUA/monitoring/main/setup.sh)
How to get Telegram bot API token
If you want to change the threshold values then edit the config.conf
file in the monitoring
directory
nano ~/monitoring/config.conf
You can also change the threshold values with commands
sed -i 's/CPU_THRESHOLD = .*/CPU_THRESHOLD = 80/g' ~/monitoring/config.conf
sed -i 's/RAM_THRESHOLD = .*/RAM_THRESHOLD = 80/g' ~/monitoring/config.conf
sed -i 's/DISC_THRESHOLD = .*/DISC_THRESHOLD = 80/g' ~/monitoring/config.conf
You can also turn notifications on or off with commands
# On notifications
sed -i 's/CPU_NOTIFICATION = .*/CPU_NOTIFICATION = True/g' ~/monitoring/config.conf
sed -i 's/RAM_NOTIFICATION = .*/RAM_NOTIFICATION = True/g' ~/monitoring/config.conf
sed -i 's/DISC_NOTIFICATION = .*/DISC_NOTIFICATION = True/g' ~/monitoring/config.conf
# Off notifications
sed -i 's/CPU_NOTIFICATION = .*/CPU_NOTIFICATION = False/g' ~/monitoring/config.conf
sed -i 's/RAM_NOTIFICATION = .*/RAM_NOTIFICATION = False/g' ~/monitoring/config.conf
sed -i 's/DISC_NOTIFICATION = .*/DISC_NOTIFICATION = False/g' ~/monitoring/config.conf
# Check logs
journalctl -u alertd -f -o cat
# Restart
systemctl restart alertd
# Stop
systemctl stop alertd
cp ~/monitoring/config.conf ~/config_temp.conf
systemctl stop alertd && cd ~/monitoring
git fetch && git reset --hard
git pull
mv -f ~/config_temp.conf ~/monitoring/config.conf
pip install -r requirements.txt
systemctl start alertd
systemctl stop alertd
rm /etc/systemd/system/alertd.service
rm -rf $HOME/monitoring
# Rename your server
sudo nano /etc/hostname
# Replace all the old names in the file with the new ones
sudo nano /etc/hosts
sudo reboot