rohit01 / docker_shinken

Automated docker builds for shinken images
http://www.rohit.io/blog/rip-nagios-hello-docker-shinken.html
56 stars 41 forks source link

Instructions for setting up webservice #13

Open petrklus opened 8 years ago

petrklus commented 8 years ago

It would be great to enable webservice by default / provide instructions to do so:

https://shinken.readthedocs.io/en/branch-1.4/89_packages/ws_daemon_module.html

wakaru44 commented 8 years ago

+1

petrklus commented 8 years ago

@wakaru44 if it helps, this is what I have done to get it working for me:

My dockerfile:

# Shinken Docker installation using pip (latest)
FROM        rohit01/shinken_thruk_graphite
MAINTAINER  Petr Klus

# Install additional packages (NUT for UPS monitoring etc.)
RUN         apt-get update && apt-get install -y nut

# upgrade apt-get packages
RUN         apt-get upgrade -y

# Add all updated plugins
ADD         extra_plugins/* /usr/lib/nagios/plugins/
RUN         cd /usr/lib/nagios/plugins/ && \
                chmod a+x * && \
                chmod u+s check_apt restart_service check_ping check_icmp check_fping apt_update check_nut_plus

# Install shinken modules from shinken.io, add ws-arbiter config
RUN         su - shinken -c 'shinken install ws-arbiter'
ADD         shinken/ws_arbiter.cfg /etc/shinken/modules/ws_arbiter.cfg
ADD         shinken/receiver-master.cfg /etc/shinken/receivers/receiver-master.cfg

You can ignore the NUT install, that is just additional package I wanted there for UPS monitoring. And then the ws_arbiter.cfg:

## Module:      ws-arbiter
## Loaded by:   Arbiter, Receiver
# WebService module for the Arbiter and Receiver so you can send (POST) passive
# checks to it :)
define module {
    module_name     ws-arbiter
    module_type     ws_arbiter
    host            0.0.0.0
    port            7760
    username        anonymous   ; If you want auth, set username and password.
    #password        secret
    #routes          push_check_result   ; restart,reload,acknowledge,downtime,recheck
}

Lastly, the receive-master has ws-arbiter added under modules:

#===============================================================================
# RECEIVER
#===============================================================================
# The receiver manages passive information. It's just a "buffer" which will
# load passive modules (like NSCA) and be read by the arbiter to dispatch data.
#===============================================================================
define receiver {
    receiver_name   receiver-master
    address         localhost
    port            7773
    spare           0

    ## Optional parameters
    timeout             3   ; Ping timeout
    data_timeout        120 ; Data send timeout
    max_check_attempts  3   ; If ping fails N or more, then the node is dead
    check_interval      60  ; Ping node every N seconds

    ## Modules for Receiver
    # - named-pipe             = Open the named pipe nagios.cmd
    # - nsca                    = NSCA server
    # - tsca                    = TSCA server
    # - ws-arbiter              = WebService for pushing results to the arbiter
    # - collectd                = Receive collectd perfdata
    modules             ws-arbiter  

    # Enable https or not
    use_ssl           0
    # enable certificate/hostname check, will avoid man in the middle attacks
    hard_ssl_name_check  0

    ## Advanced Feature
    direct_routing      0   ; If enabled, it will directly send commands to the
                            ; schedulers if it knows about the hostname in the
                            ; command.
    realm   All
}