This post is to document my Nagios Core 4.4.6 and NagiosQL 3.4.1 installation on CentOS 7. They are the latest available version at the time of this writing (May 2020).
The main reason of this post is I cannot find the updated instruction to install the latest version of NagiosQL on CentOS 7. When I follow the instruction on the outdated blog posts, I run into some issues. For example, the official CentOS 7 repository only has PHP 5.4, but NagiosQL 3.4.1 requires PHP 5.5.0 or later; and MySQL is no longer in CentOS repository. Another reason is I want to install the latest version packages (e.g. PHP 7.4), instead of the older version.
Nagios Core and Nagios Plugins Installation on CentOS 7
I follow the instruction on Nagios Support Knowledgebase without any major issue. The only modification is to get the latest version of Nagios Core 4.4.6, instead of 4.4.5; and the latest version of the Nagios Plugin 2.3.3, instead of 2.2.1.
NagiosQL Installation on CentOS 7
1. Install PHP 7.4 from Remi and EPEL repositories
As I mention earlier, the official CentOS 7 repository only has PHP 5.4. This doesn’t meet the NagiosQL 3.4.1 requirement. You can check the installed PHP version by php -v
.
yum install epel-release
yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum install yum-utils
### install PHP 7.4
yum-config-manager --enable remi-php74
yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
### verify PHP 7.4 is installed
php -v
2. Install MySQL from the community repository
I follow the instruction on this post without any issue.
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
yum install mysql-server
systemctl start mysqld
### change MySQL root password, remove anonymous user accounts, disable root logins outside of localhost, and remove test databases
mysql_secure_installation
3. Install NagiosQL required packages
yum install libssh2 libssh2-devel mysql php-mysql php-pear php-devel
### install ssh2.so version 1.2 beta that support PHP 7.4
pecl install ssh2-1.2
### add extension=ssh2.so to /etc/php.ini under Dynamic Extensions
vi /etc/php.ini
4. Download and extract NagiosQL 3.4.1 archive in Nagios document root (/usr/local/nagios/share)
cd /usr/local/nagios/share
curl -L -O https://downloads.sourceforge.net/project/nagiosql/nagiosql/NagiosQL%203.4.1/nagiosql-3.4.1-git2020-01-19.tar.gz
tar xzf nagiosql-3.4.1-git2020-01-19.tar
mv nagiosql-3.4.1 webadmin
chown -R nagios:nagios webadmin/
### create the NagiosQL configuration directory
mkdir /usr/local/nagios/nagiosql
chown -R apache:apache /usr/local/nagios/nagiosql/
5. Set up PHP Timezone and restart Apache web server
See here to get the list of timezone
### set date.timezone = 'America/Los_Angeles'
vi /etc/php.ini
systemctl restart httpd
6. Start NagiosQL web installer
- Open the URL in a browser: http://nagiosserver/nagios/webadmin/install/index.php
- Click Start Installation
- Verify the system meets all the requirements. Here is where I found out the PHP 5.4 in CentOS 7 doesn’t meet the requirement
- Click Next
- On NagiosQL Installation: Setup page
- Enter NagiosQL DB password, root password (the root password is MySQL root password), and NagiosQL admin password
- Check the checkboxes
- “Drop database if already exists?”
- “Import Nagios sample config?” (optional)
- “Create NagiosQL config paths?”
- set NagiosQL config path: /usr/local/nagios/nagiosql
- set Nagios config path: /usr/local/nagios/etc
- Click Next
- On NagiosQL Installation: Finishing Setup page, it should be all green if everything is right
- Delete the NagiosQL install directory
7. Access NagiosQL web UI
- Open the URL in a browser: http://nagiosserver/nagios/webadmin
- login with NagiosQL admin and password
8. Integrate NagiosQL with Nagios
9. Verify Nagios Core config files
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
When I run the above command, I get the error message of missing command.cfg file, etc. I go back to NagiosQL web UI, in each main section Supervision, Alerting, Commands, and Specialties, click “Write config file” to generate these files. Then the command reports no error or warning.
10. Restart Nagios Core service
systemctl restart nagios
Now Nagios Core and NagiosQL are successfully set up. You can view the monitoring status in the Nagios web UI and modify the monitoring via NagiosQL web UI.