Crates.io | pingkeeper |
lib.rs | pingkeeper |
version | 3.2.0 |
source | src |
created_at | 2020-04-17 12:57:31.573161 |
updated_at | 2020-04-19 17:14:16.53385 |
description | Command line application that monitorizes that network is reachable (direct tcp connection or ping) and, in case of failure, runs a command. Optionally it can monitor that the command is permanently running and restart it if network is unreachable. |
homepage | https://github.com/ignlg/pingkeeper |
repository | https://github.com/ignlg/pingkeeper |
max_upload_size | |
id | 231121 |
size | 229,092 |
Command line application that monitorizes the exit status of a check command and, in case of failure, runs another main command. Optionally it can monitor that the provided main command is permanently running, triggering a restart (kill & run) if check command fails.
Primarily intended for checking if network is reachable (direct tcp connection or ping), current releases can do much more with the addition of custom check and kill commands.
Proudly made from Barcelona with Rust 🦀.
Three options:
If you already have cargo
installed, use:
cargo install pingkeeper
Download release binaries from releases page.
Check the integrity of the downloaded file (version may differ):
sha512sum --check pingkeeper-macos-v3.2.0.tar.gz.sha512
It should say: pingkeeper-macos-v3.2.0.tar.gz: OK
Extract archive (version may differ) with:
tar xvf pingkeeper-macos-v3.2.0.tar.gz
Check the integrity of the binary file with:
sha512sum --check pingkeeper.sha512
It should say: pingkeeper: OK
Copy pingkeeper
binary file to somewhere within your $PATH
, ie: /usr/local/bin
.
This requires the stable version of rust
& cargo
installed. Visit Rust website for more information.
Run this command:
cargo build --release
You will find your executable at ./target/release/pingkeeper
.
Keep your vpn connection alive using OpenVPN:
sudo pingkeeper -k "openvpn /home/user/vpn_configuration.ovpn"
Keep your vpn connection alive using Hummingbird without any logging:
sudo pingkeeper --keep-alive --quiet "hummingbird denmark.ovpn"
Send an email to your boss when your network is down, using ping as test:
pingkeeper --use-ping "mail -s \"Sorry, my network is down. I will be right back asap.\" myboss@example.com < /dev/null"
Send yourself a pushbullet-cli message when your home server seems down, using ping as test:
pingkeeper --hosts "192.168.1.50" --use-ping "pb push \"Is home server down?\""
Tweet when your opentracker bittorrent tracker server seems down, using t:
pingkeeper --hosts "10.1.1.28:6969" "t update \"Dear users, the tracker is currently down :(\""
Run your own script when the damn wifi seems down again:
pingkeeper "/home/user/try_reset_router.sh"
Shutdown server when the canary file is missing:
sudo pingkeeper --check-cmd "cat /root/canary.txt" --kill-cmd "echo" "shutdown -h now"
Help available running pingkeeper --help
:
USAGE:
pingkeeper [FLAGS] [OPTIONS] <COMMAND>
FLAGS:
-h, --help
Prints help information
-k, --keep-alive
Keep <COMMAND> alive.
Run <COMMAND> on start, also restart it when it dies.
-q, --quiet
Do not output anything from <COMMAND> output, also reduces `-v` by one
-P, --use-ping
Use `ping` to check connection.
Use system's `ping` command to check network connection.
-V, --version
Prints version information
-v
Verbosity, -v -vv -vvv.
Log levels: 0 = error, 1 = warning, 2 = info, 3 = debug.
OPTIONS:
--check-cmd <check-cmd>
Use custom command to check
Check network or something else. This will trigger the execution / kill flow as if it was a network check.
Example: --check-cmd "cat canary.txt"
-H, --hosts <hosts>
Space separated list of addresses or hosts (ping).
For direct connection: List of IPv4 and IPv6, with or without port.
For ping: List of hosts.
Order does not matter, list will be shuffled. [default: 8.8.8.8 8.8.6.6 1.1.1.1 1.0.0.1]
--kill-cmd <kill-cmd>
Use custom command to kill
Example: --kill-cmd "echo \"My baby shot me down\" >> bang_bang.log"
-m, --max-errors <max-errors>
Maximum number of <COMMAND> errors in a row.
0 for infinite. Only used by `--keep-alive`. [default: 0]
-n, --network-every <n>
Network check delay, in seconds.
Check network again after this amount of seconds from the latest success. [default: 5]
--ping-opt <opts>
Options for `ping` command, requires `--use-ping` [default: -c1]
-p, --port <port>
Default port to connect, ignored if `--use-ping`.
Port to connect if host does not have a port specified. [default: 53]
-w, --wait-after-exec <seconds>
Execution delay, in seconds.
Seconds to check network for the first time after executing <COMMAND>. [default: 5]
-s, --signal <signal>
Signal to kill <COMMAND>.
Could be any unix signal: `SIGINT`, `SIGTERM`, etc. [default: SIGINT]
-t, --timeout <timeout>
Timeout in seconds, ignored if `--use-ping` [default: 2]
ARGS:
<COMMAND>
Command to run
--kill-cmd
, custom kill command.--check-cmd
, custom check command.-v
.--hosts
.--use-ping
, use system ping instead of direct connection.-t --timeout
, seconds waiting for network connection.--max-errors
, number of keep-alive errors allowed in a row to keep running.--boot-time
--wait-after-exec
.--check-time
--ping-every
.--signal
; default: "SIGINT"
.--hosts
; default: "8.8.8.8 8.8.6.6 1.1.1.1 1.0.0.1"
.--ping-opt
, ping options; default: "-c1"
.--boot-time
, seconds wait to check network after command; default: 5
.--check-time
, network check delay in seconds; default: 5
.--keep-alive
, run command on init and restart on command exit.-v --verbose
, show log.-q --quiet
, hide stdout/stderr from subcommand.--disable-notifications
.-f --force
to kill pid and remove pid from proc./var/log
.Pingkeeper Copyright (C) 2020 Ignacio Lago
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.