Linux 7.2 + LAMP + Nagios-4.2.4 + 简单部署监控项

Nagios详细文档

监控端

一、安装依赖包并设置Apache服务。

yum -y install httpd php gcc gd perl unzip openssl-devel

vi /etc/httpd/conf/httpd.conf

User nagios

Group nagios

<IfModule dir_module>

DirectoryIndex      index.php       index.html

</IfModule>

systemctl enable httpd

二、安装Nagios-Core包。

tar -xf nagios-4.2.4.tar.gz

useradd -s /sbin/nologin nagios

usermod -G nagios apache

cd nagios-4.2.4

./configure --with-command-group=nagios

make all

make install

make install-init

make install-commandmode

make install-config

make install-webconf

chkconfig --add nagios

chkconfig nagios on

三、安装Nagios扩展包。

tar -xf nagios-plugins-2.1.4.tar.gz

cd nagios-plugins-2.1.4

./configure --with-nagios-user=nagios --with-nagios-group=nagios

make && make install

四、安装nrpe插件。

tar -xf nrpe-3.0.1.tar.gz

cd nrpe-3.0.1

./configure

make all

make install-plugin

五、设置Nagios登陆用户与密码,并启动服务。

cat /etc/httpd/conf.d/nagios.conf

AuthUserFile /usr/local/nagios/etc/htpasswd.users

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

六、配置监控端

vim /usr/local/nagios/etc/objects/client-1.cfg

define host{

use                                        linux-server

host_name                         client-1

address                               192.168.20.20

}

define service{

use                                        local-service

host_name                         client-1

service_description          PING

check_command               check-host-alive

}

define service{

use                                        local-service

host_name                         client-1

service_description          HTTP

check_command               check_http

}

define service{

use                                        local-service

host_name                         client-1

service_description          BOOT-Usage

check_command               check_nrpe!check_sda1

}

define service{

use                                        local-service

host_name                         client-1

service_description          ROOT-Usage

check_command               check_nrpe!check_sda3

}

define service{

use                                        local-service

host_name                         client-1

service_description          USERS

check_command               check_nrpe!check_users

}

vim /usr/local/nagios/etc/objects/commands.cfg

define command{

command_name               check_nrpe

command_line          $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

}

vim /usr/local/nagios/etc/nagios.cfg

cfg_file=/usr/local/nagios/etc/objects/client-1.cfg

cfg_file=/usr/local/nagios/etc/objects/client-2.cfg

systemctl start httpd

systemctl start nagios

被监控端

一、安装依赖包。

yum -y install perl openssl-devel xinetd gcc

二、安装Nagios扩展包。

tar -xf nagios-plugins-2.1.4.tar.gz

useradd -s /sbin/nologin nagios

cd nagios-plugins-2.1.4

./configure

make && make install

三、安装nrpe插件

tar -xf nrpe-3.0.1.tar.gz

cd nrpe-3.0.1

./configure

make all

make install

make install-plugin

make install-daemon

make install-config

make install-inetd

make install-init

四、配置被监控端

vim /usr/local/nagios/etc/nrpe.cfg

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10

//定义监控登录用户数量的警告及严重错误的阈值分别为5和10

command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20

//定义监控本机CPU负载的警告及严重错误阈值,负载按最近1分钟,5分钟,15分钟分别计算

command[check_sda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1

//定义监控本机磁盘/dev/sda1的使用情况

command[check_sda3]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda3

//定义监控本机磁盘/dev/sda3的使用情况

command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z

//定义监控本机僵死进程的警告及严重错误阈值分别为5和10

command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200

//定义监控进程数量的警告及严重错误阈值分别为150和200

#allowed_hosts=127.0.0.1

vim /etc/xinetd.d/nrpe

only_from       = 127.0.0.1 192.168.20.10

systemctl start xinetd

systemctl enable xinetd

systemctl start nrpe

systemctl enable nrpe

在被监控端测试nrpe:

/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1

在监控端测试nrpe:

/usr/local/nagios/libexec/check_nrpe -H 192.168.20.20

上一篇:学习笔记 ACCESS 延迟注入


下一篇:Java高级-集合框架