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 $ echo '"$SGMONDIR"/helper/http http://example.com/ Some.Expected.Title'
13 > probes/example.com/ping4/run <<EOF
14 # only 3 failures will generated notification email
15 $ echo 3 > probes/example.com/http/max-attempts
17 $ echo '"$SGMONDIR"/helper/ping 4 example.com' > probes/example.com/ping4/run
19 $ echo '"$SGMONDIR"/helper/ping 6 example.com' > probes/example.com/ping6/run
20 $ echo 5 > probes/example.com/ping4/period # every 5 seconds
22 $ cat > probes/jails/foobar/run <<EOF
24 jls -j foobar-jail-name
26 $ chmod +x probes/jails/foobar/run
28 Set default configuration values:
31 NOTIFY_EMAIL=user+sgmon@example.com
35 You can run probe individually for testing:
37 $ cd probes/example.com/ping6
38 $ /path/to/sgmon/run.sh
41 Or start all of them in background:
44 $ /path/to/sgmon/start.sh
46 Send signal to that script and it will exit when all probes will die.
47 It is advisable to run it under daemontools'es supervise utility for
50 run.sh creates temporary directory for each probe and links it to
51 $probe/state. Also $probe/pid file is created there. run-script expects
52 that it is run from the $probe directory, there is state/, where it can
53 store its temporary files. $SGMONDIR are also always set $SGMONSRV.
55 You can remove all pid-files and state/-directories with clear.sh.
57 Generate HTML page with information about state of all services and
61 $ /path/to/sgmon/status.sh > /path/to/index.html
63 If some probe is failed, then email message with its stdout/stderr will
64 be sent. If it succeeds after the fail, then another message is sent.
65 Each startup and shutdown are also notified by email.