您好,登錄后才能下訂單哦!
與在redhat安裝nagios相比,在ubuntu安裝nagios監(jiān)控非常簡(jiǎn)單,直接通過(guò)
apt-get即可從ubuntu的服務(wù)器上下載組件自動(dòng)安裝。
sudo apt-get install nagios3 nagios-nrpe-plugin
給nagiosadmin添加一個(gè)密碼:
sudo htpasswd /etc/nagios3/htpasswd.users nagiosadmin
添加一個(gè)用戶:
sudo htpasswd /etc/nagios3/htpasswd.users dragon
在被監(jiān)控主機(jī)上安裝nrpe,
sudo apt-get install nagios-nrpe-server
sudo vi /etc/nagios/nrpe.cfg
找到allowed_host添加監(jiān)控主機(jī)的ip地址:
allowed_hosts=127.0.0.1,192.168.1.112
Service nrpe restart
在server端測(cè)試
/usr/lib/nagios/plugins/check_nrpe -H 192.168.1.124,測(cè)試成功的話會(huì)輸出客戶機(jī)的NRPE版本號(hào)。
NRPE_2.1.4
在server新建監(jiān)控主機(jī)定義文件server02.cfg
sudo cp /etc/nagios3/conf.d/localhost_nagios2.cfg \/etc/nagios3/conf.d/server02.cfg
編輯 /etc/nagios3/conf.d/server02.cfg:注意修改address為被監(jiān)控主機(jī)的地址,并添加DNS,http,ssh的服務(wù)監(jiān)控。
define host{
use generic-host
host_name server02
alias server-02
address 192.168.1.124
}
define service{
use generic-service
host_name server02
service_description Disk Space
check_command check_all_disks!20%!10%
}
define service{
use generic-service
host_name server02
service_description Current Users
check_command check_users!20!50
}
define service{
use generic-service
host_name server02
service_description Total Processes
check_command check_procs!250!400
}
define service{
use generic-service
host_name server02
service_description Current Load
check_command check_load!5.0!4.0!3.0!10.0!6.0!4.0
}
define service{
use generic-service
host_name server02
service_description DNS
check_command check_dns!192.168.1.124
}
define service {
host_name server02
service_description HTTP
check_command check_http
use generic-service
notification_interval 0
}
# check that ssh services are running
define service {
host_name server02
service_description SSH
check_command check_ssh
use generic-service
notification_interval 0
}
測(cè)試nagios配置是否成功
nagios3 -v /etc/nagios3/nagios.cfg
Error in configuration file '/etc/nagios3/nagios.cfg' - Line 470 (Check result path is not a valid directory)
這個(gè)文件是nagios用于存儲(chǔ)監(jiān)測(cè)主機(jī)的結(jié)果和未能監(jiān)測(cè)到的服務(wù)信息
check_result_path=/var/lib/nagios3/spool/checkresults
我發(fā)現(xiàn)本機(jī)上并沒(méi)有這個(gè)文件目錄的存在,所以我新建了這個(gè)文件,可能會(huì)出現(xiàn)啟動(dòng)nagios沒(méi)有報(bào)錯(cuò),但無(wú)法看到監(jiān)控信息的情況,查看日志提示“Jul 16 20:00:59 fileserver nagios: Error: Could not open check result queue directory '/var/nagios/spool/checkresults' for reading. ”.
Sudo mkdir /var/lib/nagios3/spool/checkresults
Sudo chmod nagios:nagios /var/lib/nagios3/spool/checkresults
啟動(dòng)nagios
Service nagios3 start
打開在瀏覽器地址欄輸入:“ip\nagios3”
利用NSClient++監(jiān)控遠(yuǎn)程Windows上的“本地信息”
在Nagios的libexec下有check_nt這個(gè)插件,它就是用來(lái)檢查windows機(jī)器的服務(wù)的。其功能類似于check_nrpe。不過(guò)還需要搭配另外一個(gè)軟件NSClient++,它則類似于NRPE。
NSClient++的原理如下圖
可以看到NSClient與nrpe最大的區(qū)別就是:
被監(jiān)控機(jī)上安裝有nrpe,并且還有插件,最終的監(jiān)控是由這些插件來(lái)進(jìn)行的。當(dāng)監(jiān)控主機(jī)將監(jiān)控請(qǐng)求發(fā)給nrpe后,nrpe調(diào)用插件來(lái)完成監(jiān)控。
NSClient++則不同,被監(jiān)控機(jī)上只安裝NSClient,沒(méi)有任何的插件。當(dāng)監(jiān)控主機(jī)將監(jiān)控請(qǐng)求發(fā)給NSClient++后,NSClient直接完成監(jiān)控,所有的監(jiān)控是由NSClient完成的。
這也說(shuō)明了NSClient++的一個(gè)很大的問(wèn)題:不靈活、沒(méi)有可擴(kuò)展性。它只能完成自己本身包含的監(jiān)控操作,不能由一些插件來(lái)擴(kuò)展。好在NSClient++已經(jīng)做的不錯(cuò)了,基本上可以完全滿足我們的監(jiān)控需求。
安裝NSClient++
使用check_nt可以看到winserver上nsclient++的監(jiān)控情況(注意需要指定端口為:12489)
要注意兩臺(tái)主機(jī)之間網(wǎng)絡(luò)是否聯(lián)通,使用ping測(cè)試網(wǎng)絡(luò)聯(lián)通,winserver的防火墻有可能阻斷兩臺(tái)主機(jī)之間的網(wǎng)絡(luò)通信,可以選擇關(guān)掉。
編輯nagios server端的nt.cfg里面的命令check_nt增加一些參數(shù)。
sudo vi /etc/nagios-plugins/config/nt.cfg
Sudo vi /etc/nagios3/objects/windows.cfg
define host{
use generic-host ; Inherit default values from a template
host_name Nagios-Windows ; The name we're giving to this host
alias My Windows Server ; A longer name associated with the host
address 192.168.1.139 ; IP address of the host
}
define hostgroup{
hostgroup_name windows-servers ; The name of the hostgroup
alias Windows Servers ; Long name of the group
}
define service{
use generic-service
host_name Nagios-Windows
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}
define service{
use generic-service
host_name Nagios-Windows
service_description Uptime
check_command check_nt!UPTIME
}
define service{
use generic-service
host_name Nagios-Windows
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}
define service{
use generic-service
host_name Nagios-Windows
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}
define service{
use generic-service
host_name Nagios-Windows
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
define service{
use generic-service
host_name Nagios-Windows
service_description W3SVC
check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
}
define service{
use generic-service
host_name Nagios-Windows
service_description Explorer
check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
}
測(cè)試nagios配置是否成功
nagios3 -v /etc/nagios3/nagios.cfg
service nagios3 restart
Sudo vi /etc/nagios3/nagios.cfg把#cfg_file=/etc/nagios3/objects/windows.cfg前面的#給去掉。使用“nagios3 -v /etc/nagios3/nagios.cfg”測(cè)試是否有錯(cuò)。沒(méi)有報(bào)錯(cuò)的話,開啟nagios3.
用瀏覽器打開nagios的控制臺(tái)等待一段時(shí)間之后就可以看到實(shí)驗(yàn)效果了。
本文允許轉(zhuǎn)載但務(wù)必保留出處:(http://dragon123.blog.51cto.com/9152073/1543915)
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。