您好,登錄后才能下訂單哦!
注釋:
首先下載
Apache 實現nagios監控通過web查看 Nagios
nagios監控程序
Nagios-plugins nagios監控插件
Pnp4nagios nagios監控插件
Nrpe nagios監控客戶端
Rrdtool pnp4nagios生成圖形工具
Nagios http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.2.1/nagios-3.2.1.tar.gz
Nagios-plugins http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz Pnp4nagios http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.6.tar.gz/download
Nrpe http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
注釋(以后可能會遇到一下相關包找不到等): 可能yum安裝會有些問題找不到包,可添加yum源:如:rpmforge源和epel源
wget http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm -ivh http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/epel-release-6-5.noarch.rpm
php的一些擴展包找不到就需要添加這兩個源:rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm和上面的epel-release-6-5.noarch.rpm
如:php擴展mcrypt就需要epel源;而php的擴展bitset就需要用哦感到rpmforge源。。。
一,安裝pnp4nagios
!!!此時安裝pnp4nagios就用到了需要的epel源,如果沒有epel源
請參考:1、安裝epel
# cat /etc/issue
CentOS release 6.2 (Final)
Kernel \r on an \m
# rpm -ivh http://dl.iuscommunity.org/pub/ius/stable/Redhat/6/x86_64/epel-release-6-5.noarch.rpm 這里應該對應你服務器的版本
[root@master ~]#yum install pnp4nagios rrdtool
或者源碼:安裝:
在這之前安裝rrdtool和pnp4nagios需要如下包:
yum install -y perl-devel perl-CPAN perl-Time-HiRes
#tar -zxvf pnp4nagios-*.tar.gz
#cd php4nagios-*
#./configure --prefix=/usr/local/pnpnagios --with-nagios-user=nagios --with-nagios-group=nagios (如果單獨編譯安裝的rrdtoool,則使用--with-rrdtool=/usr/local/rrdtool-1.2.xx/bin/rrdtool這樣的形式)
#make all
#make install
#make install-webconf
#make install-config
#make install-init
#make fullinstall
(使用這條命令替換所有的make命令, make fullinstall)
還需要:復制所有的pnp4nagios 目錄下etc下的*.cfg.simple 復制為*.cfg
cd /usr/local/pnpnagios-*/etc/
88. mv misccommands.cfg-sample misccommands.cfg
89. mv nagios.cfg-sample nagios.cfg
90. mv rra.cfg-sample rra.cfg
91. cd pages/
92. mv web_traffic.cfg-sample web_traffic.cfg
93. cd ../check_commands/
94. mv check_all_local_disks.cfg-sample check_all_local_disks.cfg
95. mv check_nrpe.cfg-sample check_nrpe.cfg
96. mv check_nwstat.cfg-sample check_nwstat.cfg
本篇文章來源于 Linux公社網站(www.linuxidc.com) 原文鏈接:http://www.linuxidc.com/Linux/2012-07/66071.htm
二,配置nagios
1、修改nagios.cfg
[root@master ~]# vim /etc/nagios/nagios.cfg //修改以下內容
process_performance_data=1 //由0改為1
host_perfdata_command=process-host-perfdata //前面的注釋拿掉
service_perfdata_command=process-service-perfdata //注釋拿掉
enable_environment_macros=1 //如果有注釋拿掉
2、修改commands.cfg
注釋掉原有對process-host-perfdata和process-service-perfdata,重新定義:
[root@master ~]# vim /etc/nagios/objects/commands.cfg
define command {
command_name process-service-perfdata
command_line /usr/bin/perl /usr/libexec/pnp4nagios/process_perfdata.pl
}
define command {
command_name process-host-perfdata
command_line /usr/bin/perl /usr/libexec/pnp4nagios/process_perfdata.pl -d HOSTPERFDATA
}
3、修改配置文件templates.cfg
添加以下內容
[root@master ~]# vim /etc/nagios/objects/templates.cfg
define host {
name hosts-pnp
register 0
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
process_perf_data 1
}
define service {
name srv-pnp
register 0
action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
process_perf_data 1
}
4、修改服務器配置文件cisco_3650.cfg
[root@master ~]# vim /etc/nagios/objects/cisco_3650.cfg
###### define hosts ##########################
define host{
use generic-switch,hosts-pnp
host_name BJ3560G-48
address 172.16.1.1
contact_groups admins
}
##### define services ############
define service{
use generic-service,srv-pnp
host_name BJ3560G-48
service_description PING
check_command check_ping!200.0,20%!600.0,60%
contact_groups admins
}
三、配置apache
修改Apache的配置文件httpd.conf:
[root@master ~]# vim /usr/local/apache/conf/httpd.conf
在AddType application/x-gzip .gz .tgz下,添加下面的配置項:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
[root@master ~]# /etc/init.d/httpd restart 重啟apache服務
可以直接拷貝下面到vim /etc/httpd/conf.d/pnp4nagios.conf
[root@lvs-save conf.d]# cat /etc/httpd/conf.d/pnp4nagios.conf
# SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER
Alias /pnpnagios "/usr/local/pnpnagios/share"
<Directory "/usr/local/pnpnagios/share">
AllowOverride None
Order allow,deny
Allow from all
#
# Use the same value as defined in nagios.conf
#
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
Options FollowSymLinks
# Installation directory
RewriteBase /pnpnagios/
# Protect application and system files from being viewed
RewriteRule ^(application|modules|system) - [F,L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]
</IfModule>
</Directory>
四、如果訪問圖不出提示:
The requested URL /pnp4nagios/index.php/graph was not found on this server.
那么可能是相關php包沒安裝:
方法:yum install php*
即可解解以上報錯出圖問題。
五、如果訪問http://IP/pnpnagios需要提供認證而用nagios登錄的也不行,那么就執行下一下在生成一個用戶進行登錄即可!
#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 第一次使用htpasswd是用參數-c表示創建目錄/usr/local/nagios/etc/htpasswd.users 用于存放用戶nagiosadmin 信息!
htpasswd -m /usr/local/nagios/etc/htpasswd.users nagios 這個-m 參數表示在這個文件里面多加一個用戶!
注意如果上面配置后在/usr/local/pnpnagios/var/perfdata/ 這么目錄下有數據 但是點擊游覽器訪問出圖數據時候報錯說什么找不到主機圖,那么一般是http配置問題!看看pnp4nagios和pnpnagios區別的別名問題!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。