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

Nagios 安装文档

[复制链接]

尚未签到

发表于 2019-1-14 09:35:42 | 显示全部楼层 |阅读模式
  安装前的装备工作
  (1)解决安装Nagios的依赖关系:
  Nagios基本组件的运行依赖于httpd、gcc和gd。可以通过以下命令来检查nagios所依赖的rpm包是否已经安装完成:
  #yum -y install httpd gcc glibc glibc-common *gd* php php-mysql mysql mysql-server --skip-broken
  (2)所需要安装组件:
  服务端所用的安装包为 nagios nagios-plugins ndoutils(非必须)
  linux客户端 nrpe
  windows客户端NSClient++
  (3)运行selinux设置,或者关闭selinux
  开始搭建:
  (1)添加nagios运行所需要的用户和组:
  # groupadd nagcmd
  # useradd -m nagios
  # usermod -a -G nagcmd nagios
  把apache加入到nagcmd组,以便于在通过web Interface操作nagios时能够具有足够的权限:
  # usermod -a -G nagcmd nagios
  2、编译安装nagios:
  # tar zxf nagios-3.1.2.tar.gz     (英文)
  # tar jxf nagios-cn-3.2.3.tar.bz2 (中文)
  cd nagios-cn-3.2.3
  ./configure --with-command-group=nagcmd --enable-event-broker()
  # make all
  # make install
  # make install-init
  # make install-commandmode
  # make install-config
  为email指定您想用来接收nagios警告信息的邮件地址,默认是本机的nagios用户:
  #vi /user/local/nagios/etc/objects/contacts.cfg
  email nagios@localhost #这个是默认设置
  在httpd的配置文件目录{conf.d}中创建Nagios的Web程序配置文件:
  # make install-webconf
  创建一个登陆nagios web程序的用户,这个用户账号在以后通过web登陆nagios认证时所用:
  # htpasswd -c /usr/local/nagios/etc/htpasswd.user nagiosadmin
  密码 123456
  以上过程配置结束以后需要重新启动httpd:
  # service httpd restart
  3、编译安装nagios-plugins
  nagios的所有监控工作都是通过插件完成的,因此在启动nagios之前还需要为其安装官方提供的插件。
  # tar zxf nagios-plugins-1.4.15.tar.gz
  # cd nagios-plugins-1.4.15
  # ./configure --with-nagios-user=nagios --with-nagios-group=nagios
  #  make
  #  make install
  4、配置并启动Nagios
  (1)把nagios添加为系统服务并将加入到自动启动服务队列:
  # chkconfig --add nagios
  # chkconfig nagios on
  (2)检查其主配置文件的语法是否正确:
  # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  注释:CTM路径太长
  vim .bashrc
  PATH=$PATH:/usr/local/nagios/bin
  . .bashrc
  echo $PATH
  /usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/nagios/bin
  ln -sv /usr/local/nagios/etc/nagios.cfg /etc/nagios.cfg
  (3)如果上面的语法检查没有问题,接下来就可以正式启动nagios服务了:
  #service nagios start
  Starting nagios: done.
  (4)配置selinux
  如果您的系统开启了selinux服务,则默认为拒绝nagios web cgi程序的运行,您可以通过下面的命令来检查您的系统是不是开启了selinux:
  #getenforce
  如果上面命令的结构显示开启了selinux服务,您可以通过下面的命令暂时性的将其关闭:
  #getenforce 0
  如果您想在以后完全关闭selinux,可以通过编辑/etc/sysconfig/selinux文件,将其中的selinux后面的值"force"修改为"disable"即可。
  当然您也可以通过以下方式将nagios的CGI程序运行于SELinux/targeted模式而不用关闭selinux:
  #chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin
  #chcon -R -t httpd_sys_content_t /usr/local/nagios/share
  (5)通过web界面查看nagios:
  http://your_nagios_IP/nagios
  登陆时需要制定前面设定的web认证账号和密码.
  我在web下能访问,但是输入密码后提示
  Authorization Required
  This server could not verify that you are authorized to access the document requested.
  Either you supplied the wrong credentials (e.g., bad password), or your browser doesn't understand how to supply the credentials required.
  mv /usr/local/nagios/etc/htpasswd.user /usr/local/nagios/etc/htpasswd.users
  ###########################################################################################
  windows端
  1、被监控端安装NSClient++-0.3.8-win32.msi
  2、安装完成后修改配置文件NSC.ini把需要的库都打开
  FileLogger.dll
  CheckSystem.dll
  CheckDisk.dll
  NSClientListener.dll
  NRPEListener.dll
  SysTray.dll
  CheckEventLog.dll
  CheckHelpers.dll
  CheckWMI.dll
  CheckExternalScripts.dll
  NSCAAgent.dll
  LUAScript.dll
  NRPEClient.dll
  CheckTaskSched.dll
  [NSClient]
  ;# ALLOWED HOST ADDRESSES
  allowed_hosts=10.0.0.0/24
  ;# USE THIS FILE
  allowed_hosts=10.0.0.12
  检测服务
  netstat -a
  TCP    amdin-deed192de:5666   amdin-deed192de:0      LISTENING
  3、在监控服务器上修改nagios配置文件nagios.cfg
  去掉注释cfg_file=/usr/local/nagios/etc/object/windows.cfg
  定义windows.cfg
  define host{
  use           windows-server   ; Inherit default values from a template
  host_name     winserver        ; The name we're giving to this host
  alias         My windows Server; A longer name associated with the host
  address       10.0.0.13        ; 你主机的IP
  }
  ################################################################################
  linux端
  被监控端
  先添加nagios用户
  useradd nagios
  为了安装nrpe,先安装nagios-plugins-1.4.15.tar.gz
  #tar zxf nagios-plugins-1.4.15.tar.gz
  #cd nagios-plugins-1.4.15
  #./configure --with-nagios-user=nagios --with-nagios-group=nagios
  #make
  #make install
  tar -zxvf nrpe-2.1.2.tar.gz
  cd nrpe-2.1.2.tar.gz
  ./configure (会自动加载SSL)
  openssl openssl-devel
  #如果后面make报错,加如下参数
  ./configure --enable-ssl --with-ssl-lib=/usr/lib/(当然前提要有openssl)
  make all
  make install-plugin
  make install-daemon
  make install-daemon-config
  4、配置nrpe信息
  vim /usr/local/nagios/etc/nrpe.cfg
  allowed_hosts=127.0.0.1 //允许监控的IP
  /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
  服务端
  3、安装NRPE
  cd nagios-nrpe-2.1.2
  ./configure  #默认自动添加了openssl
  #因为传送过程要加密,如果后面make报错,加如下参数
  rpm -qa|grep ssl
  openssl-devel-0.9.7a-43.17.e14_6.1
  rpm -ql openssl-devel-0.9.7a-43.17.e14_6.1 | more
  ./configure --enable-ssl --with-ssl-lib=/usr/lib/(当然前提要有openssl)
  make all
  make install-plugin
  4、commands.cfg定义外部构件nrpe
  vi /usr/local/nagios/etc/object/commands.cfg
  #添加
  #check nrpe
  define command{
  command_name check_nrpe
  command_line $USER$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
  }
  定义 mylinux.cfg
  define host{
  use            linux-server
  host_name      mylinux
  alias          mylinux
  address       192.168.0.13(客户端IP既被监控的IP)
  }
  define service{
  use            generic-service
  host_name      mylinux
  service_description   check-swap
  check_command         check_nrpe!check_swap
  }
  define service{
  use            generic-service
  host_name      mylinux
  service_description   check-load
  check_command         check_nrpe!check_load
  }
  define service{
  use            generic-service
  host_name      mylinux
  service_description   check-disk
  check_command         check_nrpe!check_had1
  }
  define service{
  use            generic-service
  host_name      mylinux
  service_description   check-users
  check_command         check_nrpe!check_users
  }
  define service{
  use            generic-service
  host_name      mylinux
  service_description   otal_procs
  check_command         check_nrpe!check_total_procs
  }
  chown nagios.nagios *
  ##########################################################################################
  define service{
  use            generic-service
  host_name      mylinux
  service_description   httpd
  check_command         check_http! -H 192.168.0.13
  }
  ###########################################################################################
  飞信报警
  1、修改模板文件
  修改comncont.cfg
  2.
  修改
  commands.cfg
  define command{
  command_name notify-service-by-fetion
  command_line      /usr/bin/fetion --mobile 手机号 --pwd 123qweQWE --to 手机号码 --msg-type=0 --msg-utf8 $HOSTNAME


运维网声明 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-663039-1-1.html 上篇帖子: 开源网管软件比较 Zabbix, Nagios,Hyperic HQ,OpenNMS 之服务篇 下篇帖子: Integrate NDOUtils 1.5 and Nagvis 1.8b2 with Nagios 3.5
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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