现在回过头来看第一次安装nagios的记录,发现安装真的很简单,自己的安装记录显得很简单。由于要生产环境应用,所以学了点nagios的东西,在google、baidu也search了很多,发现internet上的也是以安装的介绍居多,自己的安装记录相比较就差了许多,不过也懒,不想该了,将在下篇blog写下自己对nagios configure的理解,网上这方面介绍较少。

==========================================

这是nagios的监控端配置,被监控端配置将在下篇blog记录,本人将在应用中不断修改本篇blog。

nagios的介绍就不罗嗦了,直接看安装:

1、 安装前环境

OS:centos5.4   关闭selinux

httpd、php、gcc、gd、glibc、ssl(openssl和openssl-devel)

nagios3.3 监控端安装记录

[email protected]:[/usr/local/nagios]rpm -qa | grep ssl
openssl-0.9.8e-12.el5
openssl097a-0.9.7a-9.el5_2.1
openssl-devel-0.9.8e-12.el5

其实apache不需要到网络上下载,在linux OS 的安装包里就有,在上面忘了说明,安装httpd*.rpm一些包就可以了,另外在安装rpm包的时候,如果碰到A依赖B,B依赖C,而C又依赖A的时候,在rpm -ivh C.rpm --nodeps 即可安装。

关闭selinux

在命令行:#setenforce 0
在修改/etc/seliunx/config  中 SELINUX=disabled

在chkconfig --level 345 selinux off

 

下载文件

nagios3.3 监控端安装记录

 创建用户并设置密码:

/usr/sbin/useradd -m nagios
passwd nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache

 安装apache

nagios3.3 监控端安装记录

检查有没有apache用户 nagios3.3 监控端安装记录

启动apache的服务,并输入http://IP ,如果出现“IT WORKS” ,apache安装没有问题。

2、 安装

nagios安装

   44  tar -xzf nagios-3.3.1.tar.gz
   45  ls
   46  cd ./nagios
   47  ls
   48  less INSTALLING
   49  ls ./html/
   50  ls ./html/docs/
   51  less INSTALLING
   52  ./configure --with-command-group=nagcmd
   53  make all
   54  make install
   55  make init
   56  make install-init
   57  make install-commandmode
   58  make install-config
   59  make install-webconf
   65  make install-exfoliation
   66  make install-classicui

中间去掉了一些不要的步骤。

配置web登陆用户名和密码
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

记住这个密码,是登录web nagios时的用户名和密码

nagios-plugin 安装

   84  tar -xzf nagios-plugins-1.4.15.tar.gz
   85  ls
   86  cd ./nagios
   87  cd ../nagios-plugins-1.4.15
   88  ls
   89  ./configure --with-nagios-user=nagios --with-nagios-group=nagios
   90  make all
   91  make install
 

nrpe 安装
   94  tar -xzf nrpe-2.13.tar.gz
   95  ls
   96  cd ./nrpe-2.13
  130  ./configure --enable-ssl --enable-command-args
  131  make all
  132  make install
  133  make install-plugin
  134  make install-daemon
  135  make install-daemon-config
中间缺失的步骤是处理ssl的问题。

 vi ./etc/objects/commands.cfg  添加如下内容:

define command{
     command_name check_nrpe
     command_line /usr/local/nagios/libexec/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
     }

 3、 初步配置

配置为服务启动

  145  chkconfig --add nagios
  146  chkconfig --level 345 nagios on

测试nagios 配置文件是否正确

147  ./bin/nagios -v ./etc/nagios.cfg
出现
Total Warnings: 0
Total Errors:   0

说明nagios 配置没有问题

修改windwos监控模板

vi /usr/local/nagios/etc/nagios.cfg
#cfg_file=/usr/local/nagios/etc/objects/windows.cfg 去掉#

先重启httpd:

  176  killall httpd
  177  /etc/init.d/httpd start

启动nagios服务:

./bin/nagios -d ./etc/nagios.cfg 

发现一个有趣的事情:如果用/usr/local/apache2/bin/httpd 启动,即默认调用/usr/local/apache2/conf/httpd.conf时,无法打开http://ip/nagios

必须用/etc/init.d/httpd start启动,调用/etc/httpd/conf/httpd.conf启动,此时目录改变为:/var/www/html。查看/etc/init.d/httpd的内容如下:

#!/bin/bash
#
# httpd        Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server.  It is used to serve \
#           HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid
这时nagios启动正常。以上原因可能是在安装nagios时,make install-webconf生产有/etc/httpd目录及配置。不过我没验证过,只是猜测!呵呵

 用nagiosadmin和设置的密码登录:http://ip/nagios

nagios3.3 监控端安装记录