457475451 发表于 2019-1-15 08:43:50

nagios+NRPE+pnp4nagios+ndoutils+mysql监控项目部署(2)

  六、pnp4nagios 安装:
./configure --prefix=/usr/local/pnp4nagios --with-nagios-user=nagios --with-nagios-group=nagios
make all
make install
make install-webconf
make install-config
make install-init
cd /usr/local/pnp4nagios/etc/
mv misccommands.cfg-sample misccommands.cfg
mv nagios.cfg-sample nagios.cfg
mv rra.cfg-sample rra.cfg
cd pages/
mv web_traffic.cfg-sample web_traffic.cfg
cd ../check_commands/
mv *.cfg{-sample,}
mv check_all_local_disks.cfg{-sample,}
mv check_nrpe.cfg{-sample,}
mv check_nwstat.cfg{-sample,}
/etc/init.d/npcd restart

七、nagios于pnp4nagios 结合
vim nagios.cfg
process_performance_data=1
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata

vim commands.cfg
##添加

define command {
      command_name process-service-perfdata
      command_line/usr/local/pnp4nagios/libexec/process_perfdata.pl
      }
define command {
      command_nameprocess-host-perfdata
      command_line/usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
      }
vim templates.cfg
define host {
      name          host-pnp
      action_url    /pnp4nagios/index.php/graph?host=$HOSTNAME$
      register   0
      }
define service {
      name         srv-pnp
      action_url   /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
      register   0
      }
八、 远程主机和本地主机安装nrpe
./configure --prefix=/usr/local/nrpe
make
make install
vi /etc/rc.local
/diska/mysqldata/bin/mysqld_safe --defaults-file= /mysqldata/my.cnf &
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
vi /usr/local/nrpe/etc/nrpe.cfg
allowed_hosts=127.0.0.1, 192.168.1.157#(监控服务器)
vi /etc/services
nrpe            5666/tcp                        #NRPE
九、NDOUTILS安装
./configure --prefix=/usr/local/nagios --enable-mysql LDFLAGS=-L/usr/local/mysql/lib--with-ndo2db-user=nagios --with-ndo2db-group=nagios
Make 出错
In file included from io.c:11:
../include/config.h:261:25: error: mysql/mysql.h: No such file or directory
../include/config.h:262:26: error: mysql/errmsg.h: No such file or directory
make: *** Error 1
make: Leaving directory `/nagios/ndoutils-1.5.2/src'
make: *** Error 2
vi include/config.h.in
#include
#include
修改为
#include
#include > /etc/rc.local 开机自动启动

vi ndo2db.cfg
socket_type=tcp

vim ndomod.cfg
output_type=tcpsocket
output=127.0.0.1

修改ndo2db.cfgndomod.cfg属性为nagios
查看nagios.log日志,是否启动成功。
ndomod: Successfully connected to data sink.0 queued items to flush.
Event broker module '/usr/local/nagios/bin/ndomod-3x.o' initialized successfully.
Finished daemonizing... (New PID=14849)

十、添加监控主机:(chenck_system为自写脚本,可监控disk|mem|cpu|swap|load|ping)
1、host158.cfg
define host{
      use host-pnp
      host_name host158
      alias   host158
      contact_groups                  admins
      check_command            check-host-alive
      max_check_attempts          5
      notification_interval      10
      notification_period         24x7
      notification_options      d,u,r
      address 192.168.1.158
      }


define service{
      use   generic-service,srv-pnp
      host_name host158
      service_description load
      check_command check_nrpe!check_load!15,10,5 30,25,20
      contact_groups   admins
      }

define service{
      use   generic-service
      host_name host158
      service_description disk
      check_command check_nrpe!check_system!disk 80 90
      contact_groups   admins
      }
define service{
      use   generic-service,srv-pnp
      host_name host158
      service_description memonry
      check_command check_nrpe!check_system!mem 95 98
      contact_groups   admins
      }
define service{
      use   generic-service,srv-pnp
      host_name host158
      service_description cpu
      check_command check_nrpe!check_system!cpu 70 80
      contact_groups   admins
      }

define service{
      use   generic-service,srv-pnp
      host_name host158
      service_description swap
      check_command check_nrpe!check_system!swap 80 90
      contact_groups   admins
      }

define service{
      use   generic-service,srv-pnp
      host_name host158
      service_description PING
      check_command check_ping!100.0,20%!500.0,60%
      contact_groups   admins
      }

2、定义监控报警联系人
vim contacts.cfg
define contact{
      contact_name                  nagiosadmin             ;
      use                           generic-contact         ;
alias                           Nagios Admin            ;      service_notification_period   24x7
      host_notification_period         24x7
      service_notification_options    w,u,c,r
      host_notification_options      d,u,r
      service_notification_commands   notify-service-by-email               
      host_notification_commands      notify-host-by-email
      email                           13928860402@139.com   ;
      }
3、         客户端和服务端同时添加nrpe命令
nrpe.cfg文件修改一下内容:
command=/usr/local/nagios/libexec/check_load -w $ARG1$ -c $ARG2$
command=/usr/local/nagios/ownlibexec/check_system -d $ARG1$ -w $ARG2$ -c $ARG3$
check_system 脚本上传至
/usr/local/nagios/ownlibexec/check_system,修改文件属性
重启nrpe。

十一、重启nagios,nrpe,检查搭建情况




页: [1]
查看完整版本: nagios+NRPE+pnp4nagios+ndoutils+mysql监控项目部署(2)