Skip to content

muhaylosemenyuk/monitoring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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

Install

1. Run the script
source <(curl -s https://raw.githubusercontent.com/NodersUA/monitoring/main/setup.sh)
2. Enter your TELEGRAM_API_KEY

How to get Telegram bot API token

3. Enter your MONITORING_CHAT_ID

How to get a group chat id?

Configuration

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

Useful Commands

# Check logs
journalctl -u alertd -f -o cat
# Restart
systemctl restart alertd
# Stop
systemctl stop alertd

Update

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

Delete

systemctl stop alertd
rm /etc/systemd/system/alertd.service
rm -rf $HOME/monitoring

How to rename your hostname

# 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published