wget http://mcshell.org/nrpe-2.8.tar.gz
專注于為中小企業(yè)提供成都網(wǎng)站制作、網(wǎng)站建設(shè)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)萬山免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上1000家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
wget http://mcshell.org/nagios-plugins-1.4.13.tar.gz
一、環(huán)境Centos 6.7
ip:192.168.3.150 nagios 和cacti 監(jiān)控主機(jī)
192.168.3.150/152 被檢控主機(jī)
二、安裝準(zhǔn)備
mount
yum –y install httpd php php-MySQL mysql mysql-server php net-snmp-utils rrdtoolsnmp cairo-devel libxml2-devel pango pango-devel
service mysqld start # 啟動(dòng)mysql服務(wù)
chkconfig mysqld on #使其開機(jī)自動(dòng)啟動(dòng)
啟動(dòng)完mysql后,如果出現(xiàn)以下畫面,并能通過mysql進(jìn)入,說明成功安裝。
只要在/etc/httpd/conf/httpd.conf的配置文件中找到
LoadModule status_module modules/mod_status.so
有這一項(xiàng)表示已經(jīng)支持狀態(tài)檢測(cè)模塊,所以無需額外添加,直接啟動(dòng)web服務(wù)即可.
service httpd start #啟動(dòng)http服務(wù)
chkconfig httpd on #開機(jī)自動(dòng)啟動(dòng)httpd 服務(wù)
啟動(dòng)OK后,編輯
vim /var/www/html/index.php 在其中添加以下內(nèi)容#
phpinfo();
?>
# 保存退出
用web瀏覽器訪問,如果出現(xiàn)以下畫面,則表示http支持動(dòng)態(tài)php.并能與php成功連接.
接著測(cè)試與mysql的連接,先給mysql設(shè)置個(gè)管理員密碼
mysqladmin -uroot password '123456' #密碼設(shè)置為123456
編輯剛才的web頁面
vim /var/www/html/index.php
把里面的內(nèi)容改為
if(!$link) echo "FAILD!";
else echo "OK!";
?>
刷新剛才的web瀏覽器頁面,如果出現(xiàn)OK!字樣,則表示成功連接.
下載wget http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.5.5.tar.gz
tar -zxvfrrdtool-1.5.5.tar.gz -C /usr/loacl/
./configure --prefix=/usr/local/rrdtool/ && maek && make install
make 的時(shí)候會(huì)報(bào)錯(cuò)安裝以下即可解決
yum install -y perl-devel perl-CPAN
登陸mysql 創(chuàng)建cacti庫設(shè)置權(quán)限
指定了一個(gè)網(wǎng)段的授權(quán),是將來做監(jiān)控時(shí)數(shù)據(jù)庫和監(jiān)控工具不在同一臺(tái)主機(jī)上,網(wǎng)段可根據(jù)自己需要進(jìn)行授權(quán)
mysql -u root -p
create databasecactidb;
GRANT all privileges ON cactidb.* TOcactier@localhost IDENTIFIED BY '123456';
GRANT all privileges ONcactidb.* TOcactier@127.0.0.1 IDENTIFIED BY '123456';
GRANT all privileges ON cactidb.* TOcactier@192.168.0.0 IDENTIFIED BY '123456';
flush privileges;
在net-snmp的主配置文件/etc/snmp/snmpd.conf中,默認(rèn)的community為public,建議將public修改為您需的密碼項(xiàng),默認(rèn)密碼public
#sec.name source community
com2sec notConfigUser default public
接著,啟動(dòng)snmp進(jìn)程
service snmpd restart #如果修改過snmpd.conf 則需要重啟服務(wù)
下載包
http://www.cacti.net/downloads/cacti-0.8.7a.tar.gz
cacti-0.8.7a.tar.gz
解壓該壓縮包
tar zxvfcacti-0.8.7a.tar.gz -C/usr/local/
##因?yàn)閏acti的配置是在web頁面下進(jìn)行的,所以直接把cacti-0.8.7a 移至/var/www/html/cacti
mv /usr/local/cacti-0.8.7a/var/www/html/cacti
將cacti.sql數(shù)據(jù)庫文件導(dǎo)入,會(huì)提示輸入密碼輸入前面設(shè)置的root 的密碼即可
mysql -u root -pcactidb < cacti.sql
編輯cacti的主配置文件,為其指定對(duì)應(yīng)的數(shù)據(jù)庫參數(shù):
vim /var/www/html/cacti/include/config.php
將下列各參數(shù)的值修改為您前面所設(shè)定的:
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactier";
$database_password = "123456";
$database_port = "3306";
$database_ssl = false;
修改完成后保存退出。
添加cactier用戶 并給其設(shè)置密碼
useraddcactier
passwdcactier
cd /var/www/html/cacti/
#指定rra/ log/的屬組屬主為cactier用戶
chown -R cactier rra/ log/
vim /etc/crontab
##編輯crontab文件 在空白行添加以下內(nèi)容
*/5 * * * * cactier php /var/www/html/cacti/poller.php > /dev/null &
#每5分鐘以cactier去抓取數(shù)據(jù)繪圖,這個(gè)時(shí)間5分鐘應(yīng)該是最小間隔了,可以根據(jù)自己想建議修改為更小值,建議就每5分鐘執(zhí)行一次。
關(guān)閉selinux
vim /etc/sysconfig/selinux
SELINUX=##后面的去掉即可
可以用web瀏覽器訪問cacti進(jìn)行配置管理了。
虛擬機(jī)ip為192.168.3.150 ## IP根據(jù)自己實(shí)際情況可做相應(yīng)修改
從瀏覽器直接訪問以下地址 即可看到cacti配置畫面
http://192.168.3.150/cacti/install/
看清路徑?jīng)]有報(bào)錯(cuò)則默認(rèn)點(diǎn)擊下一步 可以點(diǎn)擊Finish 完成,中間的路徑可能與圖片不同。
Finish后就會(huì)出現(xiàn)登陸畫面 用戶名和秘密都是admin
用戶名admin 密碼admin 即可登陸
進(jìn)入后點(diǎn)擊graphs 會(huì)顯示流量圖
如果不出現(xiàn)圖片執(zhí)行以下命令讓其手動(dòng)繪圖即可.
su - cactier
php /var/www/html/cacti/poller.php > /dev/null 2>&1
exit
數(shù)據(jù)部分啟動(dòng)較慢,請(qǐng)耐心等待,如顯示如上圖片數(shù)據(jù),則成功安裝配置
二、安裝nagios 服務(wù) 和nagios 所依賴的包
yum -y install apache gcc glibc gd
nagios 需要一些基礎(chǔ)支持套件才能運(yùn)行,如apache,gcc,glibc,gd庫等。
useradd -m nagios #添加一個(gè)名為nagios的用戶來運(yùn)行nagios
groupadd nagios #添加nagios用戶組,用以通過web頁面提交外部控制命令
usermod -a -G nagios daemon #將運(yùn)行apache用戶daemon加入nagios組
解壓安裝nagios
tar -zxvf nagios-3.2.3.tar.gz -C /usr/local/
注意下面--with-httpd-conf 的路徑,取決與你apache的
cd /usr/local/nagios-3.2.3
./configure --with-command-group=nagios --with-httpd-conf=/etc/httpd/conf/
##如果沒有報(bào)錯(cuò),就進(jìn)行一下步驟
make all &&make install &&make install-init &&make install-config &&make install-commandmode
#安裝完成沒有報(bào)錯(cuò)開始以下配置
vim /usr/local/nagios/etc/objects/contacts.cfg
make install-webconf
##修改nagiosadmin這行其中的郵件地址為你的email地址,以將報(bào)警郵件發(fā)到你的郵箱
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
##設(shè)置登陸web界面時(shí)HTTP驗(yàn)證的賬號(hào)密碼
下面修改httpd.conf ,yum裝的apache ,配置文件的路徑為如下所示:
vim /etc/httpd/conf/httpd.conf
在空白地方添加一下兩行
# nagios default settings
Include conf/nagios.conf
以上過程配置結(jié)束以后需要重新啟動(dòng)httpd:
# service httpd restart
可以正常啟動(dòng),下面就可以開始編譯、安裝nagios-plugins
tar -zxvf nagios-3.2.3.tar.gz -C /usr/local/
cd nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios && make && maek install
(1)把nagios添加為系統(tǒng)服務(wù)并將之加入到自動(dòng)啟動(dòng)服務(wù)隊(duì)列:
chkconfig --add nagios
chkconfig nagios on
(2)檢查其主配置文件的語法是否正確:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
(3)如果上面的語法檢查沒有問題,接下來就可以正式啟動(dòng)nagios服務(wù)了:
service nagios start
#當(dāng)然,您也可以通過以下方式將nagios的CGI程序運(yùn)行于SELinux/targeted模式而不用關(guān)閉selinux:
chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin
chcon -R -t httpd_sys_content_t /usr/local/nagios/share
(5)通過web界面查看nagios:
http://192.168.3.150/nagios
登錄時(shí)需要指定前面設(shè)定的web認(rèn)證帳號(hào)和密碼 nagiosadmin / 123.com
3.2.2版本的nagios有個(gè)bug .安裝完在/usr/local/nagios/sbin目錄下沒有原來的statusmap.cgi執(zhí)行腳本
點(diǎn)擊左邊的current status 中的Map會(huì)顯示找不到頁面,解決方法只能從老版本中拷貝一個(gè)statusmap.cgi到/usr/local/nagios/sbin目錄下了,并賦予執(zhí)行權(quán)限。
mv statusmap.cgi histogram.cgi /usr/local/nagios/sbin/
如果此時(shí)Nagios進(jìn)程已啟動(dòng),則需要停止并重新啟動(dòng)nagios:
# killall -SIGHUP nagios
# rm -f /usr/local/nagios/var/nagios.lock
# /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
可進(jìn)入nagios的web管理頁面查看log
service httpd restart
說明:
i)此處停止Nagios必須通過向Nagios發(fā)送SIGHUP信號(hào)的方式進(jìn)行;
ii)建議此時(shí)查看nagios日志文件中是否表明ndomod的模塊加載是否正常,以及其是否能正常連接到data sink;查看日志,可以使用如下命令實(shí)現(xiàn):# tail -30 /usr/local/nagios/var/nagios.log
如果此時(shí)Nagios進(jìn)程已啟動(dòng),則需要停止并重新啟動(dòng)nagios:
killall -SIGHUP nagios
rm -f /usr/local/nagios/var/nagios.lock
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
總結(jié):
1.cacti不顯示曲線圖 原因在安裝rrdtool 時(shí)候是否安裝正確在安裝cacti的時(shí)候頁面上的路徑是否有報(bào)警。
2.網(wǎng)頁不訪問看是否關(guān)閉selinux 和iptables防火墻
====================== naginx 添加被監(jiān)控主機(jī)=== ====
[root@localhost libexec]# cd /home/softwares/
[root@localhost softwares]# wget http://nagios.manubulon.com/nagios-snmp-plugins.1.1.1.tgz
[root@localhost softwares]# tar -xvf nagios-snmp-plugins.1.1.1.tgz -C /usr/local/
[root@localhost softwares]# cd /usr/local/nagios_plugins/
配
置check_snmp_int.pl這些插件的使用時(shí)需要配置cpan,CPAN是Comprehensive Perl Archive
Network的縮寫.。它是一個(gè)巨大的Perl軟件收藏庫,收集了大量有用的Perl模塊(modules)及其相關(guān)的文件。這里主要是使用Perl-
Net-SNMP模塊。有兩種方式安裝
perl -MCPAN -e shell
cpan> install Net::SNMP
執(zhí)行nagios-snmp-plugins安裝腳本,執(zhí)行之后會(huì)將插件命令安裝到/usr/local/nagios/libexec下
[root@localhost nagios_plugins]# ./install.sh
[root@localhost nagios_plugins]# cd /usr/local/nagios/libexec/
[root@localhost libexec]# ls
check_apt check_ifstatus check_nt check_snmp_cpfw.pl check_swap
check_breeze check_imap check_ntp check_snmp_css_main.pl check_tcp
check_by_ssh check_ircd check_ntp_peer check_snmp_css.pl check_time
check_clamd check_jabber check_ntp_time check_snmp_env.pl check_udp
check_cluster check_ldap check_nwstat check_snmp_int.pl check_ups
check_dhcp check_ldaps check_oracle check_snmp_linkproof_nhr.pl check_uptime
check_disk check_load check_overcr check_snmp_load.pl check_users
check_disk_smb check_log check_ping check_snmp_mem.pl check_wave
check_dummy check_mailq check_pop check_snmp_nsbox.pl negate
檢測(cè)nagios的配置是否正確,在后面配置nagios過程中我們?yōu)榱藱z測(cè)配置的是否正確需要不斷執(zhí)行該命令來檢查配置文件。
[root@localhost libexec]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios Core 3.2.1
Copyright (c) 2009-2010 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 03-09-2010
License: GPL
開啟nagios服務(wù)
[root@localhost libexec]# /etc/init.d/nagios start
Starting nagios:This account is currently not available.
done.
把nagios加入開機(jī)自啟動(dòng)
[root@localhost libexec]# vim /etc/rc.d/rc.local
/etc/init.d/nagios start
至此nagios安裝完畢
######################監(jiān)控windows主機(jī)###################################
首先在windows主機(jī)上安裝NSClient++插件(64/32位)在安裝的過程中指定監(jiān)控端的ip地址,安裝完后啟動(dòng)NSClient++插件的服務(wù)
在監(jiān)控端配置:
1.進(jìn)入nagios的主配置文件中把監(jiān)控windows.server服務(wù)打開
[root@localhost etc]# vim /usr/local/nagios/etc/nagios.cfg
# Definitions for monitoring a Windows machine
把#cfg_file=/usr/local/nagios/etc/objects/windows.cfg的注釋去掉,開啟監(jiān)控windows服務(wù)功能
cfg_file=/usr/local/nagios/etc/objects/windows.cfg
2.進(jìn)入nagios的命令配置文件中查看是否有監(jiān)控windows的插件命令check_nt,如果沒有還得手動(dòng)添加
root@localhost etc]# vim /usr/local/nagios/etc/objects/commands.cfg
進(jìn)入配置文件中進(jìn)行收索,得知有check_nt命令
define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$
}
3.進(jìn)入windows.cfg文件中
[root@localhost etc]# vim /usr/local/nagios/etc/objects/windows.cfg
define host{
use windows-server ; Inherit default values from a template
host_name winserver ; The name we're giving to this host
alias My Windows Server ; A longer name associated with the host
address 192.168.3.28 ; #把ip地址改為被監(jiān)控主機(jī)的ip地址
}
4.都改完后重啟nagios服務(wù)
[root@localhost etc]# service nagios restar
Running configuration check...done.
Stopping nagios: .done.
Starting nagios:This account is currently not available.
done.
5.進(jìn)入web頁面進(jìn)行查看,看windows主機(jī)是否成功加入。發(fā)現(xiàn)已成功加入
在被監(jiān)控主機(jī)安裝,nrpe naginx 插件
1.解壓文件到/usr/local/
tar -zxvf nrpe-2.15.tar.gz -C /usr/local/
cd /usr/local/nrpe-2.15/
./configure
make all
make install
make install-plugin —監(jiān)控機(jī)需要安裝check_nrpe這個(gè)插件,被監(jiān)控機(jī)并不需要
被監(jiān)控主機(jī)上安裝:
# groupadd nagios
# useradd -g nagios -d /usr/local/nagios -s /sbin/nologin nagios
安裝nagios-plugin:
# ./configure -with-nagios-user=nagios -with-nagios-group=nagios -with-ping-command="/bin/ping"
make
make install
#查看播件文件是否已安裝在這個(gè)目錄有好多的check文件
ls /usr/local/nagios/libexec
配置 NRPE:
# vi /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1
#Nagios監(jiān)控機(jī)的地址或域名
修改/etc/hosts.allow增加監(jiān)控機(jī)ip
# echo 'nrpe:192.168.3.152' >> /etc/hosts.allow
啟動(dòng) NRPE 守護(hù)進(jìn)程:
[root@localhost nagios-plugins-1.4.14]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
可以將此命令加入 /etc/rc.local ,以便開機(jī)自動(dòng)啟動(dòng)。
# echo “/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d” >> /etc/rc.local
可以將此命令加入 /etc/rc.local ,以便開機(jī)自動(dòng)啟動(dòng)。
echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d" >> /etc/rc.local
添加一臺(tái)監(jiān)控機(jī),主控上操作:
在監(jiān)控機(jī)/usr/local/nagios/etc/objects/commands.cfg 添加nrpe的定義
# ‘check_nrpe ‘ command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
增加linuxserver.cfg
在/usr/local/nagios/etc/objects/ 目錄下新建文件:linuxserver.cfg
把linuxserver.cfg添加到nagios主機(jī):
# echo "cfg_file=/usr/local/nagios/etc/objects/linuxserver.cfg“>> /usr/local/nagios/etc/nagios.cfg
如果要再添加新機(jī)器方法炮制就可以了
define host{
use linux-server
host_name192.168.3.152
alias192.168.3.152
address192.168.3.152
}
define service{
use generic-service
host_name192.168.3.152
service_description load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name192.168.3.152
service_description check_ping
check_command check_ping!100.0,20%!200.0,50%
max_check_attempts 5
normal_check_interval 1
}
define service{
use generic-service
host_name192.168.3.152
service_description check_ftp
check_command check_ftp!21
max_check_attempts 5
normal_check_interval 1
}
define service{
use generic-service
host_name192.168.3.152
service_description check_ssh
check_command check_ssh
max_check_attempts 5
normal_check_interval 1
}
define service{
use generic-service
host_name192.168.3.152
service_description check_http
check_command check_http
max_check_attempts 5
normal_check_interval 1
}
或者
define host{
use linux-server
host_name linhost
alias My Linux Server
address 192.168.3.152
check_command check-host-alive
check_interval 5
retry_interval 1
max_check_attempts 5
check_period 24x7
process_perf_data 0
retain_nonstatus_information 0
contact_groups admins
notification_interval 30
notification_period 24x7
notification_options d,u,r
}
define service{
use generic-service
host_name linhost
service_description CHECK USER
check_command check_nrpe!check_users
}
define service{
use generic-service
host_name linhost
service_description Load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name linhost
service_description SDA1
check_command check_nrpe!check_sda1
}
define service{
use generic-service
host_name linhost
service_description Zombie
check_command check_nrpe!check_zombie_procs
}
define service{
use generic-service
host_name linhost
service_description Total procs
check_command check_nrpe!check_total_procs
}
define service{
use generic-service
host_name linhost
service_description HTTP
check_command check_nrpe!check_http
}
define service{
use generic-service
host_name linhost
service_description SSH
check_command check_nrpe!check_ssh
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups admins
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
}
define service{
use generic-service
host_name linhost
service_description MYSQL
check_command check_nrpe!check_mysql
}
===========================================================
添加監(jiān)控主機(jī)的思路
1.定義監(jiān)控主機(jī)
在/usr/local/nagios/etc/objects/
[root@localhost objects]# cat hosts.cfg
define host{
host_name linux-3.152
alias linux-3.152
address 192.168.3.152
check_command check-host-alive
check_interval 5
retry_interval 1
max_check_attempts 5
check_period 24x7
process_perf_data 0
retain_nonstatus_information 0
contact_groups sagroup
notification_interval 30
notification_period 24x7
notification_options d,u,r
}
2.定義主機(jī)監(jiān)控主機(jī)組
[root@localhost objects]# cat contactgroups.cfg
define contactgroup {
contactgroup_name sagroup
alias system administrator group
members nagiosadmin ###給那些成員使用
}
3.定義監(jiān)控主機(jī)監(jiān)控那些服務(wù)
[root@localhost objects]# cat linuxserver.cfg
define service {
host_name linux-3.152
service_description check-host-alive
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check-host-alive
}
define service {
host_name linux-3.152
service_description check-users
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_users
}
define service {
host_name linux-3.152
service_description check-load
check_period 24x7
max_check_attempts 4 ##嘗試最到時(shí)間
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_load
}
define service {
host_name linux-3.152
service_description check-total-procs
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_total_procs
}
define service {
host_name linux-3.152
service_description check-disk
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_disk
}
define service {
host_name linux-3.152
service_description check-ping
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_ping
}
define service {
host_name linux-3.152
service_description check-ssh
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_ssh
}
define service {
host_name linux-3.152
service_description check-http
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_nrpe!check_http
}
4.根據(jù)所作監(jiān)控更改配置文件
[root@localhost objects]# cat ../nagios.cfg | grep -v ^# | grep cfg
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_file=/usr/local/nagios/etc/objects/contactgroups.cfg
cfg_file=/usr/local/nagios/etc/objects/windows.cfg
cfg_file=/usr/local/nagios/etc/objects/linuxserver.cfg
5.更改nrpe 的配置文件監(jiān)控端和被監(jiān)控端為一樣的配置文件
cat ../nrpe.cfg | grep -v ^# | grep check
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_ssh]=/usr/local/nagios/libexec/check_ssh -4 -t 20 -p 22 localhost
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10%
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/hda1
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
command[check_httpd]=/usr/local/nagios/libexec/check_http -I 192.168.3.152 -p 80 -w 1 -c 3
command[check_ping]=/usr/local/nagios/libexec/check_ping -H localhost -w 3000.0,80% -c 5000.0,100% -p 5
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 300 -c 500
6。重起服務(wù)nrpe 和nagios 服務(wù) 后查看監(jiān)控界面
可以根據(jù)以下命令作檢測(cè)
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
7.定義編譯報(bào)經(jīng)郵件
cat contacts.cfg | grep -v ^#
define contact{
contact_name nagiosadmin ; Short name of user ##聯(lián)系人名字也就是給誰發(fā)送
use generic-contact ; Inherit default
values from generic-contact template (defined above) ##應(yīng)用那個(gè)模版
alias Nagios Admin ; Full name of user
email
13522714779@139.com,zhangqiang@228.com.cn,15324168916@189.cn,18244074804@139.com
; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
define contact {
contact_name sa
use generic-contact
alias sa
email 13522714779@139.com,15324168916@189.cn,18244074804@139.com
}
define contact {
contact_name dba
use generic-contact
alias dba
email zhangqiang@228.com.cn
}
define contactgroup {
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}
define contactgroup { ###這個(gè)是自己編寫或者直接用contacts.cfg 里面自己的admin組
contactgroup_name DBAadmins ##組的名字
alias DBA Administrators ##別名
members dba ##應(yīng)用給誰
}
define contactgroup {
contactgroup_name saadmins
alias system Administrator
members sa
}
=====================================
host_notification_options:
d =通知下主機(jī)上,
u =通知在遙不可及的主機(jī)狀態(tài)
r =通知主機(jī)復(fù)蘇(狀態(tài))
f =通知當(dāng)主機(jī)啟動(dòng)和停止拍打
s =發(fā)送通知時(shí),主機(jī)或服務(wù)計(jì)劃停機(jī)時(shí)間開始和結(jié)束
n(沒有)作為一個(gè)選項(xiàng),接觸不會(huì)接收任何類型的主機(jī)通知。
service_notification_options:
w =通知警告服務(wù)狀態(tài)
u =通知在未知的服務(wù)狀態(tài)
c =關(guān)鍵服務(wù)狀態(tài)通知
r =通知服務(wù)復(fù)蘇(好的狀態(tài))
f =通知當(dāng)服務(wù)啟動(dòng)和停止拍打
n(沒有)作為一個(gè)選項(xiàng),接觸不會(huì)接收任何類型的服務(wù)通知。
常用的設(shè)置
host_notification_options:d u r
service_notification_options:w,u c r
=======================================================
總結(jié):
1.cacti不顯示曲線圖 原因在安裝rrdtool 時(shí)候是否安裝正確在安裝cacti的時(shí)候頁面上的路徑是否有報(bào)警。
2.網(wǎng)頁不訪問看是否關(guān)閉selinux 和iptables防火墻
3.在添加監(jiān)控主機(jī)間需要里清之間的關(guān)系(定義監(jiān)控主機(jī)—定義監(jiān)控主機(jī)服務(wù)—定監(jiān)控主機(jī)組—定義配置文件)
監(jiān)控端和被監(jiān)控主機(jī)nrpe 配置需要一致
====================================================================================
cacti 添加主機(jī)監(jiān)控監(jiān)控模板
添加監(jiān)控主機(jī)
Devices—> add添加,desription 主機(jī)名 hostname 被監(jiān)控機(jī)ip host Template 監(jiān)控模板 ucd/net SNMP host選擇這個(gè)模板可
(local Linux Machine 這個(gè)模版可以監(jiān)控本機(jī)磁盤) 以查看監(jiān)控網(wǎng)卡流量---
如過查看不到,就在被監(jiān)控的服務(wù)器上編輯/etc/snmp/snmpd.conf文檔
vi /etc/snmp/snmpd.conf
systemview included .1.3.6.1.2.1.2 如果不顯示監(jiān)控網(wǎng)卡在在
service snmpd restart 重起服務(wù)
Downed Device Detection 選擇監(jiān)控的協(xié)議
Ping Port ping監(jiān)聽端口
Ping Timeout Value 超時(shí)時(shí)間
Ping Retry Count 重試計(jì)數(shù)
snmp version 版本信息建議選擇version 2
snmp comunity 用戶和cacai 配置文件里寫的一樣
snmp port 監(jiān)聽端口
snmp timeout 超時(shí)時(shí)間
Maximum OID's Per Get Request 最大的OID的/ Get請(qǐng)求
Associated Graph Templates———————add 添加監(jiān)控模版
——save 保存
點(diǎn)擊 ———>*Create Graphs for this Host
Graph Templates 圖模版
Data Query 數(shù)據(jù)查詢 —添加監(jiān)控網(wǎng)卡——添加——create 創(chuàng)建
Graph Trees 添加樹 ——Default Tree——add
Parent Item 父項(xiàng)
Tree Item Type 樹向類型
host 監(jiān)控主機(jī)
Graph Grouping Style 圖分組風(fēng)格
Graphs -> Tree Mode 查看監(jiān)控主機(jī)界面
=======================手工導(dǎo)入模版====================
Import/Export 導(dǎo)入導(dǎo)出 找到要導(dǎo)入的模版默認(rèn)下一步就行
Import Templates 導(dǎo)入模版
Export Templates 導(dǎo)出模版
瀏覽——>找到下載模版——>(http://docs.cacti.net/plugins)將下載下來的模版里面的.php 文件復(fù)制到
/var/www/html/cacti/scripts 下同時(shí)注意權(quán)限成功導(dǎo)入可以看到最后一個(gè)也年有好多綠色提示
下載模版官網(wǎng)地址
http://forums.cacti.net/viewforum.php?f=12&sid=fe2532345bf037678cb1e9fb07b40f16
=======================手工導(dǎo)入腳本=========================
Templates 模板
Graph Templates 圖形模版
Host Templates 主機(jī)模版
Data Templates 數(shù)據(jù)模版