Adagios installation on NethServer 7.x with Nagios 4

Hi all!
Some good news from monitoring world: new Adagios version is out and now - finally - supports Nagios 4!
Here’s the steps to go through the installation:

  1. Install additional repos and update them:

    rpm -ihv http://opensource.is/repo/ok-release.rpm
    rpm -Uvh https://labs.consol.de/repo/stable/rhel7/x86_64/labs-consol-stable.rhel7.noarch.rpm
    yum update -y ok-release

  2. Install deps:

    yum install -y git acl libstdc++-static python-setuptools pnp4nagios

  3. Install Nagios 4 and Livestatus:

    yum install -y nagios nagios-plugins-all nrpe check-mk-livestatus

  4. Install Adagios and OKconfig:

    yum --enablerepo=ok-testing install -y adagios okconfig pynag

  5. 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

  6. 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

  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. 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
    pynag config --append cfg_dir=/etc/nagios/commands

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

    chown -R nagios:nagios /etc/nagios/* /etc/nagios/.git

  10. Add check_mk livestatus broker module to nagios config

    pynag config --append "broker_module=/usr/lib64/check_mk/livestatus.o /var/spool/nagios/cmd/livestatus"

  11. Patch adagios.conf file:
    echo "ALLOWED_HOSTS = ['*']" >> /etc/adagios/adagios.conf

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

    usermod -G apache nagios

  13. Configure PNP4Nagios:

    pynag config --set "process_performance_data=1"

    pynag config --set 'service_perfdata_file=/var/log/pnp4nagios/service-perfdata'

    pynag config --set 'service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$'

    pynag config --set 'service_perfdata_file_mode=a'
    pynag config --set 'service_perfdata_file_processing_interval=15'
    pynag config --set 'service_perfdata_file_processing_command=process-service-perfdata-file'

    pynag config --set 'host_perfdata_file=/var/log/pnp4nagios/host-perfdata'

    pynag config --set 'host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$'

    pynag config --set 'host_perfdata_file_mode=a'
    pynag config --set 'host_perfdata_file_processing_interval=15'
    pynag config --set 'host_perfdata_file_processing_command=process-host-perfdata-file'

    pynag add command command_name=process-service-perfdata-file command_line='/bin/mv /var/log/pnp4nagios/service-perfdata /var/spool/pnp4nagios/service-perfdata.$TIMET$'

    pynag add command command_name=process-host-perfdata-file command_line='/bin/mv /var/log/pnp4nagios/host-perfdata /var/spool/pnp4nagios/host-perfdata.$TIMET$'

  14. Optional - Configure Environment variables Nagios systemd service, for example update PERL5LIB path so that nagios user loads correct perl library:

    mkdir /etc/systemd/system/nagios.service.d
    echo -e "[Service]\nEnvironment=\"PERL5LIB=\$PERL5LIB:/var/spool/nagios/perl5_custom_lib\"" > /etc/systemd/system/nagios.service.d/env.conf

    systemctl daemon-reload

  15. Set Apache basic auth password for Nagios/Adagios:

    htpasswd /etc/nagios/passwd admin

  16. Disable check_mk templates:

    mkdir -p /etc/nagios/disabled
    mv /etc/nagios/conf.d/check_mk_templates.cfg /etc/nagios/disabled

  17. 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

  18. Enable and start new services

    systemctl enable --now nagios
    systemctl enable --now npcd
    systemctl enable --now nrpe
    systemctl restart httpd

    signal-event runlevel-adjust
    signal-event firewall-adjust

  19. Fix permission in logrotate fragment:

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

Here we go! Adagios up’n’running! You can reach it at url:

https://ns_ip_or_name/adagios

user: admin
pass: the one you chose!

Copy/paste helper
rpm -ihv http://opensource.is/repo/ok-release.rpm
rpm -Uvh https://labs.consol.de/repo/stable/rhel7/x86_64/labs-consol-stable.rhel7.noarch.rpm
yum update -y ok-release
yum install -y git acl libstdc++-static python-setuptools pnp4nagios
yum install -y nagios nagios-plugins-all nrpe
yum install -y check-mk-livestatus
yum --enablerepo=ok-testing install -y adagios okconfig pynag
sed -i 's/use_syslog=1/use_syslog=0/' /etc/nagios/nagios.cfg
touch /var/www/html/apacheok
sed -i 's/check_http/check_http!-u \/apacheok/' /etc/nagios/objects/localhost.cfg
cd /etc/nagios/
git init
git config user.name "yourname"
git config user.email "yourname@yourdomain.com"
git add *
git commit -m "Initial commit"
mkdir -p /etc/nagios/adagios
pynag config --append cfg_dir=/etc/nagios/adagios
pynag config --append cfg_dir=/etc/nagios/commands
chown -R nagios:nagios /etc/nagios/* /etc/nagios/.git
pynag config --append "broker_module=/usr/lib64/check_mk/livestatus.o /var/spool/nagios/cmd/livestatus"
echo "ALLOWED_HOSTS = ['*']" >> /etc/adagios/adagios.conf
usermod -G apache nagios
pynag config --set "process_performance_data=1"
pynag config --set 'service_perfdata_file=/var/log/pnp4nagios/service-perfdata'
pynag config --set 'service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$'
pynag config --set 'service_perfdata_file_mode=a'
pynag config --set 'service_perfdata_file_processing_interval=15'
pynag config --set 'service_perfdata_file_processing_command=process-service-perfdata-file'
pynag config --set 'host_perfdata_file=/var/log/pnp4nagios/host-perfdata'
pynag config --set 'host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$'
pynag config --set 'host_perfdata_file_mode=a'
pynag config --set 'host_perfdata_file_processing_interval=15'
pynag config --set 'host_perfdata_file_processing_command=process-host-perfdata-file'
pynag add command command_name=process-service-perfdata-file command_line='/bin/mv /var/log/pnp4nagios/service-perfdata /var/spool/pnp4nagios/service-perfdata.$TIMET$'
pynag add command command_name=process-host-perfdata-file command_line='/bin/mv /var/log/pnp4nagios/host-perfdata /var/spool/pnp4nagios/host-perfdata.$TIMET$'
mkdir /etc/systemd/system/nagios.service.d
echo -e "[Service]\nEnvironment=\"PERL5LIB=\$PERL5LIB:/var/spool/nagios/perl5_custom_lib\"" > /etc/systemd/system/nagios.service.d/env.conf
systemctl daemon-reload
mkdir -p /etc/nagios/disabled
mv /etc/nagios/conf.d/check_mk_templates.cfg /etc/nagios/disabled
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
systemctl enable --now nagios
systemctl enable --now npcd
systemctl enable --now nrpe
systemctl restart httpd
signal-event runlevel-adjust
signal-event firewall-adjust
sed -i "2isu nagios nagios" /etc/logrotate.d/okconfig
htpasswd /etc/nagios/passwd admin

Have a nice monitoring! :wink:

4 Likes

Niiiiice howto @nrauso! :+1: :clap: I tested it and it works like a charm.
I just added check-mk-livestatus to the yum install line in step 3 and a copy/paste helper at the end for the impatient.

3 Likes

Thanks for the revision and the test @mrmarkuz!!

1 Like