w5wfwe 发表于 2014-8-4 10:09:26

nagios安装

//***nagios是一款开源的免费网络监控工具,能有效监控windows、linux和unix的主机状态,交换机、路由器和打印机等。在系统或服务状态出现异常时发出邮件(或短信)报警,
通知运维人员,起到实时监控的作用。***//
**********nagios安装**********
1.安装RPMForge源

1
2
3
#wget http://apt.sw.be/redhat/el6/en/x86_64/RPMS.dag/rpmforge-release-0.3.6-1.el6.rf.x86_64.rpm
#rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
#rpm -Uhv rpmforge-release-0.3.6-1.el6.rf.x86_64.rpm




2.安装依赖包

1
#yum install gd fontconfig-devel libjpeg-devel libpng-devel gd-devel perl-GD openssl-devel php mailx postfix cpp gcc gcc-c++ libstdc++ glib2-devel libtoul-ltdl-devel -y




3.创建用户和组

1
2
3
#groupadd -g 6000 nagios   //***nagios用户组***//
#groupadd -g 6001 nagcmd   //***nagios命令组***//
#useradd -u 6000 -g nagios -G nagcmd -d /home/nagios -c "Nagios Admin" nagios    //***创建nagios管理账户***//




4.安装nagios

1
2
3
4
5
6
7
8
9
10
#tar zxvf nagios-3.2.0.tar.gz
#cd nagios-3.2.0
#./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagcmd \
--enable-enent-broker --enable-nanosleep --enable-embedded-perl --with-perlcache
#make all
#make install
#make install-init
#make install-commandmode
#make install-config
#make install-webconf




5.设置nagios开机启动

1
2
#chkconfig --add nagios
#chkconfig --level 35 nagios on




6.安装nagios插件(版本1.4.14)

1
2
3
4
5
6
#tar zxvf nagios-plugins-1.4.14.tar.gz
#cd nagios-plugins-1.4.14
#./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagcmd
#make all
#make install
#chmod 755 /usr/local/nagios




7.安装apache和php

1
#yum install httpd php* -y




8.配置apache
//***在该配置文件中找到 “DirectoryIndex index.html index.html.var” 修改为 “DirectoryIndex index.html index.php”,使其支持php格式的网页。***//
//***在该配置文件中加入 “AddType application/x-httpd-php .php”,使其支持.php的文件类型***//
//***在该配置文件末加入以下内容,使其通过验证才能访问web监控页面***//

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#setting for nagios
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
   AuthType Basic
   Options ExecCGI
   AllowOverride None
   Order allow,deny
   Allow from all
   AuthName "Nagios Access"
   AuthUserFile /usr/local/nagios/etc/htpasswd.user             //用于此目录访问身份验证的文件
   Require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
   AuthType Basic
   Options None
   AllowOverride None
   Order allow,deny
   Allow from all
   AuthName "nagios Access"
   AuthUserFile /usr/local/nagios/etc/htpasswd.user
   Require valid-user
</Directory>




9.添加nagios web监控页面认证用户

1
2
3
4
#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
#chown nagios:nagcmd /usr/local/nagios/etc/htpasswd.users
#usermod -a -G nagios,nagcmd apache    //***增加额外的附属组***//
#service httpd restart




10.安装并启动postfix

1
2
3
#yum install postfix -y
#chkconfig postfix on
#/etc/init.d/postfix restart



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