Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions docs/chapters/subcommands/monitor.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,23 @@ for configuration defaults:
bastille_monitor_cron_path="/usr/local/etc/cron.d/bastille-monitor"
bastille_monitor_cron="*/5 * * * * root /usr/local/bin/bastille monitor ALL >/dev/null 2&>1"
bastille_monitor_logfile="${bastille_logsdir}/monitor.log"
bastille_monitor_healthchecks=""

bastille_monitor_module=""
bastille_monitor_url=""

Alerting modules
----------------

Bastille currently supports two healthcheck modules. The ``bastille_monitor_module`` should be
either ``uptimekuma`` or ``healthchecks.io``.

The first alerting module to be supported is Health Checks
(https://healthchecks.io), which is both a free SaaS service (up to 20 checks)
and provides a self-hosted option (see ``sysutils/py-healthchecks``).
and provides a self-hosted option (see ``sysutils/py-healthchecks``). Just add the healthcheck url to
the ``bastille_monitor_url`` variable.

Simply configure the ``${bastille_monitor_healthchecks}`` variable with your Ping
URL and you're done!
The second is Uptime-Kuma, a self-hosted monitoring application. Add a new monitor of type "Push", then
copy and paste the given url into the ``bastille_monitor_url`` variable. Do not include the optional
parameters following the ``?`` character. Only the url including the api key should be included.


Help
Expand Down
3 changes: 2 additions & 1 deletion usr/local/etc/bastille/bastille.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ bastille_template_vlan="default/vlan" ## default
bastille_monitor_cron_path="/usr/local/etc/cron.d/bastille-monitor" ## default: "/usr/local/etc/cron.d/bastille-monitor"
bastille_monitor_cron="*/5 * * * * root /usr/local/bin/bastille monitor ALL >/dev/null 2>&1" ## default: "*/5 * * * * root /usr/local/bin/bastille monitor ALL >/dev/null 2>&1"
bastille_monitor_logfile="${bastille_logsdir}/monitor.log" ## default: "${bastille_logsdir}/monitor.log"
bastille_monitor_healthchecks="" ## default: ""
bastille_monitor_module="" ## options: "uptimekuma healthchecks.io"
bastille_monitor_url="" ## default: ""
26 changes: 19 additions & 7 deletions usr/local/share/bastille/monitor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,22 @@ for jail in ${JAILS}; do
done

# Final ping to healthcheck URL
if [ -n "${bastille_monitor_healthchecks}" ]; then
if [ "${ERRORS}" -eq 0 ]; then
curl -fsS --retry 3 "${bastille_monitor_healthchecks}" > /dev/null 2>&1
else
curl -fsS --retry 3 "${bastille_monitor_healthchecks}/fail" > /dev/null 2>&1
fi
fi
case "${bastille_monitor_module}" in
uptimekuma)
if [ "${ERRORS}" -eq 0 ]; then
curl -fsS --retry 3 "${bastille_monitor_url}?status=up" >/dev/null 2>&1
else
curl -fsS --retry 3 "${bastille_monitor_url}?status=down&msg=Services+Down:+${ERRORS}" >/dev/null 2>&1
fi
;;
healthchecks.io)
if [ "${ERRORS}" -eq 0 ]; then
curl -fsS --retry 3 "${bastille_monitor_url}" >/dev/null 2>&1
else
curl -fsS --retry 3 "${bastille_monitor_url}/fail" >/dev/null 2>&1
fi
;;
*)
error_notify "[ERROR]: Healthcheck module not implemented: ${bastille_monitor_module}"
;;
esac
9 changes: 6 additions & 3 deletions usr/local/share/man/man5/bastille.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,12 @@ Cron file for automatic monitoring entry.
Actual cron entry. The default is to check every 5 minutes.
.It bastille_monitor_logfile
Log storage.
.It bastille_monitor_healthchecks
This is the FQDN for optional alert services.
Currently only supports 'healthchecks.io'.
.It bastille_monitor_module
This is the monitoring module option.
Set to 'healthchecks.io' or 'uptimekuma'.
.It bastille_monitor_url
This is the FQDN for optional alerting services.
Currently supports 'healthchecks.io' and 'uptimekuma'.
.Sh SEE ALSO
.Xr bastille-bootstrap 8 ,
.Xr bastille-clone 8 ,
Expand Down
Loading