设为首页 收藏本站
查看: 865|回复: 0

linux 下nagios监控系统的配置

[复制链接]

尚未签到

发表于 2019-1-13 10:51:59 | 显示全部楼层 |阅读模式
  Nagios是一个监视系统运行状态和网络信息的监视系统。Nagios能监视所指定的本地或远程主机以及服务,同时提供异常通知功能可运行在Linux/Unix平台之上,同时提供一个可选的基于浏览器的WEB界面以方便系统管理人员查看网络状态,各种系统问题,以及日志等。
  工作原理图(取自网上)
  
  配置图
  
  一、配置前准备:

  1、同步两台机子时间
  ntpdate ntpdate time.nist.gov
  添加定时任务,每10分钟同步一次网络时间
  [root@mail ~]# crontab -l
  0-59/10 * * * * /usr/sbin/ntpdate time.nist.gov
  2、环境安装

  安装gcc编译工具
  [root@resin ~]# yum install gcc glibc glibc-common
  安装gd库
  yum install gd gd-devel
  安装lamp
  yum install php*
  yum install httpd
  安装mysql
  yum install mysql mysql-server mysql-devel
  3、添加nagios 所需的组及用户
  useradd  nagios
  passwd nagios
  groupadd nagios
  usermod -a -G nagios nagios
  usermod -a -G nagios apache
  检查组信息
  id apache
  id -n -G nagios
  

  二、
  nagios-server端配置
  1、下载所需安装包
  nagios、nagios-plugins、nrpe
  解压
  tar -zxf nagios-3.3.1.tar.gz
  tar -zxf nagios-plugins-1.4.14.tar.gz
  tar -zxf nrpe-1.8.tar.gz
  创建目录并将解压文件移至目录下
  [root@resin ~]# mkdir /var/application/nagios -p
  [root@resin ~]# mv nagios /var/application/nagios/
  [root@resin ~]# mv nagios-plugins-1.4.14 /var/application/nagios/
  [root@resin ~]# mv nrpe-1.8  /var/application/nagios/

  2、编辑安装nagios

  进入nagios目录
  cd /var/application/nagios/nagios
  编译
  ./configure --with-command-group=nagios --enable-even-broker
  make all

  make install
  make install-init
  make install-commandmode
  make install-config
  安装nagios web配置文件
  make install-webconf
  创建web登陆用户nagiosadmin
  htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
  cat /usr/local/nagios/etc/htpasswd.users

  添加监控报警接收email地址
  vi /usr/local/nagios/etc/objects/contacts.cfg +35

  需要启动postfix
  [root@resin nagios]# service postfix start
  Starting postfix: [  OK  ]
  启动httpd
  service httpd start
  添加服务自启动
  chkconfig --add nagios
  chkconfig --level 3 nagios
  

  检查配置文件语法
  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  /etc/init.d/nagios checkconfig

  启动nagios
  /etc/init.d/nagios start
  ps -ef |grep nagios |grep -v grep

  在win下测试登陆,如下表示安装成功

  3、编译安装nagios-plugins
  ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules
  make
  make install
  检查插件个数
  ls /usr/local/nagios/libexec/ |wc -l

  4、编译安装nrpe
  ./configure
  make all
  make install-plugin
  make install-daemon
  make install-daemon-config
  注意nrpe启动依赖于xinetd服务,若没有需先安装
  [root@resin nrpe-1.8]# service xinted start
  xinted: unrecognized service
  解决: [root@resin nrpe-1.8]#  yum -y install xinetd
  [root@resin nrpe-1.8]# service xinetd restart
  Stopping xinetd: [FAILED]
  Starting xinetd: [  OK  ]
  

  nrpe端口为5666,检查启动

  

  5、本机测试nrpe
  [root@mail nrpe-1.8]#  /usr/local/nagios/libexec/check_nrpe -H localhost -c check_load
  OK - load average: 0.06, 0.08, 0.16|load1=0.060;15.000;30.000;0; load5=0.080;10.000;25.000;0; load15=0.160;5.000;20.000;0;
  

  三、nagios-client端配置
  1、编译安装nagios-plugins(同服务端安装)
  ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules
  make
  make install
  ls /usr/local/nagios/libexec/ |wc -l
  

  2、编译安装nrpe
  ./configure
  make all
  make install-plugin
  make install-daemon
  make install-daemon-config
  

  四、Server端实现监控Client端
  

  1、nagios-server编辑nrpe配置文件
  vi /etc/xinetd.d/nrpe

  编辑nagios配置文件,添加监控实例
  [root@mail ~]# vi /usr/local/nagios/etc/nagios.cfg
  # Definitions for monitoring the Linux host
  cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg
  复制localhost.cfg 成实例文件mylinux.cfg
  cp -r /usr/local/nagios/etc/objects/localhost.cfg /usr/local/nagios/etc/objects/mylinux.cfg
  修改实例文件mylinux.cfg
  vi /usr/local/nagios/etc/objects/mylinux.cfg


  ....部分监控内容省略,内容可以根据需求调整。
  

  2、naggios-client编辑nrpe.cfg

  完成后,重启:
  pkill nrpe
  [root@mail ~]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
  

  3、Server主机测试
  /usr/local/nagios/libexec/check_nrpe -H 192.168.6.129 -c check_total_procs
  [root@mail ~]# /usr/local/nagios/libexec/check_nrpe -H 192.168.6.129 -c check_total_procs
  PROCS OK: 79 processes
  

  五、测试
  通过web页面测试



  至此简单nagios监控配置完成。
  

  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-662670-1-1.html 上篇帖子: nagios 监控交换机端口 下篇帖子: zabbix与nagios对比
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表