Skip to content

Instantly share code, notes, and snippets.

@cornernote
Last active January 26, 2018 00:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cornernote/695cc633680df7b5ccfd02ffa6dd5ab0 to your computer and use it in GitHub Desktop.
Save cornernote/695cc633680df7b5ccfd02ffa6dd5ab0 to your computer and use it in GitHub Desktop.
Play with Docker Shinken

Play with Docker Shinken

There are many way to try out Docker Shinken, a really slick one is creating a stack on Play with Docker.

Login or signup, then create a new instance.

Download a Docker Shinken application definition:

# shinken_basic
curl -Lo docker-compose.yml https://gist.github.com/cornernote/695cc633680df7b5ccfd02ffa6dd5ab0/raw/ab8f36617a636212692cfe4d93b27b5ed873823d/shinken_basic.docker-compose.yml
# shinken_thruk
curl -Lo docker-compose.yml https://gist.github.com/cornernote/695cc633680df7b5ccfd02ffa6dd5ab0/raw/ab8f36617a636212692cfe4d93b27b5ed873823d/shinken_thruk.docker-compose.yml
# shinken_thruk_graphite
curl -Lo docker-compose.yml https://gist.github.com/cornernote/695cc633680df7b5ccfd02ffa6dd5ab0/raw/ab8f36617a636212692cfe4d93b27b5ed873823d/shinken_thruk_graphite.docker-compose.yml

Download the configuration

mkdir configs
curl -Lo configs/docker_shinken.cfg https://gist.github.com/cornernote/695cc633680df7b5ccfd02ffa6dd5ab0/raw/ab8f36617a636212692cfe4d93b27b5ed873823d/docker_shinken.cfg

And start the stack

docker-compose up -d

Your services will be available on their mapped port, just click the label right next to the node IP address.

Login with admin / admin.

Troubleshooting

Missing Port Link

If the link to the exposed port does not show then you can determine it from the SSH link provided. Simply convert the link as follows then visit the page.

Change:

ssh EXAMPLE@direct.labs.play-with-docker.com

To:

http://EXAMPLE-80.direct.labs.play-with-docker.com

Nginx Bad Gateway

If nginx complains about a bad gateway, you may just need to wait about 60 seconds for everything to start up.

It may also be you have an invalid configuration file. See logs below.

Viewing Logs

When all else fails, check the logs.

Container logs:

docker-compose logs -f shinken

Shinken logs:

docker-compose exec shinken bash
tail -f /var/log/shinken/*.log
define command {
command_name check_http_on_port
command_line $NAGIOSPLUGINSDIR$/check_http -H '$HOSTADDRESS$' -p $ARG1$
}
define command {
command_name local_process_cpu
command_line $NAGIOSPLUGINSDIR$/check_ps -r -p $ARG1$ -w 80 -c 90 -t cpu -g 'restart_service'
}
define command {
## Notify only for critical updates as warning. Does apt-get update as well
command_name local_apt_packages
command_line $NAGIOSPLUGINSDIR$/negate -o OK -w OK -c WARNING $NAGIOSPLUGINSDIR$/check_apt
}
define command {
command_name local_check_disk
## Need to cd for this plugin.. else, it results in 'Can't locate utils.pm' error!
command_line cd $NAGIOSPLUGINSDIR$ && ./check_linux_stats.pl -D -w 30 -c 15 -u %
}
define command {
command_name local_check_disk_inode
command_line $NAGIOSPLUGINSDIR$/check_disk --iwarning 30% --icritical 15%
}
define command {
command_name local_check_disk_root
command_line $NAGIOSPLUGINSDIR$/check_disk --warning 30% --critical 15% /
}
define command {
command_name local_check_disk_inode_root
command_line $NAGIOSPLUGINSDIR$/check_disk --iwarning 30% --icritical 15% /
}
define command {
command_name local_check_dns
command_line $NAGIOSPLUGINSDIR$/check_dns -H www.google.com
}
define command {
command_name local_fping_google
command_line $NAGIOSPLUGINSDIR$/check_fping www.google.com
}
define command {
command_name local_load_per_cpu
command_line $NAGIOSPLUGINSDIR$/check_load -r -w 4.0,2.0,1.0 -c 8.0,4.0,2.0
}
define command {
command_name local_check_ntp
command_line $NAGIOSPLUGINSDIR$/check_ntp_time -H in.pool.ntp.org
}
define command {
command_name local_check_procs
command_line $NAGIOSPLUGINSDIR$/check_procs -w 200
}
define command {
command_name local_total_zombie_process
command_line $NAGIOSPLUGINSDIR$/check_procs -w 5 -c 10 -s Z
}
define command {
command_name local_users_logged_in
command_line $NAGIOSPLUGINSDIR$/check_users -w 5 -c 10
}
define command {
command_name local_memory_usage
command_line $NAGIOSPLUGINSDIR$/check_memory -w 90 -c 95
}
define command {
## Using very high threshold values. Useful for graphs
## Need to cd for this plugin.. else, it results in 'Can't locate utils.pm' error!
command_name local_network_usage
command_line cd $NAGIOSPLUGINSDIR$ && ./check_linux_stats.pl -N -w 52428800 -c 104857600
}
define host {
host_name docker_shinken
use generic-host
alias docker_shinken
address localhost
_http_ports 80,7770,7771,7772,7773,7767,7768,7769
_process_list nginx, \
shinken-arbiter, \
shinken-broker, \
shinken-poller, \
shinken-reactionner, \
shinken-receiver, \
shinken-scheduler
_system_metric_checks local_apt_packages, \
local_check_disk, \
local_check_disk_inode, \
local_check_disk_root, \
local_check_disk_inode_root, \
local_check_dns, \
local_fping_google, \
local_load_per_cpu, \
local_check_ntp, \
local_check_procs, \
local_total_zombie_process, \
local_users_logged_in, \
local_memory_usage, \
local_network_usage
}
define service {
service_description http_port_$KEY$
use generic-service
host_name docker_shinken
check_command check_http_on_port!$KEY$
check_interval 10
retry_interval 1
aggregation http_ports
duplicate_foreach _http_ports
}
define service {
service_description process_$KEY$
use generic-service
host_name docker_shinken
check_command local_process_cpu!$KEY$
check_interval 5
retry_interval 1
aggregation process_cpu
duplicate_foreach _process_list
}
define service {
service_description $KEY$
use generic-service
host_name docker_shinken
check_command $KEY$
check_interval 10
retry_interval 1
aggregation system_metrics
duplicate_foreach _system_metric_checks
}
version: '2'
services:
shinken:
image: rohit01/shinken:latest
environment:
- "TZ=UTC"
ports:
- "80:80"
volumes:
- ./configs:/etc/shinken/custom_configs
- ./plugins:/usr/local/custom_plugins
version: '2'
services:
shinken:
image: rohit01/shinken_thruk:latest
environment:
- "TZ=UTC"
ports:
- "80:80"
volumes:
- ./configs:/etc/shinken/custom_configs
- ./plugins:/usr/local/custom_plugins
version: '2'
services:
shinken:
image: rohit01/shinken_thruk_graphite:latest
environment:
- "TZ=UTC"
ports:
- "80:80"
volumes:
- ./configs:/etc/shinken/custom_configs
- ./plugins:/usr/local/custom_plugins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment