| `-- hubot (adds hubot with an IRC adapter)
|-- irker (adds irker, and spawns irkerd by default)
|-- memcached (adds Memcached)
+ |-- nagios (adds Nagios)
|-- nginx (adds Nginx)
| |-- nginx-proxy (SSL/TLS proxying via SNI)
| |-- kibana (adds Kibana)
hubot
irker
memcached
+ nagios
nginx
nginx-proxy
kibana
--- /dev/null
+# Copyright (C) 2014 W. Trevor King <wking@tremily.us>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+FROM ${NAMESPACE}/gentoo-syslog:${TAG}
+MAINTAINER ${MAINTAINER}
+#VOLUME ["${PORTAGE}:/usr/portage:ro", "${PORTAGE}/distfiles:/usr/portage/distfiles:rw"]
+RUN echo 'media-libs/gd jpeg png' >> /etc/portage/package.use
+RUN echo 'net-analyzer/nagios-core lighttpd' >> /etc/portage/package.use
+RUN echo 'net-analyzer/nagios-plugins nagios-dns nagios-ntp nagios-ssh' >> /etc/portage/package.use
+RUN echo 'dev-lang/php cgi' >> /etc/portage/package.use
+RUN emerge -v net-analyzer/nagios
+RUN eselect news read new
+ADD lighttpd-syslog.conf /etc/lighttpd/syslog.conf
+RUN echo 'include "mod_fastcgi.conf"' >> /etc/lighttpd/lighttpd.conf
+RUN echo 'include "syslog.conf"' >> /etc/lighttpd/lighttpd.conf
+ADD lighttpd-nagios.conf /etc/lighttpd/nagios.conf
+RUN echo 'include "nagios.conf"' >> /etc/lighttpd/lighttpd.conf
+# https://bugs.gentoo.org/show_bug.cgi?id=528184
+RUN chmod 755 /etc/nagios
+RUN sed -i 's|\(#use_timezone=Australia/Brisbane\)|\1\nuse_timezone=UTC|' /etc/nagios/nagios.cfg
+RUN sed -i 's|\(;date.timezone.*\)|\1\ndate.timezone = "UTC"|' /etc/php/*/php.ini
+RUN sed -i 's|\(#default_user_name=.*\)|\1\ndefault_user_name=guest|' /etc/nagios/cgi.cfg
+RUN sed -i 's|\(authorized_for_system_information=.*\)|\1,guest|' /etc/nagios/cgi.cfg
+RUN sed -i 's|\(authorized_for_configuration_information=.*\)|\1,guest|' /etc/nagios/cgi.cfg
+RUN sed -i 's|\(authorized_for_all_services=.*\)|\1,guest|' /etc/nagios/cgi.cfg
+RUN sed -i 's|\(authorized_for_all_hosts=.*\)|\1,guest|' /etc/nagios/cgi.cfg
+RUN sed -i 's|\(authorized_for_read_only=.*\)|\1,guest|' /etc/nagios/cgi.cfg
+RUN mkdir /etc/nagios/cfg
+RUN chown nagios:nagios /etc/nagios/cfg
+RUN sed -i 's|\(#cfg_dir=/etc/nagios/routers.*\)|\1\ncfg_dir=/etc/nagios/cfg|' /etc/nagios/nagios.cfg
+RUN rc-update add nagios default
+RUN rc-update add lighttpd default
+
+EXPOSE 80
--- /dev/null
+Run this [Nagios][] image with:
+
+ $ docker run -d --name nagios-0 -p 80:80 wking/nagios
+
+You'll want to [volume mount][volume-mount] your config. For example:
+
+ $ docker run -d --name nagios-0 \
+ > -v ~/src/dockerfile/nagios/redis/plugins:/usr/local/bin \
+ > -v ~/src/dockerfile/nagios/redis/cfg:/etc/nagios/cfg \
+ > -p 80:80 \
+ > wking/nagios \
+ > /bin/bash -c '
+ > emerge -v dev-db/redis && rc default && exec tail-syslog
+ > '
+
+Of course, if you were using this in production you'd want to create a
+new image `FROM` this one with `dev-db/redis` already installed, after
+which you could drop the explicit command.
+
+For information about writing your own plugins, see the [plugin API
+docs][plugin-api]. For more information about Nagios on Gentoo, see
+the [wiki][].
+
+[Nagios]: http://www.nagios.org/
+[volume-mount]: http://docs.docker.com/userguide/dockervolumes/#mount-a-host-directory-as-a-data-volume
+[plugin-api]: http://nagios.sourceforge.net/docs/3_0/pluginapi.html
+[wiki]: http://wiki.gentoo.org/wiki/Nagios
--- /dev/null
+server.modules += ("mod_cgi")
+server.modules += ("mod_alias")
+server.modules += ("mod_rewrite")
+
+$HTTP["url"] =~ "^/nagios/cgi-bin/" {
+ dir-listing.activate = "disable"
+ cgi.assign = (
+ ".pl" => "/usr/bin/perl",
+ ".cgi" => ""
+ )
+}
+
+alias.url += (
+ "/nagios/cgi-bin" => "/usr/lib/nagios/cgi-bin",
+ "/nagios" => "/usr/share/nagios/htdocs"
+)
+
+url.rewrite = ( "^/$" => "/nagios" )
--- /dev/null
+server.errorlog-use-syslog = "enable"
+accesslog.use-syslog = "enable"
--- /dev/null
+This directory includes a `check_redis_list_length` plugin and sample
+Nagios config for monitoring the length of a [Redis][] list. If
+you're using Redis as your [Celery][] [broker][], the list name should
+match your queue name. You'll need the command line `redis-cli` to
+run the plugin.
+
+[Redis]: http://redis.io/
+[Celery]: http://celery.readthedocs.org/en/latest/
+[broker]: http://celery.readthedocs.org/en/latest/getting-started/brokers/redis.html
--- /dev/null
+define host{
+ use linux-server
+ host_name redis-host
+ alias redis-host
+ address 192.168.0.2
+}
+
+define hostgroup{
+ hostgroup_name my-servers
+ alias My Servers
+ members redis-host
+}
+
+define service{
+ use local-service
+ host_name redis-host
+ service_description PING
+ check_command check_ping!100.0,20%!500.0,60%
+}
+
+define service{
+ use local-service
+ host_name redis-host
+ service_description Default Celery Queue
+ check_command check_redis_list_length!default!50!100
+}
+
+define command{
+ command_name check_redis_list_length
+ command_line /usr/local/bin/check_redis_list_length -h $HOSTADDRESS$ -l $ARG1$ -w $ARG2$ -c $ARG3$
+}
--- /dev/null
+#!/bin/sh
+#
+# Check a Redis list length (e.g. a Celery queue)
+#
+# Copyright (C) 2014 W. Trevor King <wking@tremily.us>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+HOST='127.0.0.1'
+PORT='6379'
+LIST='default'
+WARNING='50'
+CRITICAL='100'
+
+STATE_OK=0
+STATE_WARNING=1
+STATE_CRITICAL=2
+STATE_UNKNOWN=3
+
+while [ "$#" -gt 0 ]
+do
+ case "$1" in
+ -h)
+ HOST="$2"
+ shift
+ ;;
+ -p)
+ PORT="$2"
+ shift
+ ;;
+ -l)
+ LIST="$2"
+ shift
+ ;;
+ -w)
+ WARNING="$2"
+ shift
+ ;;
+ -c)
+ CRITICAL="$2"
+ shift
+ ;;
+ *)
+ echo "LIST UNKNOWN - unrecognized option: '$1'" >&2
+ exit "${STATE_UNKNOWN}"
+ esac
+ shift
+done
+
+LENGTH=$(redis-cli -h "${HOST}" -p "${PORT}" llen "${LIST}")
+REDIS_STATUS="$?"
+if [ "${REDIS_STATUS}" -eq 127 ]
+then
+ echo "LIST UNKNOWN - command not found (did you install redis-cli?)"
+ exit "${STATE_UNKNOWN}"
+elif [ "${REDIS_STATUS}" -ne 0 ]
+then
+ echo "LIST WARNING - redis-cli returned state ${REDIS_STATUS}"
+ exit "${STATE_WARNING}"
+fi
+
+STATUS='OK'
+EXIT="${STATE_OK}"
+if [ "${LENGTH}" -gt "${CRITICAL}" ]
+then
+ STATUS='CRITICAL'
+ EXIT="${STATE_CRITICAL}"
+elif [ "${LENGTH}" -gt "${WARNING}" ]
+then
+ STATUS='WARNING'
+ EXIT="${STATE_WARNING}"
+fi
+
+echo "LIST ${STATUS} - ${LIST} length: ${LENGTH}"
+exit "${EXIT}"