jdgue 发表于 2019-1-16 14:09:04

centos 5.5安装nagios3.2.0(一)

Nagios功能列表
所需软件包及环境






NAGIOS
gcc、gcc-devel、appache、php、gd、gd-devel
NAGIOS-PLUGINS

NRPE
openssl-devel (Linux系统安装。监控端和被监控端)
NSCLIENT
无(windows系统安装,只安装在被监控端)




Pnp
cairo、 pango、 libart_lgpl、 libart_lgpl-devel、 zlib、 zlib-devel 、freetype 、freetype-devel
rrdtool






安装centos时候定制软件选择DNS服务和邮件服务.






Fetion
libACE
MSN




暂无测试

一:安装nagios
1:安装支持包
#yum -y install gcc gcc-c++ gd gd-devel php httpd openssl-devel
以上安装的支持对应的软件需求见上表
2:添加用户和组
#useradd nagios
#passwd nagios
#groupadd nagcmd
#usermod -G nagcmd nagios
#usermod -G nagcmd apache
记得把apache加入到该用户组
3:正式安装nagios
#tar –xzf nagios-3.2.0.tar.gz
#cd nagios-3.2.0
#./configure –with-command-group=nagcmd –profix=/usr/local/nagios
#make all
#make install
#make install-init
#make install-config
#make install-commandmode   
4:配置apache的httpd.conf,允许文件目录被访问
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"               
      
Options ExecCGI      
AllowOverride None   
Order allow,deny         
Allow from all      
AuthName "Nagios Access"   
AuthType Basic      
AuthUserFile /usr/local/nagios/etc/htpasswd.users      
Require valid-user      
      
Alias /nagios "/usr/local/nagios/share"   
      
Options None      
AllowOverride None      
Order allow,deny      
Allow from all      
AuthName "Nagios Access"   
AuthType Basic      
AuthUserFile /usr/local/nagios/etc/htpasswd.users   
Require valid-user      

5:创建apache目录验证文件
#htpasswd -c /usr/local/nagios/etc/htpasswd#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin   
#New password: (输入密码)   
#Re-type new password: (再输入一次密码)   
#Adding password for user nagiosadmin   
#service httpd restart
6:安装nagios插件\
#tar –xzf nagios-plugins-1.4.13.tar.gz
#cd nagios-plugins-1.4.13
#./configure –with—nagios-user=nagios –with-nagios-group=nagios –profix=/usr/local/nagios
#make
#make install
7:将nagios加入到开机启动项
#chkconfig –add nagios
#chkconfig nagios on
8:检查配置文件
#/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg
//这个检测非常有用,可以很快的判断我们的错误在哪里。
9:安装nrpe(用于监控Linux系统)
#tar –xzvf nrpe-2.12.tar.gz
#cd nrpe-2.12
#./configure
#make all
#make install-plugin
10:配置nagios。
首先/usr/local/nagios/etc/nagios.cfg,取消前面的”#”即可.如下:
# You can specify individual object config files as shown below:
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
# Definitions for monitoring the local (Linux) host
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
# Definitions for monitoring a Windows machine
#cfg_file=/usr/local/nagios/etc/objects/windows.cfg
# Definitions for monitoring a router/switch
#cfg_file=/usr/local/nagios/etc/objects/switch.cfg
# Definitions for monitoring a network printer
#cfg_file=/usr/local/nagios/etc/objects/printer.cfg

# You can also tell Nagios to process all config files (with a .cfg
# extension) in a particular directory by using the cfg_dir
# directive as shown below:
#cfg_dir=/usr/local/nagios/etc/servers

上面有些配置文件没有,需要自己手动创建
Commands.cfg主要是监控命令的配置文件。Contacts.cfg主要是联系人的配置文件
Timeperiods.cfg主要是时间配置,监控的时间段设置。Hots.cfg是主机配置.

Localhost.cfg监控服务器的配置文件.
Windows.cfg监控微软系统的配置文件.

上面是一个servers目录,这个需要手动创建在etc目录下。一般把需要监控的服务器配置文件放在该目录下。
12:配置contacts.cfg、commands.cfg

配置用户名,配置发送警告的邮件信箱,配置时间间隔。配置警告的类型,”;”表示注释该选项,有多个变量值使用”,”分开.
下图是commands.cfg的配置,使用检测3389端口的命令展示:

definecommand{
command_name    check_3389 //为该命令取个名字
command_line    $xxxxxxxxxxxx //使用到的命令
}
其他的命令写法类似。注意参数的变化,要根据不同的命令书写。不同的命令的参数可以在/usr/local/nagios/libexec下找到。比如要找到check_iftraffic这个命令的可用参数。使用以下的方式
#cd /usr/local/nagios/libexec
#./check_iftraffic –h
13 :被监控主机的配置(windows主机)
在被监控的主机上安装NSCLIENT++软件
安装完成之后,找到NSC.ini。编辑该ini文件。在下面除了
;CheckWMI.dll和;RemoteConfiguration.dll之外。其他.dll前面的”;”都取消。在下。配置allowed_hosts=127.0.0.1/32,172.16.59.4.
172.16.59.4就是监控主机的IP.
然后重起NSCLIENT服务。
14:在监控端配置被监控端的信息。这里使用172.16.75.231为例

在servers的目录下创建172.16.75.231_w.cfg文件。
#vi 172.16.75.231_w.cfg



页: [1]
查看完整版本: centos 5.5安装nagios3.2.0(一)