nagios安装配置(一)
yum安装。yum install httpd **安装Apache
yum install gcc **安装开发工具
yum install glibc glibc-common **安装开发libc库
yum install gdgd-devel **安装GD库和开发库
yum install php **安装PHP
如果以上一条一条的输入比较麻烦也可以使用一条命令进行安装:
yum install httpd*php* gcc* glibc* glibc-common* gd* gd-devel*
建立一个nagcmd组 将用户nagios(需要建立)和apache添加到组中用于从Web接口执行外部命令:
#useradd nagios
#passwd nagios
Changing passwordfor user nagios.
New UNIX password:
Retype new UNIXpassword:
passwd: allauthentication tokens updated successfully.
#groupadd nagcmd
#usermod -G nagcmd nagios
#usermod -G nagcmd apache
#tail -1 /etc/group
nagcmd:x:501:nagios,apache
下载安装Nagios软件包和插件包,有两种方式可以实现:
1、在Nagios官网下载页面直接下载再传送到服务器上。
2、直接使用wget命令下载到服务器。
Url:
http://www.nagios.org/download/core/thanks/
http://www.nagios.org/download/plugins/
Wget:
Wget http://downloads.sourceforge.net/project/nagios/nagios-3.x/nagios-3.2.1/nagios-3.2.1.tar.gz?r=http%3A%2F%2Fwww.nagios.org%2Fdownload%2Fcore%2Fthanks%2F&ts=1282635348&mirror=cdnetworks-kr-2
Wget http://downloads.sourceforge.net/project/nagiosplug/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz?r=http%3A%2F%2Fwww.nagios.org%2Fdownload%2Fplugins%2F&ts=1282636582&mirror=cdnetworks-kr-2
成功下载两个Nagios的tar包:
nagios-3.2.1.tar.gz
nagios-plugins-1.4.15.tar.gz
展开tar包:
tar zxvf nagios-3.2.1.tar.gz
tar zxvfnagios-plugins-1.4.15.tar.gz
进入nagios安装目录开始编译安装nagios软件
cd nagios-3.2.1
./configure --with-command-group=nagcmd ***编译Nagios程序包源码
make all
makeinstall
makeinstall-init **生成init启动脚本
makeinstall-config **设置相应的目录权限
makeinstall-commandmode **生成模板配置文件
makeinstall-webconf **生成apache配置文件
使用htpasswd 命令创建nagios的Web接口访问用户名和密码。
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Newpassword:
Re-type newpassword:
# cat /usr/local/nagios/etc/htpasswd.users
nagiosadmin:5DV3J8lr7mUJ6 **密码已经加密了
接下来开始编译安装nagios的插件。
cdnagios-plugins-1.4.15
./configure--with-nagios-user=nagios --with-nagios-group=nagios
make
makeinstall
将nagios加到服务列表中并使之在系统启动时自动启动
chkconfig –addnagios
chkconfignagios on
chkconfig--list nagios
nagios0:off 1:off 2:on 3:on 4:on 5:on 6:off
验证配置文件,如果没有报错说明安装正确。
# /usr/local/nagios/bin/nagios -v/usr/local/nagios/etc/nagios.cfg
Nagios Core3.2.1
Copyright(c) 2009-2010 Nagios Core Development Team and Community Contributors
Copyright (c)1999-2009 Ethan Galstad
LastModified: 03-09-2010
License:GPL
Website:http://www.nagios.org
Readingconfiguration data...
Read main config file okay...
Processingobject config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processingobject config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processingobject config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processingobject config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processingobject config file '/usr/local/nagios/etc/objects/localhost.cfg'...
Read object config files okay...
Runningpre-flight check on configuration data...
Checkingservices...
Checked 8 services.
Checkinghosts...
Checked 1 hosts.
Checkinghost groups...
Checked 1 host groups.
Checkingservice groups...
Checked 0 service groups.
Checkingcontacts...
Checked 1 contacts.
Checkingcontact groups...
Checked 1 contact groups.
Checkingservice escalations...
Checked 0 service escalations.
Checkingservice dependencies...
Checked 0 service dependencies.
Checkinghost escalations...
Checked 0 host escalations.
Checkinghost dependencies...
Checked 0 host dependencies.
Checkingcommands...
Checked 24 commands.
Checkingtime periods...
Checked 5 time periods.
Checkingfor circular paths between hosts...
Checkingfor circular host and service dependencies...
Checkingglobal event handlers...
Checkingobsessive compulsive processor commands...
Checkingmisc settings...
Total Warnings: 0
Total Errors: 0
Things lookokay - No serious problems were detected during the pre-flight check
重启apache服务和启动nagios服务
# /etc/init.d/httpd restart
Stoppinghttpd:
Startinghttpd:
# /etc/init.d/nagios start
Startingnagios: done.
这样已经完成nagios的安装部分
Web接口访问:http://localhost/nagios/ (或http://ipaddress/nagios/ )
页:
[1]