Skip to content

dnullproject/haltoping

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HaltOPing

Halt server on failed ping(s).

Purpose

Due to the mad behavior of my neighbor, I experience power outages nearly every day.

My small UPS cannot handle blackouts lasting several hours, resulting in my home lab servers struggling to maintain operation. To date, this has resulted in the failure of several hard disk drives. Given that my UPS is as unsophisticated as a wine cork, I cannot depend on any form of external automation for assistance.

The most straightforward solution I’ve devised is to continuously ping a specific target—my main router in this instance—and initiate a graceful shutdown of the server if the ping attempts fail.

Warning

Ordinary shutdown is used (without any restart) - this is on purpose. Be aware - you need to have a way to start servers remotely. In my case - I am using Tyua smart outlets (poor-man KVM).

Usage

Manual/one-shot

Only one argument is required: the target to ping.

./haltoping 192.168.1.1

Daemon

Install script as systemd service:

sudo bash install.sh 192.168.1.1

Note

You can re-run install.sh with different target IP, it will reinstall script

This will copy script into /usr/local/bin/haloping, and start it with systemd unit haltoping.service.

# check status with
systemctl status haltoping

# check logs
sudo journalctl -u haltoping

TODO

  • prever situation when server cant recover at the boot (disable autostart?)
  • install as deb package
  • test systemd service
  • pre-commit
  • github templates

Stand With Ukraine

About

Halt 'o' Ping - halt server on failed ping(s)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages