Skip to content

yurt-page/mntr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mntr - Monitor CPU and reboot on high usage

The mntr (monitor) is a SystemD daemon to monitor and watch for a high CPU usage and reboot server. This is sometimes needed as a tool of the last resort when a service used so much CPU that even SSH doesn't work. Rebooting is also clears the TCP connections table so that if you have connection leaks this will help you. The service can send an alert on a high CPU usage and when reboot is triggered.

Install

Debian/Ubuntu

For Ubuntu use PPA repository:

sudo add-apt-repository ppa:stokito/utils
sudo apt update
sudo apt install mntr

Or install by downloading the package:

wget -O /tmp/mntr https://github.com/yurt-page/mntr/releases/download/v1.1.0/mntr_1.1.0_all.deb
sudo dpkg -i /tmp/mntr
rm -f /tmp/mntr

Manual install

sudo cp -r dist/* /
sudo chmod +x /usr/bin/notify.sh
# install service
sudo systemctl daemon-reload
sudo systemctl enable mntr
# Configure (see bellow), start the service and check logs
sudo systemctl restart mntr
journalctl -n 200 -f -u mntr

From sources for development

git clone [email protected]:yurt-page/mntr.git
cd mntr
# install files, service and reload systemd services
sudo make install_all
# reload to test after changes
sudo make restart

Configure

To check CPU count use lscpu.

Edit the /etc/default/mntr to set limits:

# Send notification if only three free CPUs left
ALERT_CPU_LIMIT="-3"
# Hard reboot if load is over the 2 CPUs
REBOOT_CPU_LIMIT="2"

Edit the /etc/default/notify to set Telegram chat for an alert:

TG_BOT_TOKEN=""
TG_CHAT_ID=""

Then restart with sudo systemctl restart mntr.