写给自己 :linux运维,自己动手趟一遍
目前越来越多的人都开始使用centos7了,就像win7超越xp一样,新技术永远是越来越让人慢慢接受的。为了快速布暑,全部使用yum安装。
环境
监控服务器:192.168.88.21
被监控客户端:192.168.88.22
关闭防火墙(全部服务器)
#systemctlstopfirewalld #systemctldisablefirewalld #setenforce0 #sed-i's/SELINUX=enforcing/SELINUX=disabled/g'/etc/selinux/config
更新时间同步(全部服务器)
#yuminstallntpdate #ntpdatecn.pool.ntp.org #echo"*/5****/usr/sbin/ntpdatecn.pool.ntp.org">>/var/spool/cron/root
安装epel源(全部服务器)
#yuminstallepel-release
-----------------------------------------------------------------------
服务器端安装(192.168.88.21)
#yuminstallmariadb-servermariadb//默认数据库 #yuminstallhttpdPHPPHP-gd//apache+PHP环境 #yuminstallnagiosnagios-plugins-allnagios-plugins-nrpenrpe #systemctlstartmariadb #MysqL_secure_installation//初始化数据库
设置nagios访问用户名和密码,使用默认nagiosadmin和默认保存位置,省心
#htpasswd-c/etc/nagios/passwdnagiosadmin回车,设置密码
#systemctlstartmariadb #systemctlstarthttpd #systemctlstartnagios
登陆http://192.168.88.21/nagios/ 输入之前设置的用户名 nagiosadmin 及密码,就可以登入了。
----------------------------------------------------------------------
监控服务器端(192.168.88.21) 配置
添加nrpe的定义
#vi/etc/nagios/objects/commands.cfg
#'check_nrpe'commanddefinition definecommand{ command_namecheck_nrpe command_line$USER1$/check_nrpe-H$HOSTADDRESS$-c$ARG1$ } #'check_nrpe_memory'commanddefinition definecommand{ command_namecheck_nrpe_memory command_line$USER1$/check_nrpe-H$HOSTADDRESS$-ccheck_mem }
新建监控主机配置文件
#vi/etc/nagios/objects/hosts.cfg definehost{ uselinux-server host_name192.168.88.22 alias192.168.88.22 address192.168.88.22 }
新建监控服务配置文件
#vi/etc/nagios/objects/services.cfg defineservice{ uselocal-service host_name192.168.88.22 service_descriptioncheck-host-alive check_commandcheck-host-alive } defineservice{ usegeneric-service host_name192.168.88.22 service_descriptionDiskPartition check_commandcheck_nrpe!check_disk } defineservice{ usegeneric-service host_name192.168.88.22 service_descriptionload check_commandcheck_nrpe!check_load } defineservice{ usegeneric-service host_name192.168.88.22 service_descriptionmemory check_commandcheck_nrpe_memory } defineservice{ usegeneric-service host_name192.168.88.22 service_descriptionswap check_commandcheck_nrpe!check_swap }
#nagios-v/etc/nagios/nagios.cfg检测配置文件是否正确 #systemctlrestartnagios重启一下nagios
----------------------------------------------------------------------
监控客户端安装(192.168.88.22):
安装被监控的插件及nrpe
#yuminstallnagios-plugins-nrpenrpenagios-plugins-all
配置nrpe
#vi/etc/nagios/nrpe.cfg allowed_hosts=127.0.0.1,192.168.88.21#允许被服务器监控 command[check_disk]=/usr/lib64/nagios/plugins/check_disk-w20%-c10% command[check_swap]=/usr/lib64/nagios/plugins/check_swap-w20%-c10% command[check_iostat]=/usr/lib64/nagios/plugins/check_iostat-dsda-w1000-c2000 command[check_mem]=/usr/lib64/nagios/plugins/check_mem-w80-c70 #echo'nrpe:192.168.88.21'>>/etc/hosts.allow
check_iostat所需要命令
#yuminstallsysstatbc
check_mem和check_iostat这二个检测插件,
请看附件下载,并解压到/usr/lib64/nagios/plugins 目录下
记得加执行权限
#chmod+xcheck_iostatcheck_mem
启动nrpe
#systemctlstartnrpe
---------------------------------------------------
打开浏览器,查看一下,是否能正常监控到数据了:
原文链接:/centos/377932.html