nagios監(jiān)控工具原理及安裝_第1頁
nagios監(jiān)控工具原理及安裝_第2頁
nagios監(jiān)控工具原理及安裝_第3頁
nagios監(jiān)控工具原理及安裝_第4頁
nagios監(jiān)控工具原理及安裝_第5頁
已閱讀5頁,還剩30頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)

文檔簡介

1、Nagios高度插件化模板說明主機、服務(wù)、管理員都可以定義模板template如上圖,nagios支持ssh,nrpe,snmp,nsca四類插件也可以支持用戶自定義的插件來獲取遠端被監(jiān)控對象的資源狀態(tài)Ssh 需要在遠程服務(wù)器運行ssh進程,能給接收接收core端的ssh命令并把結(jié)果返回給core端,插件把取得結(jié)果分析,分析給個返回給核心不能監(jiān)控windows主機Nrpe 專門用來監(jiān)控linux和unix主機的插件,在遠程主機安裝nrpe服務(wù),nrpe上也需要再安裝很多插件,插件獲取主機資源信息返回給nrpe服務(wù),nrpe通過網(wǎng)絡(luò)返回給core端的check_nrpe進程,check_nrpe

2、分析并返回給核心 windows有個nsclient+協(xié)議類似linux的nrpe服務(wù)Snmp 只需遠程主機打開161端口,core端發(fā)送udp命令在遠程主機執(zhí)行,遠程主機把結(jié)果返回core端,core端snmp插件分析并返回給核心??梢灾С謜indowsNsca 被動監(jiān)控機制,是等待遠程主機主動發(fā)送數(shù)據(jù)狀態(tài)信息使用的插件主機間的依賴關(guān)系舉例來說,如果監(jiān)控端和被監(jiān)控端連在同一交換機上,如果交換機發(fā)生故障,則監(jiān)控端認為被監(jiān)控端主機故障,則被監(jiān)控機和交換機就是依賴關(guān)系,nagios設(shè)置交換機故障則暫停連在其上所有被監(jiān)控主機的監(jiān)控Nagios組成監(jiān)控端端裝nagios daemon、 nagiosp

3、lugin、 nrpe,客戶端也安裝nrpe,但是nrpe是依賴于nagios plugin工作的,所以客戶端也需要安裝nagios plugin,如果基于snmp協(xié)議的話不用安裝nrpe,客戶端也不用安裝nagios plugin,windows客戶端需要安裝NSCLIENT+現(xiàn)在開始安裝監(jiān)控端rootdirector # yum -y install httpd php mysql-devel php-mysqlrootdirector # groupadd nagcmdrootdirector # useradd -G nagcmd nagiosrootdirector # passwd

4、 nagiosChanging password for user nagios.New password: BAD PASSWORD: it is based on a dictionary wordBAD PASSWORD: is too simpleRetype new password: passwd: all authentication tokens updated successfully.rootdirector #把apache加入到nagcmd組,rootdirector # usermod -a -G nagcmd apacherootdirector #rootdire

5、ctor # id nagiosuid=501(nagios) gid=502(nagios) groups=502(nagios),501(nagcmd)rootdirector #調(diào)整時間日期rootdirector tools# dateTue Apr 26 22:29:56 EDT 2016rootdirector tools# date 042710302016.50Wed Apr 27 10:30:50 EDT 2016rootdirector tools#下載軟件包rootdirector zhanggy# cd tools/rootdirector tools# lscacti

6、-0.8.8a.tar.gz nagios-3.3.1.tar.gz nagios nagios-plugins-1.4.15rootdirector tools# pwd/home/zhanggy/toolsrootdirector tools#解壓rootdirector tools# tar -zxf nagios-plugins-1.4.15.tar.gz rootdirector tools# tar -zxf nagios-3.3.1.tar.gzrootdirector tools# lscacti-0.8.8a.tar.gz nagios-plugins-1.4.15nagio

7、s nagios-plugins-1.4.15.tar.gznagios-3.3.1.tar.gzrootdirector tools#編譯安裝rootdirector tools# cd nagios rootdirector nagios# ./configure -sysconfdir=/etc/nagios -with-command-group=nagcmd -enable-event-brokerrootdirector nagios# make allrootdirector nagios# make install自動提示我們安裝三個組件 make install-init -

8、 This installs the init script in /etc/rc.d/init.d make install-commandmode - This installs and configures permissions on the directory for holding the external command file make install-config - This installs sample config files in /etc/nagiosmake1: Leaving directory /home/zhanggy/tools/nagios'

9、一一安裝rootdirector nagios# make install-init/usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d/usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios* Init script installed *rootdirector nagios# make install-commandmode/usr/bin/install -c -m 775 -o nagios -g nagcmd -

10、d /usr/local/nagios/var/rwchmod g+s /usr/local/nagios/var/rw* External command directory configured *rootdirector nagios# make install-config/usr/bin/install -c -m 775 -o nagios -g nagios -d /etc/nagios/usr/bin/install -c -m 775 -o nagios -g nagios -d /etc/nagios/objects/usr/bin/install -c -b -m 664

11、 -o nagios -g nagios sample-config/nagios.cfg /etc/nagios/nagios.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /etc/nagios/cgi.cfg/usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /etc/nagios/resource.cfg/usr/bin/install -c -b -m 664 -o nagios

12、-g nagios sample-config/template-object/templates.cfg /etc/nagios/objects/templates.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /etc/nagios/objects/commands.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts

13、.cfg /etc/nagios/objects/contacts.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /etc/nagios/objects/timeperiods.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /etc/nagios/objects/localhost.cfg/usr/

14、bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /etc/nagios/objects/windows.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /etc/nagios/objects/printer.cfg/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-co

15、nfig/template-object/switch.cfg /etc/nagios/objects/switch.cfg* Config files installed *Remember, these are *SAMPLE* config files. You'll need to readthe documentation for more information on how to actually defineservices, hosts, etc. to fit your particular needs.rootdirector nagios#創(chuàng)建web接口root

16、director nagios# make install-webconf/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf* Nagios/Apache conf file installed *rootdirector nagios#下面是nagios默認的網(wǎng)頁地址rootdirector nagios# ls /usr/local/nagios/bin libexec sbin share varrootdirector nagios#Apache找不到這個地址就需要安裝mak

17、e install-webconf生成配置文件這樣就可以找到了創(chuàng)建web登錄用戶rootdirector nagios# htpasswd -c /etc/nagios/htpasswd.users nagiosadminNew password: Re-type new password: Adding password for user nagiosadminrootdirector nagios#重啟http服務(wù)Adding password for user nagiosadminrootdirector nagios# service httpd stopStopping httpd

18、: AH OK rootdirector nagios# service httpd startStarting httpd: OK rootdirector nagios#把nagios加到服務(wù)當(dāng)中來rootdirector nagios# chkconfig -add nagios設(shè)置開機自啟動rootdirector nagios# chkconfig nagios on啟動服務(wù)rootdirector nagios# service nagios startStarting nagios: done.先關(guān)閉nagios服務(wù)安裝nagios插件rootdirector nagios# s

19、ervice nagios stopStopping nagios: done.rootdirector nagios#rootdirector tools# cd nagios-plugins-1.4.15rootdirector nagios-plugins-1.4.15# ./configure -with-nagios-user=nagios -with-nagios-group=nagios 注意這里不使用nagcmd用戶如果要監(jiān)控mysql服務(wù)的話要加with-mysql選項 這個可以./configure help自己選Make Make install啟動nagiosrootd

20、irector nagios-plugins-1.4.15# service nagios startStarting nagios: done.rootdirector nagios-plugins-1.4.15#現(xiàn)在訪問nagios用戶名nagiosadmin 密碼 oracle登錄點擊hosts發(fā)現(xiàn)默認已經(jīng)在監(jiān)控本機點擊localhost可以看見當(dāng)前都有哪些監(jiān)控點擊services這個就是狀態(tài)了我的顯示一切OK配置nagiosrootdirector nagios-plugins-1.4.15# cd /etc/nagios/rootdirector nagios# lscgi.cfg

21、htpasswd.users nagios.cfg objects resource.cfgrootdirector nagios#總共三個配置文件cgi.cfg nagios.cfg resource.cfg其中nagios.cfg為主配置文件Objects對象rootdirector nagios# cd objects/rootdirector objects# lscommands.cfg localhost.cfg switch.cfg timeperiods.cfgcontacts.cfg printer.cfg templates.cfg windows.cfgrootdirec

22、tor objects#這些就是對象了這些對象可以隨意放位置,只要在主配置文件里面注明位置rootdirector nagios# vim nagios.cfg我們看見默認已經(jīng)存在的對象就是localhost.cfg所以我們在頁面里面看見localhost有關(guān)信息可以把一個目錄下的所有文件都作為對象Nagios支持變量定義配置文件,32個也叫宏可以自己定義rootdirector nagios# cat resource.cfg # RESOURCE.CFG - Sample Resource File for Nagios 3.3.1# Last Modified: 09-10-2003#

23、You can define $USERx$ macros in this file, which can in turn be used# in command definitions in your host config file(s). $USERx$ macros are# useful for storing sensitive information such as usernames, passwords, # etc. They are also handy for specifying the path to plugins and # event handlers - i

24、f you decide to move the plugins or event handlers to# a different directory in the future, you can just update one or two# $USERx$ macros, instead of modifying a lot of command definitions.# The CGIs will not attempt to read the contents of resource files, so# you can set restrictive permissions (6

25、00 or 660) on them.# Nagios supports up to 32 $USERx$ macros ($USER1$ through $USER32$)# Resource files may also be used to store configuration directives for# external data sources like MySQL.# Sets $USER1$ to be the path to the plugins$USER1$=/usr/local/nagios/libexec# Sets $USER2$ to be the path

26、to event handlers#$USER2$=/usr/local/nagios/libexec/eventhandlers# Store some usernames and passwords (hidden from the CGIs)#$USER3$=someuser#$USER4$=somepassword我們看看黃色部分第一個宏下面到底是啥rootdirector nagios# cd /usr/local/nagios/libexecrootdirector libexec# lscheck_apt check_disk check_hpjd check_ircd chec

27、k_mrtg check_nt check_ping check_smtp check_time utils.pmcheck_breeze check_disk_smb check_http check_jabber check_mrtgtraf check_ntp check_pop check_snmp check_udp utils.shcheck_by_ssh check_dns check_icmp check_ldap check_mysql check_ntp_peer check_procs check_spop check_upscheck_clamd check_dummy

28、 check_ide_smart check_ldaps check_mysql_query check_ntp_time check_real check_ssh check_userscheck_cluster check_file_age check_ifoperstatus check_load check_nagios check_nwstat check_rpc check_ssmtp check_wavecheck_dhcp check_flexlm check_ifstatus check_log check_nntp check_oracle check_sensors ch

29、eck_swap negatecheck_dig check_ftp check_imap check_mailq check_nntps check_overcr check_simap check_tcp urlizerootdirector libexec#看見一大堆插件第一個已經(jīng)定義好了,不要改,后面31個可以隨便定義同時nagios也支持額外的宏下面這個文件保留所有監(jiān)控結(jié)果的狀態(tài)信息Nagios監(jiān)控windows主機先下載nsclient+安裝時注意,允許誰來進行監(jiān)控那里填nagios主機ip地址,其它下一步就可以12489端口就是我們nsclient+打開的端口5666是nrpe使

30、用的端口回到nagios的插件目錄rootdirector libexec# cd /usr/local/nagios/libexec/rootdirector libexec# lscheck_apt check_ide_smart check_nntps check_spopcheck_breeze check_ifoperstatus check_nt check_sshcheck_by_ssh check_ifstatus check_ntp check_ssmtpcheck_clamd check_imap check_ntp_peer check_swapcheck_cluster

31、 check_ircd check_ntp_time check_tcpcheck_dhcp check_jabber check_nwstat check_timecheck_dig check_ldap check_oracle check_udpcheck_disk check_ldaps check_overcr check_upscheck_disk_smb check_load check_ping check_userscheck_dns check_log check_pop check_wavecheck_dummy check_mailq check_procs negat

32、echeck_file_age check_mrtg check_real urlizecheck_flexlm check_mrtgtraf check_rpc utils.pmcheck_ftp check_mysql check_sensors utils.shcheck_hpjd check_mysql_query check_simapcheck_http check_nagios check_smtpcheck_icmp check_nntp check_snmprootdirector libexec#黃色插件就是我們要用的可以先測試一下能不能正常使用可以./check_nt h

33、查看用法rootdirector libexec# ./check_nt -H -p 12489 -v UPTIME System Uptime - 0 day(s) 8 hour(s) 43 minute(s)rootdirector libexec#rootdirector libexec# ./check_nt -H -p 12489 -v CPULOAD -w 80 -c 90 -l 5,80,90CPU Load 4% (5 min average) | '5 min avg Load'=4%;80;90;0;100

34、rootrootdirector libexec# ./check_nt -H -p 12489 -v USEDDISKSPACE -w 80 -c 90 -l CC: - total: 80.01 Gb - used: 45.91 Gb (57%) - free 34.09 Gb (43%) | 'C: Used Space'=45.91Gb;64.00;72.00;0.00;80.01rootdirector libexec#定義對象rootdirector nagios# cd objects/rootdirector objects# pwd/

35、etc/nagios/objectsrootdirector objects#1定義命令rootdirector objects# vim commands.cfg2,定義主機rootdirector objects# vim windows.cfg3,定義服務(wù)rootdirector objects# vim windows.cfg!把后面所有東西當(dāng)一個參數(shù)$ARG1$:.,$swinserverwinhostg啟用對象配置文件rootdirector nagios# vim nagios.cfg標(biāo)紅的一行我新加的驗證一下我改的配置文件rootdirector nagios# /usr/lo

36、cal/nagios/bin/nagios -v /etc/nagios/nagios.cfg Nagios Core 3.3.1Copyright (c) 2009-2011 Nagios Core Development Team and Community ContributorsCopyright (c) 1999-2009 Ethan GalstadLast Modified: 07-25-2011License: GPLWebsite: Reading configuration data. Read main config file oka

37、y.Processing object config file '/etc/nagios/objects/commands.cfg'.Warning: Duplicate definition found for command 'check_nt' (config file '/etc/nagios/objects/commands.cfg', starting on line 240)Error: Could not add object property in file '/etc/nagios/objects/commands.c

38、fg' on line 241. Error processing object config files!*> One or more problems was encountered while processing the config files. Check your configuration file(s) to ensure that they contain valid directives and data defintions. If you are upgrading from a previous version of Nagios, you shoul

39、d be aware that some variables/definitions may have been removed or modified in this version. Make sure to read the HTML documentation regarding the config files, as well as the 'Whats New' section to find out what has changed.rootdirector nagios#發(fā)現(xiàn)黃色部分有問題有重復(fù)rootdirector nagios# lscgi.cfg ht

40、passwd.users nagios.cfg objects resource.cfgrootdirector nagios# cd objects/rootdirector objects# lscommands.cfg contacts.cfg localhost.cfg printer.cfg switch.cfg templates.cfg timeperiods.cfg windows.cfgrootdirector objects# vim commands.cfg剛才定義重復(fù)了注釋掉rootdirector objects# /usr/local/nagios/bin/nagi

41、os -v /etc/nagios/nagios.cfg Nagios Core 3.3.1Copyright (c) 2009-2011 Nagios Core Development Team and Community ContributorsCopyright (c) 1999-2009 Ethan GalstadLast Modified: 07-25-2011License: GPLWebsite: Reading configuration data. Read main config file okay.Processing object

42、 config file '/etc/nagios/objects/commands.cfg'.Processing object config file '/etc/nagios/objects/contacts.cfg'.Processing object config file '/etc/nagios/objects/timeperiods.cfg'.Processing object config file '/etc/nagios/objects/templates.cfg'.Processing object con

43、fig file '/etc/nagios/objects/windows.cmf'.Error: Cannot open config file '/etc/nagios/objects/windows.cmf' for reading: No such file or directory Error processing object config files!*> One or more problems was encountered while processing the config files. Check your configurati

44、on file(s) to ensure that they contain valid directives and data defintions. If you are upgrading from a previous version of Nagios, you should be aware that some variables/definitions may have been removed or modified in this version. Make sure to read the HTML documentation regarding the config fi

45、les, as well as the 'Whats New' section to find out what has changed.還有錯誤發(fā)現(xiàn)是剛才寫錯了rootdirector nagios# /usr/local/nagios/bin/nagios -v /etc/nagios/nagios.cfg Nagios Core 3.3.1Copyright (c) 2009-2011 Nagios Core Development Team and Community ContributorsCopyright (c) 1999-2009 Ethan GalstadLa

46、st Modified: 07-25-2011License: GPLWebsite: Reading configuration data. Read main config file okay.Processing object config file '/etc/nagios/objects/commands.cfg'.Processing object config file '/etc/nagios/objects/contacts.cfg'.Processing object config file '

47、/etc/nagios/objects/timeperiods.cfg'.Processing object config file '/etc/nagios/objects/templates.cfg'.Processing object config file '/etc/nagios/objects/windows.cfg'.Processing object config file '/etc/nagios/objects/localhost.cfg'. Read object config files okay.Running

48、pre-flight check on configuration data.Checking services. Checked 15 services.Checking hosts. Checked 2 hosts.Checking host groups. Checked 2 host groups.Checking service groups. Checked 0 service groups.Checking contacts. Checked 1 contacts.Checking contact groups. Checked 1 contact groups.Checking

49、 service escalations. Checked 0 service escalations.Checking service dependencies. Checked 0 service dependencies.Checking host escalations. Checked 0 host escalations.Checking host dependencies. Checked 0 host dependencies.Checking commands. Checked 24 commands.Checking time periods. Checked 5 time

50、 periods.Checking for circular paths between hosts.Checking for circular host and service dependencies.Checking global event handlers.Checking obsessive compulsive processor commands.Checking misc settings.Total Warnings: 0Total Errors: 0Things look okay - No serious problems were detected during th

51、e pre-flight checkrootdirector nagios好了,沒錯了重啟nagiosrootdirector nagios# service nagios restartRunning configuration check.done.Stopping nagios: done.Starting nagios: done.rootdirector nagios#去頁面看看有東西沒有有了東西點開看看Pebding表示正在檢測 ok表示ok現(xiàn)在展示通過nrpe方式檢測linux被監(jiān)控端先安裝nagios-plugins然后安裝nrpe啟動,打開5666端口供nagios主機監(jiān)控監(jiān)

52、控端也要補安裝nrpe但是不需要啟動被監(jiān)控端1, 安裝開發(fā)包組rootdata-1-2 # yum -y groupinstall "Development Tools" "Development Libraries"2, 調(diào)整被監(jiān)控主機時間rootdata-1-2 # date 042718062016.50Wed Apr 27 18:06:50 PDT 2016rootdata-1-2 # 3, 解壓軟件包rootdata-1-2 # cd /home/zhanggy/tools/rootdata-1-2 tools# lsdrbd-8.4.4 mysql-5.5.32.tar.gzdrbd-8.4.4.tar.gz nagios-plugins-1.4.15.tar.gzlibart_lgpl-2.3.17 nrpe-2.12.tar.gzlibart_lgpl-2.3.17.tar.gz rrdtool-1.2.30mysql-5.5.32 rrdtool-1.2.30.tar.gzrootdata-1-2 tools# tar -zxf nrpe-2.12.tar.gz rootdata-1-2 tools# tar -zxf nagios-plugins-1.4.15.tar.gz rootdata-1-2 too

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論