Thruk is an advanced interface for Nagios (and Shinken) that allows connecting to multiple Nagios instances simultaneously and displaying more relevant information compared to the standard Nagios interface.
<IfModulemod_fcgid.c>AddHandlerfcgid-script.sh
<Directory/usr/share/thruk>OptionsFollowSymLinks
AllowOverrideAllorderallow,deny
allowfromall</Directory><Directory/etc/thruk/themes>OptionsFollowSymLinks
allowfromall</Directory><Directory/etc/thruk/plugins>OptionsFollowSymLinks
allowfromall</Directory># redirect to a startup page when there is no pidfile yetRewriteEngineOnRewriteCond%{REQUEST_METHOD}GET
RewriteCond%{REQUEST_URI}!^/thruk/startup.html
RewriteCond%{REQUEST_URI}!^/thruk/side.html
RewriteCond%{REQUEST_URI}!^/thruk/.*\.(css|png|js)
RewriteCond%{REQUEST_URI}^/thruk
RewriteCond/var/cache/thruk/thruk.pid!-f
RewriteRule^(.*)$/thruk/startup.html?$1[R=302,L,NE,QSA]
Alias/thruk/documentation.html/usr/share/thruk/root/thruk/documentation.htmlAlias/thruk/startup.html/usr/share/thruk/root/thruk/startup.htmlAliasMatch^/thruk/(.*\.cgi|.*\.html)/usr/share/thruk/fcgid_env.sh/thruk/$1
AliasMatch^/thruk/plugins/(.*?)/(.*)$/etc/thruk/plugins/plugins-enabled/$1/root/$2
Alias/thruk/themes//etc/thruk/themes/themes-enabled/Alias/thruk/usr/share/thruk/root/thruk<Location/thruk>OptionsExecCGI
</Location><DirectoryMatch(/usr/share/thruk/root/thruk|/etc/thruk/themes/themes-enabled/)>OptionsFollowSymLinks
#DirectoryIndex index.phpAllowOverrideAuthConfig
OrderDeny,Allow
DenyFromAllAllowFrom127.0.1.1AllowFrom127.0.0.1AuthName"Thruk Access"AuthTypeBasic
AuthBasicProviderldap
AuthzLDAPAuthoritativeonAuthLDAPURLldap://openldap.deimos.fr/dc=openldap,dc=deimos,dc=fr?uid?sub?(objectClass=posixAccount)
AuthLDAPRemoteUserIsDNoffAuthLDAPGroupAttributememberUid
AuthLDAPGroupAttributeIsDNoffRequireldap-groupou=Groups,dc=openldap,dc=deimos,dc=fr
Requireldap-usernagiosadmin
SatisfyAny</DirectoryMatch></IfModule>
Thruk
For Thruk configuration, there are 2 important files:
thruk.conf: General configuration
thruk_local.conf: Custom configuration
According to the official documentation, it's preferable not to touch the general configuration and override certain parameters with the custom configuration.
Here's a basic configuration to make it work with MK Livestatus:
############################################
# put your own settings into this file
# settings from this file will override
# those from the thruk.conf
############################################
# Interface Options
default_theme = Exfoliation
use_timezone = CET
use_ajax_search = 1
use_new_search = 1
info_popup_event_type = onmouseover
show_modified_attributes = 1
show_long_plugin_output = inline
show_full_commandline = 2
# Backends to Mklivestatus
<Component Thruk::Backend>
<peer>
name = Local Nagios
type = livestatus
<options>
peer = /var/lib/nagios3/rw/live
resource_file = /etc/nagios3/resource.cfg
</options>
<configtool>
core_conf = /etc/nagios3/nagios.cfg
obj_check_cmd = /usr/sbin/nagios3 -v /etc/nagios3/nagios.cfg
obj_reload_cmd = /etc/init.d/nagios3 reload
</configtool>
</peer>
</Component>
You can add multiple Peers to have a unified interface with several Nagios servers. Once you have access to the Thruk interface, you can configure all its options directly from this interface, as well as those of Nagios.
Then reload Apache for the changes to take effect.
Minimal Interface for Monitoring Screens
I had already discussed in the Nagios documentation solutions for having a fairly minimal screen. The problem is that it's still not sufficient, and fortunately with Thruk there's a way to fix this issue without having to recode 3/4 of the program. So I created a small patch that I submitted to the Thruk team (which has just been accepted https://github.com/sni/Thruk/commit/d1eefef82cd8fbab6ebebff8a570bb1e026d1a9f but will only be available in the next release (1.28)), so in the meantime, here's how to have the most minimal interface possible.
Here is a first patch to modify the Thruk Perl modules so that they take into account a new parameter in the URL called "minimal":
In some cases, you may have certain checks that temporarily store information on the Nagios server, and you want to be able to execute actions from the Nagios interface. For this, there is the 'action_url' option where we can provide a URL to a CGI that will execute what we want, possibly with options.
Let's start by creating our CGI. Here is a minimalist example where I remove a temporary file:
define service{
use generic-services-ulsysnet
hostgroup_name network
service_description Interface Network Flapping
check_period 24x7
notification_period 24x7
_SNMP_PORT 161
_SNMP_COMMUNITY public
_DURATION 86400
check_command check_interface_flapping
# For Thruk & Nagios
# action_url ../../cgi-bin/nagios3/remove.cgi?host=$HOSTADDRESS$
# For Nagios only
action_url remove.cgi?host=$HOSTADDRESS$
}
Now you just need to reload Nagios.
You'll notice that for Thruk, I found an easy but not very clean method, which consists of rewriting the URL to point to the Nagios links. For a clean method, you would need to write a dedicated plugin.
FAQ
OS Icons No Longer Display
Apparently in the Debian package of this version of Thruk, there is a small issue with displaying OS icons. To fix this, we'll create a symbolic link: