Nagios服务器架设之一
实验环境:RHEL 5.4
一、Nagios服务器安装过程
1)配置服务器端IP地址
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=none
HWADDR=00:0c:29:fe:39:A1
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.6.199
GATEWAY=192.168.6.1
TYPE=Ethernet
2)安装Nagios
A,安装前准备
1)创建nagios程序用户、组
[root@localhost ~]# useradd -s /sbin/nologin nagios
---阻止用户登录服务器
-s :用户登录shell
[root@localhost ~]# mkdir /usr/local/nagios
[root@localhost ~]# chown -R nagios.nagios /usr/local/nagios/
---修改它的属主属组权限
2)保证系统中sendmail服务器要开启
[root@localhost ~]# service sendmail status
sendmail (pid 3090) 正在运行...
B、编译安装Nagios
[root@localhost ~]# cd /aaa/
[root@localhost aaa]# tar zxf nagios-3.2.0.tar.gz
[root@localhost aaa]# cd nagios-3.2.0
[root@localhost nagios-3.2.0]# ./configure --prefix=/usr/local/nagios/
[root@localhost nagios-3.2.0]# make all ; make install ; make install-init ; make install-commandmode ; make install-config
[root@localhost nagios-3.2.0]# chkconfig --add nagios
[root@localhost nagios-3.2.0]# chkconfig nagios on
[root@localhost nagios-3.2.0]# chkconfig --list nagios
---查看nagios服务是否运行
nagios
0:关闭
1:关闭
2:启用
3:启用
4:启用
5:启用
6:关闭
C、安装Nagios插件
你可以从 http://www.nagios.org
官方网站上下载最新的nagios插件
[root@localhost aaa]# tar zxf nagios-plugins-1.4.14.tar.gz
[root@localhost aaa]# cd nagios-plugins-1.4.14
[root@localhost nagios-plugins-1.4.14]# ./configure --prefix=/usr/local/nagios/ ; make ; make install
D、安装Nagios的汉化包
[root@localhost aaa]# tar jxf nagios-cn-3.2.0.tar.bz2
[root@localhost aaa]# cd nagios-cn-3.2.0
[root@localhost nagios-cn-3.2.0]# ./configure ; make all ; make install
E、安装LAMP架构
[root@localhost ~]# mount /dev/cdrom /media/
[root@localhost ~]# vi /etc/yum.repos.d/rhel-debuginfo.repo
[rhel-debuginfo]
name=Red Hat Enterprise Linux $releasever - $basearch - Debugbaseurl=file:///media/Server
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[root@localhost ~]# yum -y install php* mysql* http*
[root@localhost ~]# service httpd start
启动 httpd:
[确定]
[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# vi /etc/httpd/conf/httpd.conf
231 User apache
232 Group apache
391 DirectoryIndex index.php index.html index.html.var
992 #setting for nagios
993 ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
994 <Directory "/usr/local/nagios/sbin">
995 AuthType Basic
996 Options ExecCGI
997 AllowOverride None
998 Order allow,deny
999 Allow from all
1000 AuthName "nagios access"
1001 AuthUserFile /usr/local/nagios/etc/htpasswd
1002 Require valid-user
1003 </Directory>
1004 Alias /nagios "/usr/local/nagios/share"
1005 <Directory "/usr/local/nagios/share">
1006 AuthType Basic
1007 Options ExecCGI
1008 AllowOverride None
1009 Order allow,deny
1010 Allow from all
1011 AuthName "nagios access"
1012 AuthUserFile /usr/local/nagios/etc/htpasswd
1013 Require valid-user
1014 </Directory>
创建apache目录的验证文件“/usr/local/nagios/etc/htpasswd”
[root@localhost ~]# htpasswd -c /usr/local/nagios/etc/htpasswd benet
New password:
Re-type new password:
Adding password for user benet
重启apache服务器并进行验证nagios登陆情况
[root@localhost ~]# service httpd restart
停止 httpd:
[确定]
启动 httpd:
[确定]
至此nagios服务器安装结束