更新日誌: |
- 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
- 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
- htpasswd -c /var/www/html/nagios/etc/htpasswd.users nagiosadmin
- wget http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz
- tar -zvxf nagios-plugins-1.4.15.tar.gz
- cd nagios-plugins-1.4.15
- ./configure --prefix=/var/www/html/nagios/
- make
- make install
- usermod -G nagios apache ##將apache用戶加到nagios組。
- chown nagios.nagios /var/www/html/nagios/ -R
- service httpd restart
- chkconfig httpd on
- /etc/init.d/nagios start
在這裏沒有提供rrdtool的工具,須要下載能夠去這裏下載上述的3個軟件包html
rrdtool、rrdtool-devel的地址:
http://packages.express.org/rrdtool/
rrdtool-php的地址:
http://pkgs.org/download/rrdtool-php
注意,rrdtool的組件和附加組件版本儘可能一致,而因爲rrdtool-php這個包很是稀有,因此,儘可能請以rrdtool-php的版原本決定rrdtool以及rrdtool-devel的版本。
還有必定要對應環境,別安裝成了fedora的版本了=。=
|
- yum localinstall -y --nogpgcheck rrdtool-*
- service mysqld start
- vim /etc/snmp/snmpd.conf
- # 修改3項 127.0.0.1 、 all、啓用項(修改的內容詳見我Cacti的安裝文檔,上面有很是詳細的內容介紹)
- service snmpd restart
- 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
- mysql> create database cacti;
- mysql> grant all on cacti.* to 'cacti'@'localhost' identified by 'cacti';
- mysql> flush privileges;
- cd /var/www/html/cacti
- mysql -ucacti -pcacti cacti < /var/www/html/cacti/cacti.sql
- vim /var/www/html/cacti/include/config.php
- vim /var/www/html/cacti/include/global.php
$database_default = "cacti"; //默認數據庫名mysql
$database_hostname = "localhost"; //主機名
$database_username = "cacti"; //登錄數據庫用戶名
$database_password = "cacti"; //登錄數據庫密碼
$database_port = "3306";
|
- useradd –r –M cacti
- chown –R cacti /var/www/html/cacti/rra/
- chown –R cacti /var/www/html/cacti/log/
- su cacti
- crontab –e
- */5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1
- php /var/www/html/cacti/poller.php > /dev/null 2>&1
- exit
- 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
- 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/*
- 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
- 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
- vim /var/www/html/nagios/etc/ndomod.cfg
- # 確保下列項的惟一內容爲
- output_type=tcpsocket
- output=127.0.0.1
- cp ./daemon-init /etc/init.d/ndo2db
- vim /etc/init.d/ndo2db
- # 檢查裏面的路徑確保不會出現「//",並將Ndo2dbBin修改爲下面的值:
- Ndo2dbBin=/var/www/html/nagios/bin/ndo2db-3x
- chmod +x /etc/init.d/ndo2db
- service ndo2db start
- tail -20 /var/log/messages ## 查看其中是否有錯誤出現。如無報錯請繼續
- service nagios start
- 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配置文件打補丁的時候注意在爲include/config.php打補丁的時候有可能它將 include/config.php.dist給打補丁了,咱們只須要手動加入下面的內容便可。
- vim include/config.php
- # 修改(或新加入)爲
- $url_path = "/cacti/";
- 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';
- 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 ## 若是發現沒有Phpize文件,則是由於php-devel包沒有安裝致使的
- ./configure
- make && make install
- php -i | grep php.ini ## 查看是否有導入信息
- vim /etc/php.ini
- # 添加
- extension=json.so
- vim /etc/httpd/conf/httpd.conf
- # 添加一行:
- AddType application/x-httpd-php .php .phtml
- # 修改原DirectoryIndex內容爲:
- DirectoryIndex index.html index.html.var index.php
- usermod -G cacti apache
- service httpd restart ## 重啓apache以讓php生效
- php -m ## 查看是否有json被加載
- vim /var/www/html/nagios/etc/ndo2db.cfg
- db_prefix=npc_
- ./mysql -ucacti -p cacti
- mysql> use cacti;
- mysql> alter table npc_eventhandlers add long_output TEXT NOT NULL default '' after output;
- mysql> alter table npc_hostchecks add long_output TEXT NOT NULL default '' after output;
- mysql> alter table npc_hoststatus add long_output TEXT NOT NULL default '' after output;
- mysql> alter table npc_notifications add long_output TEXT NOT NULL default '' after output;
- mysql> alter table npc_servicechecks add long_output TEXT NOT NULL default '' after output;
- mysql> alter table npc_servicestatus add long_output TEXT NOT NULL default '' after output;
- mysql> alter table npc_statehistory add long_output TEXT NOT NULL default '' after output;
- mysql> alter table npc_systemcommands add long_output TEXT NOT NULL default '' after output;
- service ndo2db restart
- service nagios restart
- # 進入mysql數據庫
- mysql> create database nconf;
- # 建立nconf數據庫
- mysql> grant all privileges on nconf.* to nconf@localhost identified by 'nconf';
- # 建立nconf用戶並賦權
- mysql> flush privileges;
- # 刷新特權表
- mysql> quit
- 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/
- 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-ONS/deploy_local.sh
- 修改裏面的Nagios路徑爲 /var/www/html/nagios/etc/
- /var/www/html/nconf/ADD-ONS/deploy_local.sh
- vim /var/www/html/nagios/etc/nagios.cfg
- # 將其中cfg_file=*******字段所有註釋 ,並加入
- cfg_dir=/var/www/html/nagios/etc/Default_collector
- cfg_dir=/var/www/html/nagios/etc/global
- service nagios reload
- # 重載nagios配置文件使之生效
ndomod: Could not open data sink! I'll keep trying, but some output may get lost...linux
解決辦法:
檢查 /nagios/etc目錄的權限是否足夠的大
確保/var/www/html/nagios/etc/nagios.cfg中有以下行出現,不然,請自行添加:
event_broker_options=-1
檢查ndo2db.cfg中的配置,確保使用tcp鏈接
socket_type=tcp
檢查ndomod.cfg中的配置,確保使用tcp套接字
output_type=tcpsocket
|
2.在npc安裝過程當中進行表操做時報錯ios
mysql> alter table npc_eventhandlers add long_output TEXT NOT NULL default '' after output; 解決辦法:要先在cacti頁面下正確的啓用npc插件,正確的啓用~一個向上的箭頭和一個向右的箭頭都要開啓才行~sql |
3.在應用nconf的時候報錯數據庫
點 nconf --> Generate Nagios config --> 報錯了。express Error accessing or executing Nagios / Icinga binary '/var/www/html/nconf/bin/nagios'. 解決辦法: 檢查你的/var/www/html/nconf/bin/nagios這個文件所連接的那個原始文件的權限,確保是777或者775 |
4....固然尚未發現錯誤,若是有,將會繼續補充,歡迎網友在安裝部署的過程當中發現錯誤將錯誤積極交流,我將一一添加……
七:最後的樣式