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:
-
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
-
Install deps:
yum install -y git acl libstdc++-static python-setuptools pnp4nagios
-
Install Nagios 4 and Livestatus:
yum install -y nagios nagios-plugins-all nrpe check-mk-livestatus
-
Install Adagios and OKconfig:
yum --enablerepo=ok-testing install -y adagios okconfig pynag
-
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
-
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
-
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"
-
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
-
Make sure Nagios group will always have write access to the configuration files:
chown -R nagios:nagios /etc/nagios/* /etc/nagios/.git
-
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"
-
Patch adagios.conf file:
echo "ALLOWED_HOSTS = ['*']" >> /etc/adagios/adagios.conf
-
Add nagios to apache group so it has permissions to pnp4nagios session files:
usermod -G apache nagios
-
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$'
-
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
-
Set Apache basic auth password for Nagios/Adagios:
htpasswd /etc/nagios/passwd admin
-
Disable check_mk templates:
mkdir -p /etc/nagios/disabled
mv /etc/nagios/conf.d/check_mk_templates.cfg /etc/nagios/disabled
-
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
-
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
-
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!