Adagios installation on NethServer 7.x

Hi all!
Good news are on the way: you can now run Adagios even on NS 7! :smile:

Just a couple of notes about this procedure:

  • You have to use Nagios 3.5.1 core yet (we’ll take the rpm from one of these mirrors): that’s for a known limitation of Adagios mk-liveststatus implementation (take a look here);
  • The procedure is still experimental so there’s a chance it will change! :slight_smile:

Now let’s go on!

Source:
https://github.com/opinkerfi/adagios/wiki/Adagios-on-CentOS-7-with-Nagios-4 (notice the “Under construction, not ready yet” in the title! ;))

  1. Install additional repo:

    yum localinstall http://opensource.is/repo/ok-release.rpm -y

  2. Change releasever ref into ok repo url (mandatory or installation fails):

    sed -i ‘s/rhel$releasever/rhel7/’ /etc/yum.repos.d/ok.repo

  3. Procede with installation:

    yum -y --enablerepo=ok* install pnp4nagios nagios-plugins*
    git adagios okconfig acl python-setuptools mk-livestatus pynag
    ftp://bo.mirror.garr.it/1/centos/7.3.1611/cloud/x86_64/openstack-newton/common/nagios-3.5.1-1.el7.x86_64.rpm
    ftp://bo.mirror.garr.it/1/centos/7.3.1611/cloud/x86_64/openstack-newton/common/nagios-common-3.5.1-1.el7.x86_64.rpm

  4. Don’t want Nagios to log into syslog (too verbose!), so disable it:

    sed -i ‘s/use_syslog=1/use_syslog=0/’ /etc/nagios/nagios.cfg

  5. Fit localhost check_http command to NS Apache configuration:

    touch /var/www/html/apacheok
    sed -i ‘s/check_http/check_http!-u /apacheok/’ /etc/nagios/objects/localhost.cfg

  6. Choose nagiosadmin password:

    htpasswd -c /etc/nagios/passwd nagiosadmin

  7. Make sure Adagios can write to nagios configuration files, and that it is a valid git repo so we have audit trail:

    cd /etc/nagios/
    git init
    git config user.name "yourname"
    git config user.email "yourname@yourdomain.com"
    git add *
    git commit -m “Initial commit”

  8. Make sure Nagios group will always have write access to the configuration files:

    chown -R nagios /etc/nagios/* /etc/nagios/.git
    setfacl -R -m group:nagios:rwx /etc/nagios/
    setfacl -R -m d:group:nagios:rwx /etc/nagios/

  9. By default objects created by Adagios will go to /etc/nagios/adagios so make sure that this directory exists and nagios.cfg contains a reference to this directory:

    mkdir -p /etc/nagios/adagios
    pynag config --append cfg_dir=/etc/nagios/adagios

  10. The status view relies on broker modules livestatus and pnp4nagios, so let’s configure nagios.cfg to use those:

    pynag config --append "broker_module=/usr/lib64/nagios/brokers/npcdmod.o config_file=/etc/pnp4nagios/npcd.cfg"
    pynag config --append "broker_module=/usr/lib64/mk-livestatus/livestatus.o /var/spool/nagios/cmd/livestatus"
    pynag config --set “process_performance_data=1”

  11. Add nagios to apache group so it has permissions to pnp4nagios session files:

    usermod -G apache nagios

  12. Define new services according to NethServer default (see developer manual):

    config set nagios service status enabled
    mkdir -p /etc/e-smith/db/configuration/defaults/nagios
    echo “service” > /etc/e-smith/db/configuration/defaults/nagios/type
    echo “enabled” > /etc/e-smith/db/configuration/defaults/nagios/status

    config set npcd service status enabled
    mkdir -p /etc/e-smith/db/configuration/defaults/npcd
    echo “service” > /etc/e-smith/db/configuration/defaults/npcd/type
    echo “enabled” > /etc/e-smith/db/configuration/defaults/npcd/status

    config set nrpe service access private TCPPort 5666 status enabled
    mkdir -p /etc/e-smith/db/configuration/defaults/nrpe
    echo “service” > /etc/e-smith/db/configuration/defaults/nrpe/type
    echo “enabled” > /etc/e-smith/db/configuration/defaults/nrpe/status
    echo “private” > /etc/e-smith/db/configuration/defaults/nrpe/access
    echo “5666” > /etc/e-smith/db/configuration/defaults/nrpe/TCPPort

  13. We need to fix a known bug (see here):

    sed -i “3iALLOWED_HOSTS = [’*’]\n” /etc/adagios/adagios.conf

  14. Enable, start and signal the new services:

    systemctl enable nagios
    systemctl enable npcd
    systemctl enable nrpe

    systemctl start nagios
    systemctl start npcd
    systemctl start nrpe
    systemctl restart httpd

    signal-event runlevel-adjust

  15. Add the following line at the end of Adagios sudoers fragment file:

    cat << EOT > /etc/sudoers.d/nagios-adagios

    Nagios daemon control on NethServer 7

    Defaults:nagios !requiretty
    nagios ALL = (root) NOPASSWD: /usr/bin/systemctl
    EOT

  16. Fix permission in logrotate fragment:

    sed -i “2isu nagios nagios” /etc/logrotate.d/okconfig

  17. To prevent unforseen nagios package update, add:

    mkdir -p /etc/e-smith/templates-custom/etc/yum.conf
    echo -e “#\n# 25exclusions\n#\nexclude=nagios nagios-common\n” > /etc/e-smith/templates-custom/etc/yum.conf/25exclude
    expand-template /etc/yum.conf

Done! Now you can access Adagios form the default url:

https://server.domain/adagios

using nagiosadmin credentials.

Test it, test it, test it and let me know! :smiley:

5 Likes

Guess that @mario_spang @ironsky @zapdog @Artem_Voylenko @edi @tramamo @m.traeumner @vores @jaapvdv would be more than happy to help you :slight_smile:

Anyway Kudos to @nrauso great shot! :gun:

great work @nrauso!!
this is absolutely a more advanced install. not the default create database + dbuser, create apache vhost, download the applucation and unpack in vhost directory, start the installer, fill in some basic stuff and done.

can you explain why adagios uses a git-like local repo?

Hi @robb!
Happy you like the procedure: I’ll work to make it better! :slight_smile:

Concerning Git, Adagios uses it only to keep track of configuration changes: it allows you to log any activity and easily revert any change (you could find the panel to manage git commits under the cog icon on the top-right corner of the gui -> “Object History” menu).

Actually Git configuration is optional.

I could write it down on the procedure, what do you think?

Hi Nicola,
thanks for your great job. I have to set up a new virtual mashine to test it. I’ll try to do it next week.

2 Likes

Wow!
Thanks @m.traeumner: let me know! :slight_smile:

Great news and excellent howto! :clap:

2 Likes

Hi Nicola,
the installation went fine. After configuring the ssh-request (no standard ssh port) it works without any errors.
Thanks for your great work.

Hi to all,
if you have installed nagios and adagios on Nethser 7 with this tutorial and you don’t have the standard ssh port it shows a critical error.

To get rid of it you only have to add an argument with the portnumber and restart the service.

  • go to the adagios webinterface
  • choose Configure at the upper menu
  • choose Configuration at the left side
  • by Object Configuration switch from Host to Services
  • click on ssh and choose monitoring
  • by Argument 1 you can add your port option like “-p 2222” without quotation mark
  • after that I had to restart nagios from shell “systemctl restart nagios”

I think for nagios on Nethserver 6.8 it’s the same, perhaps somebody can try it.

1 Like

Nice shot @m.traeumner! :vulcan:
And yes, on NS 6.8 it’s the same because it’s the standard ssh check config. :slight_smile:

1 Like

After update to 7.4 and now final I can’t use nagios anymore.

[root@GroupwareBackup nagios]# systemctl status nagios -l
● nagios.service - Nagios Network Monitoring
Loaded: loaded (/usr/lib/systemd/system/nagios.service; enabled; vendor prese t: disabled)
Active: failed (Result: exit-code) since Thu 2017-02-02 14:45:27 CET; 1min 5s ago
Docs: Documentation | Nagios Open Source
Process: 26089 ExecStartPre=/usr/sbin/nagios -v /etc/nagios/nagios.cfg (code=e xited, status=1/FAILURE)

Feb 02 14:45:27 GroupwareBackup.jonas.de systemd[1]: Starting Nagios Network Mon itoring…
Feb 02 14:45:27 GroupwareBackup.jonas.de systemd[1]: nagios.service: control pro cess exited, code=exited status=1
Feb 02 14:45:27 GroupwareBackup.jonas.de systemd[1]: Failed to start Nagios Netw ork Monitoring.
Feb 02 14:45:27 GroupwareBackup.jonas.de systemd[1]: Unit nagios.service entered failed state.
Feb 02 14:45:27 GroupwareBackup.jonas.de systemd[1]: nagios.service failed.
[root@GroupwareBackup nagios]#

Oh my! :cry:
I’ll take a look at it asap!

1 Like

Hi @m.traeumner!
I ran some test but haven’t been able to reproduce your problem.
Could be a matter of configuration?
Could you post here the output of the command:

nagios -v /etc/nagios/nagios.cfg

and attach /etc/adagios/adagios.conf file?

Hi Nicola,
thanks for your test. I’ve forgotton that I’ve changed something. I have tried to install a nagios win client at my win pc and bind it with the nagios at nethserver. I’ve done it with these steps.
After renaming /etc/nagios/okconfig/PC20141103-01.cfg PC20141103-01.bak

nagios -v /etc/nagios/nagios.cfg

runs without errors:

Nagios Core 4.0.8
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-12-2014
License: GPL

Website: http://www.nagios.org
Reading configuration data…
Read main config file okay…
Read object config files okay…

Running pre-flight check on configuration data…

Checking objects…
Checked 8 services.
Checked 1 hosts.
Checked 2 host groups.
Checked 1 service groups.
Checked 1 contacts.
Checked 2 contact groups.
Checked 189 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths…
Checked 1 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 5 timeperiods
Checking global event handlers…
Checking obsessive compulsive processor commands…
Checking misc settings…

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check

I think the second hostgroup is my problem.

Here is my

/etc/adagios/adagios.conf

file:

# -- coding: utf-8 --

# nagios_config - Path to your nagios configuration file
# If set, adagios will use this file to manage your object
# definitions. If set to None, adagios will search most common
# paths like /etc/nagios/nagios.cfg for it
#nagios_config = “/etc/nagios/nagios.cfg”
nagios_config = “/etc/nagios/nagios.cfg”

# This should be the URL to your nagios server. If set, then
# Adagios can link you directly from configuration to live object.
# If you don’t need this feature. Set nagios_url to ‘’ or None
#nagios_url = “http://mynagiosserver/nagios
nagios_url = “/nagios”

# destination_directory - Where adagios will store new objects
# by default. You should make sure that this directory exists
# and nagios.cfg has a cfg_dir=/etc/nagios/adagios/
destination_directory = “/etc/nagios/adagios/”

# livestatus_path - Path to livestatus socket
livestatus_path = None
# enable_githandler - If set to true, and your /etc/nagios/ directory
# is a git repository. adagios will automatically commit changes when
# they are made.
enable_githandler = True

# enable_loghandler - If set to true, all changes adagios makes to
# object definitions will be logged to a file.
enable_loghandler = False

# auto_reload - If set to True, then nagios is reloaded automatically on
# changes. Not really recommended unless you are sure you want to fire
# a nagios reload after every single change.
auto_reload = False

# nagios_service - Service name used to start/stop nagios
# Adagios uses this to reload nagios after configuration changes
nagios_service = “nagios”

# nagios_init_script - Path to init script used to start/stop nagios
# Adagios uses this to reload nagios after configuration changes
nagios_init_script=“”

# nagios_binary - Path to your nagios binary
# Adagios uses this to run “nagios -v /etc/nagios/nagios.cfg”
nagios_binary=“/usr/sbin/nagios”

# escape_html_tags - Escape html tags in status view
# If this is enabled, html code in plugin outputs is escaped.
# If you set this to False, then plugins will be able to inject
# HTML code into adagios web interface
escape_html_tags = True

# warn_if_selinux_is_active - Check (and warn user) if selinux is running
# You should only turn this off if you have configured your selinux policy
# and know what you are doing
warn_if_selinux_is_active=True

# pnp_filepath - Path to pnp4nagios index.php
# This is used for integrated graphs into the status view
# if you do not use pnp or do not need the status view of adagios
# simply change this to any other file that exists
pnp_filepath=“/usr/share/nagios/html/pnp4nagios/index.php”

# contrib_dir - Path to user contributed views
contrib_dir = “/var/lib/adagios/contrib/”

# serverside_includes - Path to user contributed includes
# The files located in this directory can be used to include
# user contributed html into the header and footer of every page respectively
serverside_includes = “/etc/adagios/ssi”

# title_prefix - Title of every page is prefixed with this.
# You can customize this if you have multiple adagios instances
# and you want to distinguish the tabs in browser.
title_prefix = “Adagios -”

# enable_pnp4nagios - Enable pnp4nagios support (True by default).
# Disabling this removes the pnp mouse-over graphs as well as the graphs
# tab from the status views.
enable_pnp4nagios = True

# enable_graphite - Enable graphite integration with graphite
# If set to True, status_detail view of hosts and services
# Will show related graphs.
enable_graphite = False

# graphite_url - URL to your graphite instance
# If specified, and enable_graphite is set to True,
# connect to this graphite instance
graphite_url = “http://localhost:9091

# graphite_querystring - Customize the querystring that is sent to
# graphite’s /render? method. {host} {service} and {metric} will all
# be replaced with actual values while {host_} {service_} and {metric_}
# will apply common escaping techniques, i.e.: example.com becomes example_com
graphite_querystring = “target={host_}.{service_}.{metric_}&width=500&height=200&from={from_}d&lineMode=connected&title={title}&target={host_}.{service_}.{metric_}warn&target={host}.{service_}.{metric_}_crit”

# graphite_title - Put this string at the top of graphite graphs
graphite_title = “{host} - {service} - {metric}”

# Include configuration options from these config files
include=“/etc/adagios/conf.d/*.conf”

# Automaticly generated secret_key
django_secret_key = ‘fjh3ladr!hdq1kekebsps%(-lp!624eoa3q477xzxmqoh2pnyx’

Hi @m.traeumner!
That’s the culprit:

Nagios Core 4.0.8

As said in the how-to:

You have to use Nagios 3.5.1 core yet (we’ll take the rpm from one of these mirrors): that’s for a known limitation of Adagios mk-liveststatus implementation

The mk-livestatus error is generated by a known incompatibility with the Nagios version you adopted.

1 Like

I can’t remind that I’ve done an update but now I downgraded it

yum localinstall http://opensource.is/repo/ok-release.rpm -y

sed -i ‘s/rhel$releasever/rhel7/’ /etc/yum.repos.d/ok.repo

yum downgrade pnp4nagios nagios-plugins*
git adagios okconfig acl python-setuptools mk-livestatus
ftp://bo.mirror.garr.it/1/centos/7.3.1611/cloud/x86_64/openstack-newton/common/nagios-3.5.1-1.el7.x86_64.rpm

restored my nagios.cfg backup and it works fine again.

Thanks for your support

Know I now where nagios 4.0.8 comes from, after downgrading to 3.5.1 the Software-Center shows the update to 4.0.8. Is there a way to block it without installing every update in the terminal?

Yes, take a look at this:

1 Like

Hi @m.traeumner!

I added some how-to stuff to prevent nagios package update: check it out!:wink:

1 Like

Hi Nicola and Giacomo,
thanks for your answers, the exclusion of nagios update works. I did it with manually editing the template
nano /etc/e-smith… and after deleting it I tried with Nicolas way. Both works fine.
@nrauso
Did you change anymore in your howto?