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
 
  36 You can run probe individually for testing:
 
  38     $ cd probes/example.com/ping6
 
  39     $ /path/to/sgmon/run.sh
 
  42 Or start all of them in background:
 
  45     $ /path/to/sgmon/start.sh
 
  47 Send signal to that script and it will exit when all probes will die.
 
  48 It is advisable to run it under daemontools'es supervise utility for
 
  51 run.sh creates temporary directory for each probe and links it to
 
  52 $probe/state. run-script expects that it is run from the $probe
 
  53 directory, there is state/, where it can store its temporary files.
 
  54 $SGMONDIR and $SGMONDIR are also always set too.
 
  56 You can remove all state directories with clear.sh.
 
  58 Generate HTML page with information about state of all services and
 
  62     $ /path/to/sgmon/status.sh > /path/to/index.html
 
  64 If some probe is failed, then email message with its stdout/stderr will
 
  65 be sent. If it succeeds after the fail, then another message is sent.
 
  66 Each startup and shutdown are also notified by email.