日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > windows >内容正文

windows

监控系统安装配置文档(Nagios+Cacti+Nconf)

發(fā)布時間:2024/4/14 windows 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 监控系统安装配置文档(Nagios+Cacti+Nconf) 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

監(jiān)控系統(tǒng)安裝配置文檔(Nagios+Cacti+Nconf) 一:Nagios環(huán)境的搭建 1.為以后的配置搭建安裝環(huán)境 # yum install -y http* # yum install -y mysql* # yum install -y php-* # yum install -y net-snmp*

# yum install -y httpd gcc glibc glibc-common gd gd-devel php php-gd ntp

2.安裝nagios

# wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.3.1/nagios-3.3.1.tar.gz

# tar zxf nagios-3.3.1.tar.gz # cd nagios # ./configure --prefix=/var/www/html/nagios # make all # useradd nagios

# make install && make install-init && make install-commandmode && make install-config && make install-webconf

2.增加nagios登陸認(rèn)證文件,一定要用默認(rèn)的nagiosadmin作為用戶,否則需要修改其他文件。

# htpasswd -c /var/www/html/nagios/etc/htpasswd.users nagiosadmin

3. 安裝插件:

# wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz

# tar -xf nagios-plugins-1.4.15.tar # cd nagios-plugins-1.4.15 # ./configure --prefix=/var/www/html/nagios/ # make # make install 4.將運行Apache的用戶添加到nagios組里,這樣Apache才有權(quán)限讀取文件 # usermod -G nagios apache??? //將apache用戶加到nagios組。 5.階段測試 # chown nagios.nagios /var/www/html/nagios/ -R # service httpd restart # chkconfig httpd on? # /etc/init.d/nagios start 二:cacti環(huán)境的搭建 1.rrdtool的安裝,這里需要安裝的是:rrdtool,rrdtool-devel.rrdtool-perl,rrdtool-php # yum localinstall -y --nogpgcheck rrdtool-* # service mysqld start 2.配置snmp # vim /etc/snmp/snmp.conf 修改3項?127.0.0.1 、 all、啟用項 # service snmpd restart 3.安裝cacti

# wget http://www.cacti.net/downloads/cacti-0.8.7h.tar.gz

# tar zxvf cacti-0.8.7h.tar.gz # mv cacti-0.8.7h /var/www/html/cacti 4.創(chuàng)建cacti數(shù)據(jù)庫 mysql> create database cacti;

mysql> grant all on cacti.* to 'cacti'@'localhost' identified by 'cacti';

mysql> flush privileges; 5.將cacti的表內(nèi)容導(dǎo)入創(chuàng)建的數(shù)據(jù)庫 # cd /var/www/html/cacti # mysql -ucacti -pcacti cacti < /var/www/html/cacti/cacti.sql 6.分別編輯兩個.php文件,以適應(yīng)環(huán)境,修改內(nèi)容相同。 # vim /var/www/html/cacti/include/config.php # vim /var/www/html/cacti/include/global.php

??????????????? $database_default = "cacti";?????? //默認(rèn)數(shù)據(jù)庫名

??????????????? $database_hostname = "localhost";??????? ?//主機(jī)名

??????????????? $database_username = "cacti";????????????? //登陸數(shù)據(jù)庫用戶名

??????????????? $database_password = "cacti";????????????? //登陸數(shù)據(jù)庫密碼

??????????????? $database_port = "3306";

# useradd –r –M cacti # chown –R cacti /var/www/html/cacti/rra/ # chown –R cacti /var/www/html/cacti/log/ 7.在cacti用戶下創(chuàng)建計劃任務(wù)以畫圖 # su cacti # crontab –e

??????????????? */1 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1

# php /var/www/html/cacti/poller.php > /dev/null 2>&1

# exit 8.從web頁面啟動cacti,安裝,并查看圖形化界面 三:整合Nagios與Cacti 1.下載并安裝ndoutils

# wget http://sourceforge.net/projects/nagios/files/ndoutils-1.x/ndoutils-1.4b9/ndoutils-1.4b9.tar.gz/download

# tar zxvf ndoutils-1.4b9.tar.gz # cd ndoutils-1.4b9

# ./configure --prefix=/var/www/html/nagios --enable-mysql --disable-pgsql --with-mysql-inc=/usr/include/mysql --with-mysql-lib=/usr/lib/mysql

# make 2.準(zhǔn)備配置文件

# cp -v src/{ndomod-3x.o,ndo2db-3x,file2sock,log2ndo} /var/www/html/nagios/bin

# cd db # ./installdb -ucacti -pcacti -hlocalhost -d cacti # cd ..

# cp -v config/{ndo2db.cfg-sample,ndomod.cfg-sample} /var/www/html/nagios/etc

# mv /var/www/html/nagios/etc/ndo2db.cfg-sample /var/www/html/nagios/etc/ndo2db.cfg

# mv /var/www/html/nagios/etc/ndomod.cfg-sample /var/www/html/nagios/etc/ndomod.cfg

# chmod 644 /var/www/html/nagios/etc/ndo* # chown nagios:nagios /var/www/html/nagios/etc/* # chown nagios:nagios /var/www/html/nagios/bin/* 3.修改nagios.cfg配置文件以適應(yīng)當(dāng)前環(huán)境 # vim /var/www/html/nagios/etc/nagios.cfg 在文件中添加:

??????????????? broker_module=/var/www/html/nagios/bin/ndomod-3x.o config_file=/var/www/html/nagios/etc/ndomod.cfg

檢查 event_broker_options=-1???? //為Nagios開啟event broker 4.修改ndo2db.cfg以適應(yīng)當(dāng)前環(huán)境 # vim /var/www/html/nagios/etc/ndo2db.cfg socket_type=tcp db_servertype=mysql db_host=localhost db_port=3306 db_name=cacti db_prefix=nagios_ db_user=cacti db_pass=cacti 5.修改ndomod.cfg以適應(yīng)當(dāng)前環(huán)境 # vim /var/www/html/nagios/etc/ndomod.cfg output_type=tcpsocket output=127.0.0.1 6.為ndo2db添加啟動進(jìn)程 # cp ./daemon-init /etc/init.d/ndo2db # vim /etc/init.d/ndo2db 檢查里面的路徑確保不會出現(xiàn)“//",并將Ndo2dbBin修改成下面的值: Ndo2dbBin=/var/www/html/nagios/bin/ndo2db-3x # chmod +x /etc/init.d/ndo2db 7.啟動守護(hù)進(jìn)程

# /var/www/html/nagios/bin/ndo2db-3x -c /var/www/html/nagios/etc/ndo2db.cfg

# tail -20 /var/log/messages??? //查看其中是否有錯誤出現(xiàn) 添加開機(jī)自動啟動

# echo "/var/www/html/nagios/bin/ndo2db-3x -c /var/www/html/nagios/etc/ndo2db.cfg" >> /etc/rc.local

# service nagios restart 四:安裝ncp,以在Cacti中展現(xiàn)Nagios 1.先安裝cacti擴(kuò)展模塊

# wget http://www.cacti.net/downloads/pia/cacti-plugin-0.8.7h-PA-v3.0.tar.gz

# tar xvf cacti-plugin-0.8.7h-PA-v3.0.tar.gz # cp -R cacti-plugin-arch/* /var/www/html/cacti/ # cd /var/www/html/cacti/ # mysql -ucacti -pcacti cacti < pa.sql # patch -p1 -N < cacti-plugin-0.8.7h-PA-v3.0.diff?//為cacti配置文件打補(bǔ)丁的時候注意在為include/config.php打補(bǔ)丁的時候有可能它將 include/config.php.dist給打補(bǔ)丁了,我們只需要手動加入下面的內(nèi)容即可。 # vim include/config.php 修改(或新加入)為

??????????????? $url_path = "/cacti/";

從web進(jìn)入cacti,啟用cacti plugin擴(kuò)展

2.安裝npc # tar zxvf npc-2.0.4.tar.gz # mv npc /var/www/html/cacti/plugins/ # vim /var/www/html/cacti/include/config.php 加入:

??????????????? $plugins[] = 'npc';

3.安裝 npc支持:json

# wget http://pkgs.fedoraproject.org/repo/pkgs/php-pecl-json/json-1.2.1.tgz/d8904d2f004ceec85eeacf524cd25539/json-1.2.1.tgz

# tar zxvf json-1.2.1.tgz # cd json-1.2.1 # phpize?????????????? //如果發(fā)現(xiàn)沒有Phpize文件,則是因為php-devel包沒有安裝導(dǎo)致的 # ./configure # make && make install # php -i | grep php.ini?查看是否有導(dǎo)入信息 4.打開php.ini文件添加對json的支持 # vim /etc/php.ini 添加 extension=json.so 5.為apache添加php支持。 # vim /etc/httpd/conf/httpd.conf 添加一行:

??????????????? AddType application/x-httpd-php .php .phtml

修改原DirectoryIndex內(nèi)容為:

??????????????? DirectoryIndex index.html index.html.var index.php

# usermod -G cacti apache # service httpd restart?????????????????? //重啟apache以讓php生效?????????????????? # php -m????????????????????????????????????????????? //查看是否有json被加載 6.修改配置文件以讓npc讀取到新的數(shù)據(jù)。 # vim /var/www/html/nagios/etc/ndo2db.cfg db_prefix=npc_ 6.1 從Web進(jìn)入Cacti,確保正確使用npc選項。 6.2 修改mysql中的表結(jié)構(gòu): ./mysql -ucacti -p cacti

alter table npc_eventhandlers add long_output TEXT NOT NULL default '' after output;

alter table npc_hostchecks add long_output TEXT NOT NULL default '' after output;

alter table npc_hoststatus add long_output TEXT NOT NULL default '' after output;

alter table npc_notifications add long_output TEXT NOT NULL default '' after output;

alter table npc_servicechecks add long_output TEXT NOT NULL default '' after output;

alter table npc_servicestatus add long_output TEXT NOT NULL default '' after output;

alter table npc_statehistory add long_output TEXT NOT NULL default '' after output;

alter table npc_systemcommands add long_output TEXT NOT NULL default '' after output;

7.重啟ndo2db進(jìn)程,重新加載配置文件重啟nagios服務(wù)。 # service ndo2db restart # service nagios restart 8.在Web上配置NPC以使之正常讀取工作。

在Settings->npc中 ,勾上Remote Commands

Nagios Command File Path= /var/www/html/nagios/var/rw/nagios.cmd

Nagios URL=你的地址(http://ocalhost/nagios/) 接下來刷新npc就可以看到數(shù)據(jù) 五:nconf的安裝與配置 首先對mysql數(shù)據(jù)庫進(jìn)行定義 mysql> create database nconf;?

mysql> grant all privileges on nconf.* to nconf@localhost identified by 'nconf';

mysql> flush privileges;?? mysql>quit 下載與安裝nconf

# wget http://sourceforge.net/projects/nconf/files/nconf/1.2.6-0/nconf-1.2.6-0.tgz/download

# tar -zxf nconf-1.2.6-0.tgz -C /var/www/html/ # cd /var/www/html/nconf

# chown -R apache.apache config/ temp/ static_cfg/ output/

進(jìn)入web,開始安裝 http://您nagios監(jiān)控端的IP/nconf 在web頁面按照安裝提示一步步安裝 使用剛才創(chuàng)建的nconf數(shù)據(jù)庫和nconf數(shù)據(jù)庫用戶/密碼 輸入用于通過nconf生成nagios配置文件所需的nconf路徑和nagios命令路徑 設(shè)置nconf管理員密碼,此時默認(rèn)登錄用戶為admin 網(wǎng)頁安裝完成 # rm -rf INSTALL INSTALL.php?UPDATE UPDATE.php?

# ln -s /var/www/html/nagios/bin/nagios bin/nagios?

# chmod +x /var/www/html/nconf/bin/generate_config.pl?

# chown -R apache.apache?bin # chmod +x /var/www/html/nagios/bin/nagios

# chmod +x /var/www/html/nconf/ADD-ONS/deploy_local.sh??

# vim /var/www/html/nconf/ADD-ONE/deploy_local.sh 修改里面的nagios為我們nagios的安裝路徑/var/www/html/nagios 重新刷新頁面,輸入admin/您設(shè)置的密碼,進(jìn)入nconf頁面

點擊Generate Nagios config嘗試生成配置文件,以測試是否與nagios成功關(guān)聯(lián)

注意:nconf在點擊【Generate Nagios config】后將您的生成nagios配置文件是/var/www/html/nconf/output/NagiosConfig.tgz,而并非直接導(dǎo)入nagios中。

1.在web頁面對監(jiān)控服務(wù)和主機(jī)配置完畢,點擊【Generate Nagios config】

2.deploy_local.sh是nconf自帶配置文件導(dǎo)入腳本 # /var/www/html/nconf/ADD-ONS/deploy_local.sh 手動執(zhí)行此腳本,將在/var/www/html/nagios/etc下生成兩目錄Default_collector與global 3.修改nagios主配置文件 # vim /var/www/html/nagios/etc/nagios.cf 將其中cfg_file=*******字段全部注釋 ,并加入

cfg_dir=/var/www/html/nagios/etc/Default_collector

cfg_dir=/var/www/html/nagios/etc/global

# service nagios reload 重載nagios配置文件使之生效 六:問題跟蹤: 1.啟動ndo2db發(fā)現(xiàn)日志報錯:

ndomod: Could not open data sink! I'll keep trying, but some output may get lost...

解決辦法:

??????????????? 檢查 /nagios/etc目錄的權(quán)限是否足夠的大

確保/var/www/html/nagios/etc/nagios.cfg中有如下行出現(xiàn),否則,請自行添加:

??????????????? event_broker_options=-1

檢查ndo2db.cfg中的配置,確保使用tcp連接 socket_type=tcp 檢查ndomod.cfg中的配置,確保使用tcp套接字 output_type=tcpsocket

轉(zhuǎn)載于:https://blog.51cto.com/yyy3y/727964

總結(jié)

以上是生活随笔為你收集整理的监控系统安装配置文档(Nagios+Cacti+Nconf)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。