How to install and configure a monitoring machine for supervision

From Deimos.fr / Bloc Notes Informatique
Jump to: navigation, search
Nagios

Software version
Operating System Debian 7
Website {{{infobox_website}}}
Last Update 08/08/2013
Others

1 Introduction

The goal of this documentation is how to quickly setup a monitoring machine on Nagios/Shinken :

Monito screen.png

The idea is to have a machine that nobody never touch once installed. It's always boring to plug a keyboard and a mouse when somethings goes wrong on this kind of machine. That's why we'll see how to setup a minimal installation with all requirements to satisfy those needs.

2 Installation

Install a Debian wheezy with a SSH server and additional utilities but without any X server or Window Manager and create an 'monitoring' user. Once done, connect with SSH on the machine install install those packages :

Command aptitude
aptitude install xserver-xorg-core xorg awesome slim iceweasel wmctrl

We're installing iceweasel to get all dependencies of Firefox satisfied, but as we don't want any Iceweasel update break our configuration, we're going to install firefox :

Command
wget ftp://ftp.mozilla.org/pub/firefox/releases/22.0/linux-x86_64/fr/firefox-22.0.tar.bz2
tar -xjf firefox-22.0.tar.bz2
mv firefox /usr/share/
rm firefox-22.0.tar.bz2
ln -s /usr/share/firefox/firefox /usr/bin/
chown -Rf monitoring /usr/share/firefox/firefox

Now we're ready for the configuration.

3 Configuration

3.1 slim

The configuration of slim is simple : we want to boot awesome without any credentials questions :

Configuration File /etc/slim.conf
# NOTE: if your system does not have bash you need
# to adjust the command according to your preferred shell,
# i.e. for freebsd use:
login_cmd           exec /bin/sh - ~/.xinitrc %session##login_cmd           exec /bin/bash -login /etc/X11/Xsession %session
[...]
# sessions            default,startxfce4,openbox,ion3,icewm,wmaker,blackbox,awesome
sessions            awesome[...]
# default user, leave blank or remove this line
# for avoid pre-loading the username.
default_user        monitoring[...]
# Automatically login the default user (without entering
# the password. Set to "yes" to enable this feature
auto_login          yes

3.2 Awesome

Awesome should be configured to launch firefox in fullscreen mode automatically at startup. That's why we need to create a configuration file and then modify it. Login with monitoring user and copy the default config :

Command
mkdir -p .config/awesome
cp /etc/xdg/awesome/rc.lua .config/awesome/

Then edit the configuration file and modify/add those lines :

Configuration File ~/.config/awesome/rc.lua
[...]
layouts =
{
    awful.layout.suit.max.fullscreen,    awful.layout.suit.floating,
    awful.layout.suit.tile,
    awful.layout.suit.tile.left,
    awful.layout.suit.tile.bottom,
    awful.layout.suit.tile.top,
    awful.layout.suit.fair,
    awful.layout.suit.fair.horizontal,
    awful.layout.suit.spiral,
    awful.layout.suit.spiral.dwindle,
    awful.layout.suit.max,
    awful.layout.suit.magnifier
}
[...]
-- Move mouse to a cornerlocal safeCoords = {x=0, y=60}local moveMouseOnStartup = truelocal function moveMouse(x_co, y_co)    mouse.coords({ x=x_co, y=y_co })endif moveMouseOnStartup then        moveMouse(safeCoords.x, safeCoords.y)end -- Launch Firefox at startupawful.util.spawn_with_shell("firefox")

As you can see, we're moving the mouse at boot instead of hiding it with slim. It's preferable to have the possibility to use it if we really need it than changing the configuration and reboot instead.

3.3 Firefox

Launch firefox and install a fullscreen extension to autohide everything. You also need to change the "about:config" to set to false this parameter :

browser.sessionstore.resume_from_crash

To finish, disable automatic update and configure the URL with Nagios :

https://nagios.deimos.fr/cgi-bin/status.cgi?host=all&servicestatustypes=28&hoststatustypes=3&serviceprops=42&sorttype=1&sortoption=6&noheader

Or if you prefer Thruk :

https://nagios.deimos.fr/thruk/cgi-bin/status.cgi?serviceprops=42&servicestatustypes=28&sortoption=6&type=detail&sorttype=1&host=all&hostprops=10&minimal=1

3.4 Screensaver

Another interesting thing is to disable the screensaver :-D. And add in xinitrc :

Configuration File ~/.xinitrc
#!/bin/sh
 
# Disable screen shutdown
xset -dpms
xset s off
 
# Launch Window Manager
exec awesome >> ~/.cache/awesome/stdout 2>> ~/.cache/awesome/stderr

And create the folder that doesn't exist :

Command
mkdir -p ~/.cache/awesome

3.5 Powersaving

As I'm a green IT, I don't want the monitoring machine to be up & running 24/24h 7/7j. That's why in the BIOS, I've set it up to start automatically at the wished hour. And I added this in the root crontab to autoswitch off correctly Firefox (using wmctrl is necessary are there is a bug on Firefox with SIGINT for more than 10 years) :

PATH=/usr/bin:/sbin:/bin
0 20 * * * export DISPLAY=:0 ; su - monitoring -c "wmctrl -c firefox" ; halt