1 sgmon -- Simple stargrave's monitoring system
2 Intended for my own personal use, as a replacement for Monit.
3 All of that is just an ordinary plain POSIX shell scripts.
5 Create some directory hierarchy for convenience:
7 $ mkdir -p probes/example.com/{ping4,ping6,http}
8 $ mkdir -p probes/jails/foobar
10 Make probes from them:
12 $ cat > probes/example.com/ping4/run <<EOF
14 "$SGMONDIR"/helper/http http://example.com/ Some.Expected.Title
16 # only 3 failures will generated notification email
17 $ echo 3 > probes/example.com/http/max-attempts
19 $ cat > probes/example.com/ping4/run <<EOF
21 "$SGMONDIR"/helper/ping 4 example.com
24 $ cat > probes/example.com/ping6/run <<EOF
26 "$SGMONDIR"/helper/ping 6 example.com
28 $ echo 5 > probes/example.com/ping4/period # every 5 seconds
30 $ cat > probes/jails/foobar/run <<EOF
32 jls -j foobar-jail-name
35 Set default configuration values:
38 NOTIFY_EMAIL=user+sgmon@example.com
42 You can run probe individually for testing:
44 $ cd probes/example.com/ping6
45 $ /path/to/sgmon/run.sh
48 Or start all of them in background:
51 $ /path/to/sgmon/start.sh
53 Send signal to that script and it will exit when all probes will die.
54 It is advisable to run it under daemontools'es supervise utility for
57 run.sh creates temporary directory for each probe and links it to
58 $probe/state. Also $probe/pid file is created there. run-script expects
59 that it is run from the $probe directory, there is state/, where it can
60 store its temporary files. $SGMONDIR are also always set $SGMONSRV.
62 You can remove all pid-files and state/-directories with clear.sh.
64 Generate HTML page with information about state of all services and
68 $ /path/to/sgmon/status.sh > /path/to/index.html
70 If some probe is failed, then email message with its stdout/stderr will
71 be sent. If it succeeds after the fail, then another message is sent.
72 Each startup and shutdown are also notified by email.