External monitoring

Step by step how-to instructions on installing and running KoBo Toolbox on a standalone server.
Jump to: navigation, search

We will monitor the vital parameters of our KoBo Docker installation from elsewhere. Issues and service outages will automatically be recorded, alerts sent out to administrators etc.We will use Nagios 4 to perform the monitoring. On the Host, only the Nagios NRPE server will be required:

$ sudo apt-get install nagios-nrpe-server

NRPE is now ready. In a traditional usage scenario, we would next edit the NRPE configuration to set allowed IPs and other transport parameter.

We are going use a different approach though; further steps are installation-specific. Firstly, disable the autostart of NRPE; we will use only it's executables. Checks from the remote Nagios server will use ssh transport, not nrpe.

$ sudo update-rc.d nagios-nrpe-server remove

We will then add two plugins from Nagios Exchange:

$ cd /usr/lib/nagios/plugins/
$ sudo wget -O check_docker https://raw.githubusercontent.com/timdaman/check_docker/master/check_docker.py
$ sudo chmod 0755 check_docker
$ sudo wget -O check_mem.gz "https://exchange.nagios.org/components/com_mtree/attachment.php?link_id=3402&cf_id=24"
$ sudo gunzip check_mem.gz
$ sudo chmod 0755 check_mem
$ sudo nano /etc/cron.d/check-docker
MAILTO=vladimir.maric@mreznisistemi.rs
MAILFROM=Kobo-OCB
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/lib/nagios/plugins/
OUT=/tmp/check.docker

*/5 * * * *     root    check_docker --memory 1024:2048:m > $OUT.memory.out 2>&1
*   * * * *     root    check_docker --container kobodocker.* --status running > $OUT.status.out 2>&1

Nagios Server configuration

The following configuration file is installation-specific, and is provided here for reference only.

$ nano /etc/nagios/servers/msf-kobo.cfg 
define command {
        command_name    check_ssh_load
        command_line    /usr/local/nagios/libexec/check_by_ssh -u $ARG1$ -H $HOSTADDRESS$ -C "/usr/lib/nagios/plugins/check_load -w $ARG2$ -c $ARG3$"
}
define command {
        command_name    check_ssh_memory
        command_line    /usr/local/nagios/libexec/check_by_ssh -u $ARG1$ -H $HOSTADDRESS$ -C "/usr/lib/nagios/plugins/check_mem -w $ARG2$ -c $ARG3$"
}
define command {
        command_name    check_ssh_disk
        command_line    /usr/local/nagios/libexec/check_by_ssh -u $ARG1$ -H $HOSTADDRESS$ -C "/usr/lib/nagios/plugins/check_disk -w $ARG3$ -c $ARG4$ -p $AR
G2$"
}
define command {
        command_name    check_ssh_docker
        command_line    /usr/local/nagios/libexec/check_by_ssh -u $ARG1$ -H $HOSTADDRESS$ -C "cat /tmp/check.docker.$ARG2$.out"
}
define command{
        command_name    check_https_vhost
        command_line    $USER1$/check_http -H $ARG1$ --ssl --onredirect $ARG2$ --pagesize $ARG3$
        }

define host{
          use                   linux-box-remote    ; Choose another template if necessary
          host_name             msfkobo             ; The name we're giving to this server
          alias                 gatitux.msf.org     ; A longer name for the server
          address               194.78.70.203       ; IP address of the server
          check_command         check_ssh
          contacts              nagiosadmin
          }
define service{
          use                 generic-service
          host_name           msfkobo
          service_description KoBo login page
          check_command       check_https_vhost!kobo.msf.org!follow!3343:3343
          }
define service{
          use                 graphed-service
          host_name           msfkobo
          service_description Host disk
          check_command       check_ssh_disk!vladimir!/dev/mapper/GATITUX--vg-root!75!90
          }
define service{
          use                 graphed-service
          host_name           msfkobo
          service_description Host CPU Load
          check_command       check_ssh_load!vladimir!5.0,4.0,3.0!10.0,6.0,4.0
          }
define service{
          use                 generic-service
          host_name           msfkobo
          service_description Host Memory
          check_command       check_ssh_memory!vladimir!75!90
          }
define service{
          use                 generic-service
          host_name           msfkobo
          service_description Docker status
          check_command       check_ssh_docker!vladimir!status
          }
define service{
          use                 graphed-service
          host_name           msfkobo
          service_description Docker memory
          check_command       check_ssh_docker!vladimir!memory
          }