CentOS6.0+Nagios中文版+PNP+NagiosWeb管理工具nagiosQL中文版

按照網(wǎng)上一篇文檔實(shí)踐搭建了nagios監(jiān)控系統(tǒng), 學(xué)習(xí)交流,原文地址:http://zhumeng8337797.blog.163.com/blog/static/1007689142011101551756386/

金昌網(wǎng)站制作公司哪家好,找創(chuàng)新互聯(lián)!從網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、APP開發(fā)、自適應(yīng)網(wǎng)站建設(shè)等網(wǎng)站項(xiàng)目制作,到程序開發(fā),運(yùn)營維護(hù)。創(chuàng)新互聯(lián)自2013年創(chuàng)立以來到現(xiàn)在10年的時間,我們擁有了豐富的建站經(jīng)驗(yàn)和運(yùn)維經(jīng)驗(yàn),來保證我們的工作的順利進(jìn)行。專注于網(wǎng)站建設(shè)就選創(chuàng)新互聯(lián)

一、安裝CentOS6.0 64位系統(tǒng)

二、執(zhí)行
1.yum -y install httpd gettext MySQL mysql-server mysql-devel php php-mysql php-pear
2.yum install php-mysql mysql perl mysql-server perl-DBI perl-DBD-MySQL httpd gcc glibc glibc-common gd gd-devel php
三、下載安裝包
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz (現(xiàn)在最新版本的插件) 
wget http://sourceforge.net/projects/nagios-cn/files/sourcecode/zh_CN%203.2.3/nagios-cn-3.2.3.tar.bz2/download
   四、用戶和組的準(zhǔn)備
useradd nagios
passwd nagios 
usermod -s /sbin/nologin nagios
uroupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd apache 
   五、開始安裝程序
解壓:tar -jxvf nagios-cn-3.2.3.tar.bz2
編譯安裝:cd nagios-cn-3.2.3
yum -y install gcc automake autoconf libtool make
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagcmd                                                                                    make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
安裝插件:
tar zxvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make insall
添加訪問頁面用戶nagiosadmin及密碼,這里要記住此密碼不要忘記了.(nagios  123456)
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
設(shè)置相關(guān)服務(wù)開機(jī)啟動
[root@localhost nagios-cn-3.2.3]#service nagios start 
[root@localhost nagios-cn-3.2.3]#chkconfig --add nagios
[root@localhost nagios-cn-3.2.3]# chkconfig nagios on
[root@localhost nagios-cn-3.2.3]# chkconfig httpd on
[root@localhost nagios-cn-3.2.3]# chkconfig mysqld on
檢查配置文件是否正確
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

沒有錯誤,表示通過。
現(xiàn)在可以通過http://IP/nagios訪問控制臺
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

六.安裝nrpe插件
nrpe_plugins指標(biāo)采集程序主要是用來分析nrpe客戶端的plugin腳本采集性能指 標(biāo)數(shù)據(jù)。目前實(shí)現(xiàn)的有cpu、memory、diskbuffer、singleprocessoracle、sybase等方面的性能指標(biāo)的分析這個插件需要分別安裝在主控端和被控端上,這個插件需要openssl的支持,沒有就直接在線安裝一下(yum install openssl-devel)所以還需在nagios主機(jī)和被控端安裝,感覺挺麻煩,沒辦法它需要咱們就跟著做哈.]
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
yum install openssl-devel  (提示已經(jīng)安裝)
./configure
make && make install
完成以后沒有出錯就可以看到以下生成的文件了
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

接下來按如下操作
mkdir /usr/local/nagios/etc
cp sample-config/nrpe.cfg /usr/local/nagios/etc/
cp init-script /etc/init.d/nrpe
chmod +x /etc/init.d/nrpe 
啟動nrpe :service nrpe start
七、配置PNP
PNP是一個基于phpperl,用rrdtoolnagios采集的數(shù)據(jù)繪制圖表的工具,所以安裝pnp之前必須先安裝php perl  and rrdtool這里用yum直接來安裝rrdtool,單獨(dú)下載安裝有很多依存關(guān)系,挺麻煩.]
yum install rrdtool
wget http://sourceforge.net/projects/pnp4nagios/files/PNP-0.6/pnp4nagios-0.6.15.tar.gz/download
tar zxvf pnp4nagios-0.6.15.tar.gz 
cd pnp4nagios-0.6.15
./configure 
報錯:
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

執(zhí)行:yum install perl-Time-HiRes
繼續(xù)編譯
make all
make install
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

根據(jù)提示
make install-webconf
make install-config
make install-init
然后把相關(guān)后綴帶sample文件變更成無sample后綴
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

[root@localhost pnp4nagios-0.6.15]# cd /usr/local/pnp4nagios/etc/
[root@localhost etc]# mv misccommands.cfg-sample misccommands.cfg
[root@localhost etc]# mv nagios.cfg-sample nagios.cfg
[root@localhost etc]# mv rra.cfg-sample rra.cfg
[root@localhost etc]# cd pages/
[root@localhost pages]# mv web_traffic.cfg-sample web_traffic.cfg
[root@localhost pages]# cd ../check_commands/
[root@localhost check_commands]# mv check_all_local_disks.cfg-sample check_all_local_disks.cfg
[root@localhost check_commands]# mv check_nrpe.cfg-sample check_nrpe.cfg
[root@localhost check_commands]# mv check_nwstat.cfg-sample check_nwstat.cfg
配置Nagios來啟用PNP
cd /usr/local/nagios/etc
vi nagios.cfg
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

pnp4nagios有很多種工作模式,這里我們選用同步模式,想選其它模式可以看說明都有詳細(xì)配置教程(不同模式配置不同)
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

這里我們按說明的設(shè)定方法來做
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

[這里先把pnp4nagios執(zhí)行數(shù)據(jù)收集的文件拷貝到nagioslibexec下,方便統(tǒng)一命令的執(zhí)行路徑.]
cp /usr/local/pnp4nagios/libexec/process_perfdata.pl /usr/local/nagios/libexec/
然后在commands.cfg里面加入如下(這里是同步模式設(shè)定方法)
cd /usr/local/nagios/etc/objects
vi commands.cfg
添加內(nèi)容并注釋掉原來的
#process-host-perfdata' command definition 
define command{ 
        command_name    process-host-perfdata 
        command_line    $USER1$/process_perfdata.pl -d HOSTPERFDATA 
        }
#process-service-perfdata' command definition 
define command{ 
        command_name    process-service-perfdata 
        command_line    $USER1$/process_perfdata.pl 
        } 
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

然后添加小太陽模版,鑲嵌在nagios頁面上
[這里有兩種查看圖的方法,第一種方法是你當(dāng)太陽的圖標(biāo)的時候會在新窗口中打開圖形查看,第二種方法是你只需要把鼠標(biāo)移動到太陽圖標(biāo)上面就會自動彈出圖形出來,以下兩種方法你可以根據(jù)自己喜好選其中一種即可]
第一種方法在templates.cfg里面加入如下
vi templates.cfg
添加內(nèi)容:
define host { 
   name       host-pnp 
   action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_ 
   register   0 
}
define service { 
   name       srv-pnp 
   action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$ 
   register   0 
為目標(biāo)主機(jī)圖標(biāo)旁邊添加一個小太陽標(biāo)記
vi localhost.cfg
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

為相關(guān)服務(wù)添加一個小太陽標(biāo)記
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

訪問http://IP/pnp3nagios,有一項(xiàng)出錯
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

yum install php* -y
重啟后解決

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

 
按要求重命名install.php
cd /usr/local/pnp4nagios/share/
mv install.php install.php.bak
刷新網(wǎng)頁:
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

重啟nagios:service nagios restart
ok,到此總算配置好了PNP
八.Nagios WEB管理工具叫NagiosQL注:還有同樣一個Nagios WEB管理工具叫Nconf)
下載安裝包:wget http://sourceforge.net/projects/nagiosql/files/nagiosql/NagiosQL%203.1.1/nagiosql_311.tar.gz/download
NagiosQL是一個WEB管理工具,只要把其放到下Apache即可。因?yàn)檫@里它要和Nagios整合到一起,為了方便管理,把其放在Nagios目錄下
tar zxvf nagiosql_311.tar.gz 
mv nagiosql /usr/local/nagios/
建立nagiosQL導(dǎo)出nagios配置文件的目錄,并修改權(quán)限
建目錄和改權(quán)限
mkdir -p /etc/nagiosql/{hosts,services,backup/{,hosts,services},import}
chown -R apache:nagios /etc/nagiosql/
chmod -R 755 /etc/nagiosql
chmod 777 /usr/local/nagios/nagiosql/config
Nagios相關(guān)文件權(quán)限的設(shè)定
chown nagios:apache /usr/local/nagios/etc
chown nagios:apache /usr/local/nagios/etc/{nagios.cfg,cgi.cfg}
chown nagios:apache /usr/local/nagios/etc/*
chmod 664 /usr/local/nagios/etc/{nagios.cfg,cgi.cfg}
chmod 775 /usr/local/nagios/etc
設(shè)定nagios二進(jìn)制文件的權(quán)限,以便其能夠通過Web程序執(zhí)行
chown nagios:apache /usr/local/nagios/bin/nagios
chmod 750 /usr/local/nagios/bin/nagios
chown -R apache.nagios /usr/local/nagios/var/spool/
chown nagios:apache /usr/local/nagios/var/rw/nagios.cmd
chmod 660 /usr/local/nagios/var/rw/nagios.cmd
apache添加nagiosQL虛擬目錄
vi /etc/httpd/conf.d/nagios.conf 
#add virture directory for nagiossql
Alias /nagiosQL "/usr/local/nagios/nagiosql"
<Directory "/usr/local/nagios/nagiosql">
# SSLRequireSSL
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
重新加載httpd服務(wù)和啟動mysqld服務(wù)
service httpd reload
service mysqld restart 
建立nagiosql安裝文件
touch /usr/local/nagios/nagiosql/install/ENABLE_INSTALLER
訪問http://ip/nagiosQL進(jìn)行安裝
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

開始安裝,測試環(huán)境通過,下一步
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

輸入mysql 密碼,設(shè)置nagiosQL默認(rèn)登錄密碼
刪除安裝目錄,這里使用改權(quán)限:chmod 000 /usr/local/nagios/nagiosql/install
完成安裝
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

管理-域-localhost---點(diǎn)修改
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

按如圖修改
 
 
CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版
工具-導(dǎo)入數(shù)據(jù) 右邊會列出一些配置文件,選擇導(dǎo)入即可。
導(dǎo)入只是把配置文件內(nèi)容導(dǎo)入到Mysql數(shù)據(jù)庫,而使用其配置文件時,是一個個cfg文件,所以下面要進(jìn)行寫入過程
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

工具-nagios控制-寫入檢測數(shù)據(jù)-寫入其他數(shù)據(jù)
CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版
檢查配置文件成功

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

重新啟動nagios
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

寫入之后就可以看到相應(yīng)的cfg文件了,查看寫入是否成功,由下面的輸出可以看出寫入是成功滴.
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

修改nagios的配置文件,將原有以cfg_file開頭項(xiàng)全部注釋掉,加入上面新寫入的配置文件
vi /usr/local/nagios/etc/nagios.cfg 
注釋掉
 

CentOS 6.0+Nagios中文版+PNP+Nagios Web管理工具nagiosQL中文版

加入新的配置文件路徑
cfg_dir=/etc/nagiosql/hosts/ 
cfg_dir=/etc/nagiosql/services/ 
cfg_file=/etc/nagiosql/commands.cfg 
cfg_file=/etc/nagiosql/contactgroups.cfg 
cfg_file=/etc/nagiosql/contacts.cfg 
cfg_file=/etc/nagiosql/contacttemplates.cfg 
cfg_file=/etc/nagiosql/hostdependencies.cfg 
cfg_file=/etc/nagiosql/hostescalations.cfg 
cfg_file=/etc/nagiosql/hostextinfo.cfg 
cfg_file=/etc/nagiosql/hostgroups.cfg 
cfg_file=/etc/nagiosql/hosttemplates.cfg 
cfg_file=/etc/nagiosql/servicedependencies.cfg 
cfg_file=/etc/nagiosql/serviceescalations.cfg 
cfg_file=/etc/nagiosql/serviceextinfo.cfg 
cfg_file=/etc/nagiosql/servicegroups.cfg
cfg_file=/etc/nagiosql/servicetemplates.cfg 
cfg_file=/etc/nagiosql/timeperiods.cfg
檢查nagios的配置文件是否有問題,然后生重啟nagios服務(wù),至此整個搭建過程終于完成了
 
后面續(xù)上添加監(jiān)控主機(jī)。

網(wǎng)頁名稱:CentOS6.0+Nagios中文版+PNP+NagiosWeb管理工具nagiosQL中文版
網(wǎng)站鏈接:http://muchs.cn/article14/picjge.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供Google、電子商務(wù)、軟件開發(fā)、App開發(fā)、定制網(wǎng)站、做網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)