This script is used to control server power according to status of critical services:
- qBittorrent Nox
- SMB connections
- SSH connections
These scripts require :
Script is written in python3, to work properly it need interpreter and dependencies
sudo apt-get update && sudo apt-get install python3 python3-pip curl nano
Script is writen to check output of TCPdump and inotifywait:
opkg update && opkg install tcpdump inotifywait
Those oneliners below download needed dependencies and setting them up:
curl -k -L 'https://raw.githubusercontent.com/emilwojcik93/server_monitor/main/autoinstall-server_check.sh' -o "/tmp/autoinstall.sh" && chmod 755 "/tmp/autoinstall.sh" && /tmp/autoinstall.sh && rm /tmp/autoinstall.sh
opkg update && opkg install curl && curl -k -L 'https://raw.githubusercontent.com/emilwojcik93/server_monitor/main/autoinstall-server_start.sh' -o "/tmp/autoinstall.sh" && chmod 755 "/tmp/autoinstall.sh" && /tmp/autoinstall.sh && rm /tmp/autoinstall.sh
This script is written to execute as systemd-service. To configure it properly please follow above steps:
- Download script to location
/opt/server_check.py
sudo curl -k -L 'https://raw.githubusercontent.com/emilwojcik93/server_monitor/main/server_check.py' -o "/opt/server_check.py" && sudo chmod 755 "/opt/server_check.py"
-
Create systemd service by executing following commnad from root user:
Please change value of arguments
<user>
and<pass>
inExecStart
(line 8)
sudo curl -k -L 'https://raw.githubusercontent.com/emilwojcik93/server_monitor/main/server_check.service' -o "/lib/systemd/system/server_check.service"
- Enable and start systemd-service by:
sudo systemctl daemon-reload
sudo systemctl enable server_check.service
sudo systemctl start server_check.service
sudo systemctl status server_check.service
- Download script to location
/bin/server-start.sh
curl -k -L 'https://raw.githubusercontent.com/emilwojcik93/server_monitor/main/openwrt/server-start.sh' -o "/bin/server-start.sh" && chmod 755 "/bin/server-start.sh"
- Create init.d service by executing following commnad:
curl -k -L 'https://raw.githubusercontent.com/emilwojcik93/server_monitor/main/openwrt/server-start' -o "/etc/init.d/server-start" && chmod 755 "/etc/init.d/server-start"
- Enable and start systemd-service by:
/etc/init.d/server-start start && \
/etc/init.d/server-start enable && \
ps | grep server-start | grep -v grep