Repository navigation
Expand file tree
/
Copy pathhelp.go
More file actions
115 lines (85 loc) · 4.59 KB
/
Copy pathhelp.go
File metadata and controls
115 lines (85 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
package main
import (
"fmt"
"io"
"strings"
)
// helpText is written so that someone who never opens the README can copy a line
// and have fogping running correctly. Keep every command runnable as printed.
const helpText = `fogping {{VERSION}} — SmokePing-style latency and packet-loss graphs.
One binary with a built-in database and web UI. No config file.
Start it, then open http://<this-server-ip>:8518 in a browser.
Data is kept in ./data under the directory you start it from:
always start it from the same directory.
EXAMPLES
Your first five minutes, step by step:
1. Start it:
./fogping
Open http://<this-server-ip>:8518 in a browser. A demo target
(www.google.com) is already there, so the first graph appears within
a minute. Nothing to log in to yet, and targets cannot be changed.
2. Give it a login. Stop fogping (Ctrl-C) and start it with a user name
and a password — pick your own; "change-me" is only an example:
./fogping user=admin passwd=change-me
3. Add your own targets. Start with --edit, open the web UI and click
"✎ targets". Changes apply at once:
./fogping --edit user=admin passwd=change-me
4. When you are done, stop it and start again WITHOUT --edit (the
step 2 line). The UI is then read-only and safe to share.
Forgot the password? Nothing is stored anywhere: the login exists only
in the line you start with. Just start again with a new passwd=.
More ready-made lines:
Several users (names and passwords are paired by position):
./fogping user=alice,bob passwd=alice-pw,bob-pw
Keep 30 days of history instead of 93 (93 is also the maximum):
./fogping --days=30 user=admin passwd=change-me
Run in the background with a log file, and stop it again:
nohup ./fogping user=admin passwd=change-me >> fogping.log 2>&1 &
pkill -x fogping
Listen on 127.0.0.1 only, when Nginx/Caddy in front of it handles access:
./fogping --localhost
./fogping --localhost --edit
Upgrade: stop it, replace the fogping file, start it again. ./data is kept.
PING TARGETS SHOW 100% LOSS?
This host does not allow ICMP for normal users. Fix it with one of:
# until the next reboot:
sudo sysctl -w net.ipv4.ping_group_range="0 2147483647"
# permanently:
echo 'net.ipv4.ping_group_range = 0 2147483647' | sudo tee /etc/sysctl.d/99-fogping.conf
sudo sysctl --system
# or give this binary the permission (redo after each upgrade):
sudo setcap cap_net_raw+ep ./fogping
TCP targets need nothing.
FLAGS
--edit allow changing targets in the web UI
(refuses to start without user=/passwd= or --localhost)
--localhost listen on 127.0.0.1:8518 instead of all interfaces (0.0.0.0:8518)
--days=N days of history to keep (default 93, max 93)
--version print the version and exit
--probes load external probers from ./probes (docs/PROBE-PROTOCOL.md); off by default
--zabbix serve read-only stats to the Zabbix template (needs a token, see below)
--check check flags, login, tokens, data directory, database, port and
plugins; print a report and exit without starting anything
--gen-token=F write a new random token to file F (owner-only, never printed)
check / gen-token F the pingping spellings of --check / --gen-token=F; both work
user= passwd= turn on the login page (comma-separated lists)
passwd-file=F read the passwords from file F instead, one per line
Flags and user=/passwd= can be given in any order. The port is always 8518.
passwd= on the command line is readable by every account on this machine
(ps) and stays in shell history. To keep it private, put it in the
environment or a file instead:
FOGPING_PASSWD='change-me' ./fogping user=admin
./fogping user=admin passwd-file=/etc/fogping.pw # chmod 600
FOGPING_USER and FOGPING_PASSWD_FILE work the same way.
Optional: --zabbix with FOGPING_ZABBIX_TOKEN (or FOGPING_ZABBIX_TOKEN_FILE,
zabbix-token-file=F) serves a read-only GET /api/stats for the Zabbix
template in zabbix/ of the repository. Without --zabbix nothing changes.
Make the token with: ./fogping --gen-token=/etc/fogping/zabbix.token
then start with: FOGPING_ZABBIX_TOKEN_FILE=/etc/fogping/zabbix.token ./fogping --zabbix
Before restarting a service, ./fogping --check (with the same flags) says
whether it would start, and why not, without touching the running one.
Full guide, systemd unit, reverse proxy: https://github.com/githubflyideas/fogping
`
func printHelp(w io.Writer) {
fmt.Fprint(w, strings.Replace(helpText, "{{VERSION}}", version, 1))
}