欢迎来到之路教程(on itroad-com)

在 CentOS 7 上为 Nagios Core 安装 Lilac Reloaded Configurator

使用 Putty 登录 Nagios Monitoring Server 并安装 MySQL 数据库服务器。

[root@nagios03 ~]# yum install -y mariadb-server

启动并启用 mariadb 服务。

[root@nagios03 ~]# systemctl start mariadb.service
[root@nagios03 ~]# systemctl enable mariadb.service

配置 MySQL 服务器。

[root@nagios03 ~]# /usr/bin/mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
 ... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
 ... Success!
By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
 ... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
[root@nagios03 ~]#

为 Lilac Reloaded 创建数据库和用户。

[root@nagios03 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14
Server version: 5.1.73 Source distribution
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create database lilac;
Query OK, 1 row affected (0.00 sec)
mysql> create user 'lilac'@'localhost' identified by 'lilac';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on lilac.* to 'lilac'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@nagios03 ~]#

验证 PHP 版本。

[root@nagios03 ~]# php -v
PHP 5.3.3 (cli) (built: Aug 11 2016 20:33:53)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
[root@nagios03 ~]#

Lilac Reloaded 需要 PHP 5.5 ,因此,为了更新 PHP,我添加了 Webtatic yum 存储库以获取 PHP 5.5 包。

[root@nagios03 ~]# rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
Retrieving https://mirror.webtatic.com/yum/el6/latest.rpm
warning: /var/tmp/rpm-tmp.NZFWFl: Header V4 DSA/SHA1 Signature, key ID cf4c4ff9: NOKEY
Preparing...                ########################################### [100%]
   1:webtatic-release       ########################################### [100%]
[root@nagios03 ~]#

升级到 PHP 5.5.

[root@nagios03 ~]# yum search php55
[root@nagios03 ~]# yum remove php php-common
[root@nagios03 ~]# yum install php55w php55w-pear php55w-pdo php55w-mysql
[root@nagios03 ~]# service httpd restart

再次检查 PHP 版本。

[root@nagios03 ~]# php -v
PHP 5.5.38 (cli) (built: Jul 21 2016 12:51:12)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
[root@nagios03 ~]#

Lilac 需要 nmap 来自动发现网络设备,因此安装它。

[root@nagios03 html]# yum install nmap

从 https://sourceforge.net/projects/lilac--reloaded/ 下载丁香重新加载

[root@nagios03 ~]# cd /soft
[root@nagios03 soft]# wget https://sourceforge.net/projects/lilac--reloaded/files/latest/download
[root@nagios03 soft]# tar xvf download

将 lilac-reloaded 目录移动到 /var/www/html 并更改目录的所有权。

[root@nagios03 soft]# mv lilac-reloaded/ /var/www/html/
[root@nagios03 soft]# chown -R apache.apache /var/www/html/lilac-reloaded/

与 Nagios 一样,Lilac Reloaded 也没有自己的任何用户身份验证方法,因此启用基本 HTTP 身份验证,并使用与 Nagios 服务器相同的 htpassword 文件。

[root@nagios03 etc]# cat  >> /etc/httpd/conf.d/lilac.conf << EOF
>  <directory "/var/www/html/lilac-reloaded">
>  AuthType Basic
>  AuthName "Restricted Content"
>  AuthUserFile /usr/local/nagios/etc/htpasswd.users
>  Require valid-user
>  </directory>
> EOF
[root@nagios03 etc]# systemctl restart httpd.service

浏览到 http://nagios03.onitroad.com/lilac-reloaded/

如果此页面显示任何依赖错误,请解决它并单击继续配置...。

定义数据库和访问凭据,然后单击继续。

单击“导入 Nagios 设置”以导入 lilac 数据库中的配置。

创建导入作业并单击开始导入。

导入 Nagios 配置。

安装环境

CentOS 7 上 Nagios 监控服务器的工作实例。

  • 主机名 - nagios03.onitroad.com
  • IP 地址 - 192.168.229.134/24
  • Nagios 版本 - Nagios Core 4.4
在 CentOS 7 上为 Nagios Core 安装 Lilac Configurator

Nagios 是一个行业标准的服务器监控解决方案。

它非常简单、轻便且易于配置。
它的配置是由管理员(根据他的基础设施)为每个主机、服务、命令、联系人等在纯文本文件中定义的。
这些配置没什么大不了的,除非我们正在监控大型基础设施,我们必须经常更新设备定义、添加新主机、更换故障交换机等。
如果我们没有正确计划组织 Nagios 配置,那么维护配置的任务可能是一场噩梦。

幸运的是,有一些基于 Web 的配置器,例如 Fruity、Lilac Reloaded、NConf 等可用,可以减轻 Nagios 配置管理的任务。

在这篇文章中,我们将在 CentOS 7 上的 Nagios 核心服务器上安装 Lilac Reloaded Configurator。
Lilac Reloaded 使用 MySQL 作为其数据库后端,它是用 PHP 编写的。

日期:2020-09-17 00:16:43 来源:oir作者:oir