Skip to content

Instantly share code, notes, and snippets.

@insanity54
Created November 5, 2015 17:47
Show Gist options
  • Select an option

  • Save insanity54/80bc05fa16837461cfd9 to your computer and use it in GitHub Desktop.

Select an option

Save insanity54/80bc05fa16837461cfd9 to your computer and use it in GitHub Desktop.
Shinken notes

Shinken

Installation

these steps are for debian.

prereqs

$ sudo apt-get install python-pip python-pycurl python-crypto

create system user to run shinken as

$ sudo adduser shinken

install

$ sudo pip install shinken

this puts a bunch of shinken binaries in /etc/shinken/ /usr/bin/ and /var/lib/shinken/

first thing to do is initialize your installation.

$ sudo shinken --init

As far as I can tell, this just creates an ini file in your home directory. Notice I used sudo. Since shinken runs as user shinken, the user you're logged in as probably can't work with shinken files without using sudo. Also, later on we might need to install some modules using shinken install. If we did $ shinken --init when I was logged in as chris, It would create /home/chris/.shinken.ini which is not useful to the shinken user. Instead, we run init as sudo, which creates /root/.shinken.ini. This is what we want because in order for 'shinken' to install anything at all (/etc,/var,etc.), it needs root access.

now that we have a basic installation, run a pre-flight check. If there are no errors, it's ready to go.

$ /usr/bin/shinken-arbiter -v -c /etc/shinken/shinken.cfg

Warnings are OK, fixing them is optional. If you get errors, a nice log output will show which should help you get them solved. for me I had to install some modules (see troubleshooting section)

start daemon now

$ sudo /etc/init.d/shinken start

If you get errors here (I did) check the log output it specifies. For me, I was getting permission denied errors, and it was because the directory shinken's pid files were placed was owned by root, not shinken. Fixed it by running sudo chown shinken:shinken /var/run/shinken

tell system to start shinken on boot

$ sudo update-rc.d shinken defaults 20

Configuration

It's just like nagios, fully compatible. You can even drop in your existing nagios configs. Just edit object definitions in /etc/shinken/

configuration is at /home/firstwin.shinken.ini (generated in installation step)

Authentication

set up an authentication method for the web ui. if you want ldap, active directory, or something else, check shinken search auth for options. otherwise, we'll install the basic authentication module which goes off of the contacts files in /etc/shinken/contacts/

$ sudo shinken install auth-cfg-password

now we need to define auth-cfg-password so shinken knows about it, and we can reference it in other modules. Create the file-

$ sudo emacs -nw /etc/shinken/modules/auth_cfg_password.cfg

in it, add the following, then save and close

## Module:      auth-cfg-password                                                            
## Loaded by:   WebUI                                                                        
# Check authentification using password parameter in contact definition.                     
define module {
    module_name     auth-cfg-password
    module_type     cfg_password_webui
}

lastly change it's user and group to shinken

$ sudo chown shinken:shinken /etc/shinken/modules/auth_cfg_password.cfg

now you need to configure the webui module to use the auth-cfg-password module. more on that in the next section.

Web UI

the webui module.

change the auth_secret of the web module to something unique and hard to guess/brute force

$ sudo emacs -nw /etc/shinken/modules/webui.cfg

while you're editing that file, configure the webui module to use the auth-cfg-password module.

there is a directive in webui.cfg called 'modules'. after modules, add, 'auth-cfg-password' like the following example:

modules                   auth-cfg-password

now configure

now set up user accounts to be able to log into the webui. by default there is a user, 'admin' which has a poor password, 'admin'. go ahead and change it

$ sudo emacs -nw /etc/shinken/contacts/admin.cfg
Monitor a service

first define a host or service in /etc/shinken/hosts/ or /etc/shinken/services/. which you choose doesn't matter, the directories are just for your organization.

example file /etc/shinken/hosts/elrond.cfg

define host{
        generic-host            generic-host
        hostgroups              linux,minecraft
        contact_groups          admins
        host_name		        elrond
        address			        elrond.servegame.com
        }

following the 'hostgroups' directive, we can add tags of this server's attributes. Later, we can set up individual tags to automatically run checks against associated hosts. Here's an example of that:

define host{
        use                     generic-host
        hostgroups              linux,minecraft
        contact_groups          admins
        host_name		        taco
        address			        taco.servegame.com
        }

with linux and minecraft tags configured, this host would get basic health checks via check_icmp, as well as TCP port checking for minecraft servers.

Set up e-mail notifications

add a directive enable_notifications=1 in /etc/shinken/shinken.cfg and restart shinken services

Set up xmpp notifications

prereqs

$ sudo apt-get -y install python-xmpp

configure xmpp account to send from

$ sudo emacs -nw /var/lib/shinken/libexec/notify_by_xmpp.ini

send test message

$ /var/lib/shinken/libexec/notify_by_xmpp.py -a /var/lib/shinken/libexec/notify_by_xmpp.ini "test 1234" <your email address>

Troubleshooting

[FAIL] ConfigCheck failed: Configuration is incorrect, sorry, I bail out ... failed!

something's wrong with a config file. to find out which one and why, run the pre-flight check and search the output for errors.

$ /usr/bin/shinken-arbiter -v -c /etc/shinken/shinken.cfg
can't log into the web ui
Warning! Invalid user or Password 

You either don't have an auth module installed, or it's not configured. or you're just typing your password wrong.

check to see if you have an auth module installed.

$ ls /var/lib/shinken/modules

if you see no auth-* in the above directory, it's time to install one. follow the Authentication subsection under the Configuration section above

the module x is unknown

If you get an error like this:

[1444551504] ERROR: [Shinken] [item::broker-master] Error: the module graphite is unknown for broker-master

it means there is a configuration for the module (somewhere in /etc/shinken/modules) but the module itself is not installed (in /var/lib/shinken/modules)

the fix is to use the shinken command to install any needed modules

$ sudo shinken install <module name>
FAILED: shinken.daemon.InvalidPidFile

FAILED: shinken.daemon.InvalidPidFile: [Errno 13] Permission denied: '/var/run/shinken/schedulerd.pid' (full output is in /tmp/bad_start_for_scheduler) failed!

pid files are in a directory owned by root, not shinken. fix by changing owner to shinken

sudo chown shinken:shinken /var/run/shinken
sudo chown shinken:shinken /var/lib/shinken

(these are set by the init script, /etc/init.d/shinken ~line 178)

shinken.http_daemon.PortNotFree
FAILED: shinken.http_daemon.PortNotFree: Error: Sorry, the port 7770 is not free: [Errno 98] Address already in use (full output is in /tmp/bad_start_for_arbiter)
 failed!
Web UI shows, '[Errno 2] No such file or directory' for host UP/DOWN output

The check_icmp plugin is probably missing. The easy fix is to download nagios-plugins package.

$ sudo apt-get -y install nagios-plugins

alternatively you can add in a check_icmp script downloaded from exchange.nagios.com

Edit the file /etc/shinken/commands/check_host_alive. If you see a macro in there such as, $NAGIOSPLUGINDIR$ change it to the directory of shinken plugins. (/var/lib/shinken/libexec) and download a check_icmp script to that directory.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment