Giter Club home page Giter Club logo

heartbeep's Introduction

heartbeep - minimum viable heartbeat

Minimalistic Go tool to periodically check the availability of a remote machine over TCP.

Intended use is for remote machines on a local network, and with systemd's timers to do this loop on repeat.

Usage

$ ./heartbeep -ip=8.8.8.8 -port=53 && echo "success!"         # returns status code 0 silently on success.
success!

$ ./heartbeep -ip=10.0.0.2 -port=22 && echo "success!"        # returns status code 1. no success.
2023/09/20 20:41:24 Machine 10.0.0.2 on port 22 is down!

To integrate heartbeep with systemd for consistent periodic checks (this example uses 10.0.0.2 on port 22):

  1. Create a systemd service file /etc/systemd/system/heartbeep-monitor.service:
[Unit]
Description=Heartbeep Monitor for 10.0.0.2

[Service]
Type=oneshot
ExecStart=/path/to/heartbeep -ip=10.0.0.2 -port=22
  1. Create a timer file /etc/systemd/system/heartbeep-monitor.timer:
[Unit]
Description=Run Heartbeep monitoring every second

[Timer]
OnBootSec=10
OnUnitActiveSec=1
Unit=heartbeep-monitor.service

[Install]
WantedBy=timers.target
  1. Activate and start the timer:
sudo systemctl daemon-reload
sudo systemctl enable heartbeep-monitor.timer
sudo systemctl start heartbeep-monitor.timer

How to build it

Requires Go.

  1. Clone the repository:
git clone https://github.com/hiAndrewQuinn/heartbeep.git
cd heartbeep
  1. Build the binary.

    • To build the heartbeep binary normally:

      go build -o heartbeep heartbeep.go
    • If you want a fully static binary, aka something you can sftp up to a Unix server and just go:

      CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' -o heartbeep heartbeep.go

      This ensures that the binary doesn't depend on any shared libraries on the system, making it highly portable.

License

This project is released under the Creative Commons Zero v1.0 Universal, allowing for maximum flexibility for end users.

heartbeep's People

Contributors

hiandrewquinn avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.