bdjhx 发表于 2019-1-14 08:41:02

安装配置nagios

  一、安装nagios前的准备工作

  1.解决安装Nagios的依赖关系:Nagios基本组件的运行依赖于httpd、gcc和gd
  
  2. 所需要安装组件:
  服务端所用的安装包为 nagios nagios-plugins
  linux客户端 nrpe
  windows客户端 NSClient++
  二.下载需求软件

  nagios主程序:wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz
  nagios插件程序:wget http://down1.chinaunix.net/distfiles/nagios-plugins-1.4.13.tar.gz
  apache程序:wget http://autosetup1.googlecode.com/files/httpd-2.2.11.tar.gz
  php程序:wget http://museum.php.net/php5/php-5.3.0.tar.gz
  三.编译安装nagios
  1.tar zxf nagios-3.1.2.tar.gz
  #   cd nagios-3.1.2
  
#./configure --enable-event-broker--prefix=/usr/local/nagios
#make all
#make install
#make install-init
#make install-config
#make install-commandmode
在httpd的配置文件目录(conf.d)中创建Nagios的Web程序配置文件:
   # make install-webconf

创建一个登录nagiosweb程序的用户,这个用户帐号在以后通过web登录nagios认证时所用:
# htpasswd -c/var/www/nagios/etc/htpasswd.users nagiosadmin
2.编译安装nagios-plugins
nagios的所有监控工作都是通过插件完成的,因此,在启动nagios之前还需要为其安装官方提供的插件。
tar zxf nagios-plugins-1.4.13.tar.gz

  #cd nagios-plugins-1.4.13
  #./configure --with-nagios-user=nagios --with-#nagios-group=nagios -with-mysql
  #make
  #make install
  4.配置并启动Nagios
  /etc/init.d/nagios start
  注:如果启动时会报错

  
  Error: Cannot open main configuration file '/root/nagios-plugins-1.4.13/start' for reading!
  Nagios 3.1.2 starting... (PID=14327)
  Local time is Fri Feb 28 02:52:22 CST 2014
  Bailing out due to one or more errors encountered in the configuration files. Run Nagios from the command line with the -v option to verify your config before restarting. (PID=14327)
  使用: /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg检查配置文件没有发现错误

  可使用:/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg 尝试启动

  启动成功之后 可以使用top命令查看是否有nagios进程(有nagios进程说明启动成功)
  
  注: service nagios restart 启动时再次失败
  
  Running configuration check...done.
  Stopping nagios: done.
  Starting nagios:su: warning: cannot change directory to /home/nagios: No such file or directory
  This account is currently not available.
  done.
  可以使用: mkdir /home/nagios 解决

   service nagios restart 如果启动时仍然失败 但错误提示是:
  Running configuration check...done.
  Stopping nagios: done.
  Starting nagios:This account is currently not available.
  done.
  可以在:vi/etc/passwd
  找到此行:nagios:x:500:500::/home/nagios:/sbin/nologin(注意红色字体),把此行改成如下一行
        nagios:x:500:500::/home/nagios:/bin/bash
  修改后再次重启 ,启动成功
  
  # service nagios restart
  Running configuration check...done.
  Stopping nagios: done.
  Starting nagios: done.
  




  


  

  








  


  



页: [1]
查看完整版本: 安装配置nagios