1.安装依赖包
[root@node1 opt]# yum install -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel
[root@node1 ~]# useradd -s /sbin/nologin nagios
[root@node1 ~]# mkdir /usr/local/nagios
[root@node1 ~]# chown -R nagios.nagios /usr/local/nagios
2、编译安装Nagios
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.3.tar.gz
[root@node1 ~]# tar zxvf nagios-3.4.3.tar.gz
[root@node1 ~]# cd nagios
[root@node1 ~]# ./configure --prefix=/usr/local/nagios
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagios
Embedded Perl: no
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Lock file: ${prefix}/var/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/rc.d/init.d
Apache conf.d directory: /etc/httpd/conf.d
Mail program: /bin/mail
Host OS: linux-gnu
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /bin/traceroute
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
[root@node1 ~]# make all
[root@node1 ~]#make install
[root@node1 nagios]# make install-init
/usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d
/usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios
*** Init script installed ***
[root@node1 nagios]# make install-commandmode
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/rw
chmod g+s /usr/local/nagios/var/rw
*** External command directory configured ***
[root@node1 nagios]# make install-config
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg
/usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg
*** Config files installed ***
Remember, these are *SAMPLE* config files. You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.
[root@node1 nagios]# chkconfig --add nagios
[root@node1 nagios]# chkconfig --level 35 nagios on
[root@node1 nagios]# chkconfig --list nagios
nagios 0:off 1:off 2:off 3:on 4:on 5:on 6:off
3、安装Nagios 插件
[root@node1 opt]#tar zxvf nagios-plugins-1.4.13.tar.gz
[root@node1 opt]# cd nagios-plugins-1.4.13
[root@node1 opt]# ./configure --prefix=/usr/local/nagios
config.status: creating po/Makefile
--with-apt-get-command:
--with-ping6-command: /bin/ping6 -n -U -w %d -c %d %s
--with-ping-command: /bin/ping -n -U -w %d -c %d %s
--with-ipv6: yes
--with-mysql: no
--with-openssl: yes
--with-gnutls: no
--enable-extra-opts: no
--with-perl: /usr/bin/perl
--enable-perl-modules: no
--with-cgiurl: /nagios/cgi-bin
--with-trusted-path: /bin:/sbin:/usr/bin:/usr/sbin
[root@node1 nagios-plugins-1.4.13]# make && make install
4、安装与配置Apache和Php
Apache 和Php 不是安装nagios 所必须的,但是nagios提供了web监控界面,通过web监控界面可以清晰的看到被监控主机、资源的运行状态,因此,安装一个web服务是很必要的。
需要注意的是,nagios在nagios3.1.x版本以后,配置web监控界面时需要php的支持。这里我们下载的nagios版本为nagios-3.4.3,因此在编译安装完成apache后,还需要编译php模块,这里选取的php版本为php5.4.10。
a. 安装Apache
# wget http://archive.apache.org/dist/httpd/httpd-2.2.23.tar.gz
# tar zxvf httpd-2.2.23.tar.gz
# cd httpd-2.2.23
[root@node1 ~]# mkdir -p /usr/local/apache2
[root@node1 ~]# ./configure --prefix=/usr/local/apache2
[root@node1 ~]# make && make install
b. 安装Php
php-5.4.10.tar.gz
[root@node1 ~]# tar zxvf php-5.4.10.tar.gz
[root@node1 ~]# cd php-5.4.10
[root@node1 ~]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs
checking for strftime... (cached) yes
checking which regex library to use... php
checking whether to enable LIBXML support... yes
checking libxml2 install dir... no
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
--解决方案
[root@node1 php-5.3.8]#yum erase zlib-devel
[root@node1 php-5.3.8]#yum install zlib-devel
[root@node1 php-5.3.8]#yum install libxml2-devel
[root@node1 ~]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating main/php_config.h
config.status: executing default commands
[root@master php-5.4.10]# make && make install
c. 配置apache
找到apache 的配置文件/usr/local/apache2/conf/httpd.conf
找到:
User daemon
Group daemon
修改为
User nagios
Group nagios
然后找到
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
修改为
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
接着增加如下内容:
AddType application/x-httpd-php .php
为了安全起见,一般情况下要让nagios 的web 监控页面必须经过授权才能访问,这需要增加验证配置,即在httpd.conf 文件最后添加如下信息:
复制代码
#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 //用于此目录访问身份验证的文件
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
Require valid-user
</Directory>
复制代码
d. 创建apache目录验证文件
在上面的配置中,指定了目录验证文件htpasswd,下面要创建这个文件:
# /usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd david
这样就在/usr/local/nagios/etc 目录下创建了一个htpasswd 验证文件,当通过http://192.168.1.108/nagios/ 访问时就需要输入用户名和密码了。
e. 查看认证文件的内容
# cat /usr/local/nagios/etc/htpasswd
f. 启动apache 服务
# /usr/local/apache2/bin/apachectl start
到这里nagios 的安装也就基本完成了,你可以通过web来访问了。
http://192.168.1.106/nagios/
遇到的问题与解决方案
问题一:
./configure以下错误发生
Sorry, I cannot run apxs. Possiblereasons follow:
1. Perl is not installed
2. apxs was not found. Try to pass the path using--with-apxs2=/path/to/apxs
3. Apache was not built using --enable-so (the apxs usage page isdisplayed)
解决方法:指定正确的apxs路径
1.查找apxs路径
# whereis apxs
apxs:
说明系统没有安装apxs扩展工具
2.安装apxs
# yum install httpd-devel
3.查找apxs路径
# whereis apxs
apxs: /usr/sbin/apxs /usr/share/man/man8/apxs.8.gz
apxs安装成功
问题二:
安装apxs以下错误发生:
Package cyrus-sasl-plain needs cyrus-sasl-lib = 2.1.22-4, thisis not available.
解决方法:
# yum -y install cyrus*
之后再次安装apxs
问题三:
再次./configure以下错误发生
configure: error: xml2-config not found. Please check your libxml2installation.
解决方法:
安装libxml2
# yum install libxml2-devel
【问题四:=====================================================】
hecking libxml2 install dir... no
checking for xml2-config path... /usr/bin/xml2-config
checking whether libxml build works... no
configure: error: build test failed. Pleasecheck the config.log for details.
解决方法:
# yum erase zlib-devel
# yum install zlib-devel
# yum install libxml2-devel
[root@node1 ~]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs
# make && make install
相关推荐
向Nagios添加监控主机 监控linux服务器
nagios监控主机内存,监控主机开销,主机类型为linux
主机监控:Nagios 可以监控服务器、路由器、交换机等网络设备。它检查主机的可用性、响应时间、资源利用率等,并生成报告以供管理员查看。 插件支持:Nagios 支持各种插件,这些插件可以根据需要添加到系统中。通过...
nagios监控主机安装手册
nagios 被监控端安装。网络服务监控(SMTP、POP3、HTTP、NNTP、ICMP、SNMP、FTP、SSH) 主机资源监控(CPU load、disk usage、system logs),也包括Windows主机(使用NSClient++ plugin) 数据库监控 (Mysql...
CentOS配置Nagios监控平台,监控Linux客户端,Windows客户端详细配置,以及如何设置微信报警
NSClient nagios监控windows主机客户端
Nagios在Windows下的应用 图文并茂~非常好理解~
nagios监控linux主机、web等各种服务,并实现飞信自动报警
Nagios监控Linux主机(NRPE安装与应用)很少看到的
被动监控是当远程被监控主机处于防火墙之内的时候,只有远程主机可以访问到监控中心,防火墙之内可以设置另外一个监控中心,远程监控中心的nagios收集服务器信息以后,和nsca报告,由naca客户端报告naca的服务器端,...
3.nagios的基本结构介绍,实例说明nagios如何通过snmp方式监控windows主机(公司环境原因,大部分是windows主机,而且因为先前已有其他监控,都打开了snmp,就不想再用agent方式了) 3.cacti的安装 4.ndoutils的安装...
(2)NSCA:用来让 被监控的远程Linux/Unix主机主动将监控信息发送给Nagios服务器(这在冗余监控模式中特别要用到) (3)NSClient++:用来监控 Windows主机时安装在Windows主机上的组件 (4)NDOUtils:则用来将...
NSCA是一个可在远程Linux/Unix主机上执行强制检测并将结果传给Nagios守护进程的外部构件包。 被动模式的监控原理: 相比与主动模式中服务器主动去被监控机上轮询获取监控数据的方式,被动模式则是在被监控机上面通过...
本文档主要实现nagios监控windows主机,nagios监控windows系统有三种实现方式:SNMP、NSClient++、NRPE,后面两种方式都需要在windows上安装agent,因目前服务器上都开启了SNMP,所以本文档只介绍使用SNMP方式来监控...
nagios监控配置,nagios为监控主机情况,按照nagios安装配置系统
配置Nagios检查主机开销,主机为linux各种版本
Nagios配置之监控远程主机插件安装(案例).pdf 学习资料 复习资料 教学资源
nagios4.3.2编译安装安装文档,包括依赖软件的编译安装、nagios的编译安装、php配置、监控主机配置、被监控主机配置。
Nagios是一款开源的免费网络监视工具,能有效监控Windows、Linux和Unix的主机状态,交换机路由器等网络设置,打印机等。在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员,在状态恢复后发出正常的...