第二階段視頻2-39nagios監(jiān)控_第1頁
第二階段視頻2-39nagios監(jiān)控_第2頁
第二階段視頻2-39nagios監(jiān)控_第3頁
第二階段視頻2-39nagios監(jiān)控_第4頁
第二階段視頻2-39nagios監(jiān)控_第5頁
已閱讀5頁,還剩49頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

NagiosNagiosWindowx,Un,Route,tch,具有報警功能,是一個網(wǎng)絡監(jiān)控系統(tǒng)。它可以監(jiān)視你指定的主機和服務,并在那些設備“變壞”和“變好”的時候通知管理員。態(tài)恢復后發(fā)出正常的郵件或短信通知。NagiosCoreLinux當然,它在其他的Unix系統(tǒng)下應該也能進行工作。Nagios os界面很不美觀,可以更換主題 //Nagios插件 NagiosC/SB/S優(yōu)點 1:監(jiān)控網(wǎng)路服務狀態(tài)2:監(jiān)控主機資源(處理器符合,硬盤利用率3:拓展,根據(jù)自己的需求實現(xiàn)拓展檢測功能(插件開發(fā)4:7:8:WEBNagiosNagiosNagiosNagios會維持一個隊列,所有插件返回來的狀態(tài)信息都進入隊列,Nagios首開始讀取信息,并進行處理后,把狀態(tài)結(jié)果通過web顯示出來。Nagios提供了許多插件,利用這些插件可以方便的監(jiān)控很多服務狀態(tài)。安裝完成后,在nagios主目錄下的/libexec里放有nagios自帶的可以使用的所有插件,如,check_diskcheck_loadCPU等等。每一個插件可以通過運行./check_xxx–h來查看其使用方法和功能。獲取數(shù)據(jù)的方式:主動發(fā)送、NRPESNMP、Nagios通過NRPE來遠端管理服務Nagioscheck_nrpe插件,并告訴check_nrpe去檢SSL,check_nrpe連接遠端機子上的NRPENRPE運行本地的各種插件去檢測本地的服務和狀態(tài)最后,NRPEcheck_nrpe,check_nrpe再把結(jié)果送到Nagios狀態(tài)隊列中。NagiosNagiosLAMP #Nagios插件,用于存放腳本和命令 #也就是Nsclient++,用來監(jiān)控Windows,分為64為何32位版本 Nagios NagiosLAP(zabbixLNMPLAP[root@XueGod63~]#yuminstall-ygccglibcglibc-commonphpgdgd-devellibpnglibmnglibjpegzlib[root@XueGod63~]#yuminstall-yhttpd;servicehttpdNagios[root@XueGod63~]#useraddnagios Nagios用nologin的shell,nagios會用到[root@XueGod63~]#groupaddnagcmd [root@XueGod63~]#usermod-Gnagcmdnagios //將Nagios和apache加入該組[root@XueGod63~]#usermod-GnagcmdNagiosnrpe-nagios-plugins-2.1.1.tar.gznrpe-nagios-plugins-2.1.1.tar.gzGeneralNagiosexecutable:Nagiosuser/group:GeneralNagiosexecutable:Nagiosuser/group:#Commanduser/group:#EmbeddedPerl:EventBroker:Install${prefix}:/ #Lockfile:Checkresultdirectory:Initdirectory:Apacheconf.ddirectory:/etc/httpd/conf.d #Apacheconf.d配置Mailprogram:HostOS:linux-WebInterfaceHTMLURL: #CGIURL:http://localhost/nagios/cgi-Traceroute(usedbyWAP):Reviewtheoptionsaboveforaccuracy.Iftheylooktype'makeall'tocompilethemainprogramandCGIs.[root@XueGod63nagios]#makeall//根據(jù)上面提示,Makeall****CompilefinishedIfthemainprogramandCGIscompiledwithoutanyerrors,youcancontinuewithinstallingNagiosasfollows(type'make'withoutanyargumentsforalistofallpossibleoptions):#makeThisinstallsthemainprogram,CGIs,andHTMLmakeinstall-Thisinstallstheinitscriptinmakeinstall-Thisinstallsandconfigurespermissionsonthedirectoryforholdingtheexternalcommandfilemakeinstall-Thisinstalls*SAMPLE*configfilesinYou‘llhavetomodifythesesamplefilesbeforeyouuseNagios.ReadtheHTMLdocumentationformoreondoingthis.Payparticularattentiontothedocsobjectconfigurationfiles,astheydeterminethingsgetmakeinstall-ThisinstallstheApacheconfigfileforthewebmakeinstall- #ThisinstallstheExfoliationthemeforthewebmakeinstall-classicui Thisinstallstheclassicthemefortheweb***SupportNotesIfyouhavequestionsaboutconfiguringorrunningpleasemakesurethatLookatthesampleconfigReadthedocumentationontheNagiosLibrarybeforeyoupostaquestiontooneofthemailingAlsomakesuretoincludepertinentinformationthathelpothershelpyou.ThismightWhatversionofNagiosyouareWhatversionofthepluginsyouareRelevantsnippetsfromyourconfigRelevanterrormessagesfromtheNagioslogFormoreinformationonobtainingsupportforNagios,[root@XueGod63nagios]#makeinstall&&makeinstall-init&&makeinstall-commandmode&&makeinstall-config&&make安裝生成即//makeinstall-init 安裝生成/etc/rc.d/init.d/nagios啟動腳//makeinstall- 下的nagios//makeinstall- nagios 安裝Nagios的WEB配置文件到Apacheconf.d[root@XueGod63nagios]#cd/root/Nagios;config.inc.phpconfig.inc.php rss-corefeed.phpphp imagesindex.phpmain.phprobots.txtrss-newsfeed.phpssimakeinstall-init[root@XueGod63Nagios]#ls #其實就是在makeinstall-configNagios[root@XueGod63Nagios]#lscgi.cfgcgi.cfgnagios.cfgobjects#pluginresource.cfg:定義了很多資源變量的調(diào)[root@XueGod63Nagios]#ls#[root@XueGod63Nagios]#vimAliasAlias/nagiosNagios[root@XueGod63Nagios]#ll#Nagios#nagios配置文件所在目錄,初始安裝只有幾個*.cfg#NagiosCgi#Nagios#日志文件,pidnagios[root@XueGod63Nagios]#vim##系##機,時間#模板(#監(jiān)控本機相關配置文 #(用 # # # #[root@XueGod63Nagios]#vimnagios.cfg###URL后面加上/nagios###Nagios[root@XueGod63Nagios]#servicehttpdvim/etc/httpd/conf.d/nagios.conf[root@XueGod63Nagios]#vimAliasAlias/nagios<Directory"/usr/local/nagios/share">#SSLRequireSSLOptionsNoneAllowOverrideNoneOrderallow,denyAllowfromall#Order##Denyfrom#AllowfromAuthName"NagiosAccess"AuthTypeAuthUserFile/usr/local/nagios/etc/htpasswd.usersRequirevalid-user[root@XueGod63Nagios]#htpasswd--cc[[root@XueGod63Nagios]#cat#[root@XueGod63Nagios]#servicehttpdrestart 用戶名是nagiosadmin,密碼123456)##nagiosnagiosadminnagios,binnagios[root@XueGod63Nagios]#/usr/local/nagios/bin/nagios--v=--verify-configTotalTotalTotal [root@XueGod63Nagios]#/usr/local/nagios/bin/nagios-Nagios-plugins為了后面的實驗要求,我們先把mysql客戶端安裝了yuminstallmysqlmysql-下面[root@XueGod63Nagios]#tarxvfnagios-plugins-2.1.1.tar.gz-[root@XueGod63Nagios]#cd/usr/local/src/nagios-plugins-2.1.1/[root@XueGod63nagios-plugins-2.1.1]#./configure--with-nagios-user=nagios--with-nagios-[root@XueGod63nagios-plugins-2.1.1]#make&&makeinstall; check_ifoperstatuscheck_mysql_queryNagios[root@XueGod63Nagios]#servicehttpdrestart;servicenagiosNagios(指定主配置文件需要加載的配置文件—1:原理數(shù)據(jù)收集,數(shù)據(jù)呈現(xiàn)2Nagiosnrpe5:創(chuàng)建Nagios運行用戶和組,加入我們的運行組6:主程序安裝,./configure–with-command-group=nagcmd(makeall7:htpasswdweb認證用戶并測試登陸8Nagios-pluginsNFS[root@XueGod63Nagios]#cd/usr/local/nagios/etc/objects[root@XueGod63objects]#cplocalhost.cfg [root@XueGod63objects]#vimdefinedefine}check/usr/local/nagios/libexec/目錄下檢測格式:check_tcp!端口號 [root@XueGod63objects]#/etc/init.d/nfsrestart[root@XueGod63objects]#showmount-e3 NFSExportExportlistfor/tmplocalhost[root@XueGod63objects]#vim[root@XueGod63objects]#/usr/local/nagios/bin/nagios-TotalTotalTotal [root@XueGod63objects]#servicenagios nagiosNFS[root@XueGod63objects]#servicenfsstop NFS后有一個Re-schedulethenextcheckofthisservice,強制刷新修改Nagios默認的主題:把主題包解壓到對應的目錄下[root@xuegod63~]#unzipvautour_style.zip-d/usr/local/nagios/share/ replace/usr/local/nagios/share/images/ack.gif?[y]es,[n]o,[A]ll,[N]one,[r]ename:Ainflating:NagiosMYSQL【監(jiān)控任何一臺服務器,工作流程是定義主機,定義服務,定義命令 MySQLServerXueGod64[root@XueGod64~]#yuminstall-ymysql-servermysql[root@XueGod64~]#servicemysqldrestart[root@XueGod64~]#mysql mysql>createdatabasenagiosdb;mysql>grantselectonnagiosdb.*tonagiosdb@'3';mysql>exitXueGod63Nagios[root@XueGod63objects]#vim##Definitionsformonitoringthelocal(Linux)[root@XueGod63objects]#vimdefinedefine # #IP 片statusmap_image ##2D#3D}[root@XueGod63objects]#vimdefinedefine }define}[root@XueGod63objects]#vimdefinedefine $USER1$/check_mysql-H$HOSTADDRESS$-u-d}Uptime:1810Threads:1Uptime:1810Threads:1Questions:6Slowqueries:0Opens:15Flushtables:1Opentables:8Queriespersecondavg:0.3|Connections=4c;;;Open_files=16;;;Open_tables=8;;;Qcache_free_memory=0;;;Qcache_hits=0c;;;Qcache_inserts=0c;;;Qcache_lowmem_prunes=0c;;;he_not_cached=0c;;;Qcache_queries_in_cache=0;;;Queries=6c;;;Table_locks_waitedTable_locks_waited=0c;;;Threads_connected=1;;;Threads_running=1;;;Uptime=1check_commandcommand.cfg才能使用,而command.cfg中的command_line中使用的命令,必須在/usr/local/Nagios/libexecplugins手動檢測command.cfg的命令有效性mysqlplugins才會生成yuminstallmysqlmysql-[root@XueGod64~]#servicemysqldstop //XueGod64[root@XueGod63objects]#/usr/local/nagios/libexec/check_mysql-H-unagiosdb-dcan'tcan'tconnecttoMySQLserveron'4'[root@XueGod63objects]#servicenagiosrestart[root@XueGod64~]#servicemysqldstart去停掉數(shù)據(jù)庫[root@XueGod64~]#servicemysqld定義監(jiān)控httpd服務:先手動測試下:/usr/local/nagios/libexec/check_tcpH4p[root@XueGod63objects]#vimdefinedefine #IP 片statusmap_image ##2D#3D}[root@XueGod63objects]#vimdefinedefine }[root@XueGod63objects]#vimdefinedefine $USER1$/check_tcp-H$HOSTADDRESS$-p}[root@XueGod63objects]#servicenagios私有信息,包括默認的硬盤使用,進程數(shù)目,SWAPNRPEnrpe插NRPEcheck_nrpe,NRPENagioscheck_nrpecheck_nrpenrpe工作原SSLnrpe不需要安裝NAGIOS服務端NRPE1:nagios2:NRPE(makeinstall-daemon-configmakeinstall-xinetd)3:配置我們xinted服務,允許誰來拿數(shù)據(jù)4:解決依[root@XueGod63Nagios]#yuminstall-yopensslopenssl-devel[root@XueGod64~]#yuminstall-yopensslopenssl-develSSL服務端安裝[root@XueGod63Nagios]#tarxvfnrpe-2.15.tar.gz-C/usr/local/src/[root@XueGod63Nagios]#cd/usr/local/src/nrpe-2.15/[root@XueGod63nrpe-2.15]#./configure&&make&&makeinstall[root@XueGod63nrpe-2.15]#makeinstall-plugin&&makeinstall-[root@XueGod63nrpe-2.15]#cd/root/Nagios/;ls #nrpe客戶端配[root@XueGod63objects]#cd[root@XueGod63Nagios]#scpnagios-plugins-2.1.1.tar.gznrpe-2.15.tar.gz[root@XueGod64~]#useradd-s/sbin/nologinnagios[root@XueGod64~]#groupaddnagcmd[root@XueGod64~]#usermod-Gnagcmdnagios[root@XueGod64~]#tarxvfnagios-plugins-2.1.1.tar.gz-C/usr/local/src/[root@XueGod64~]#tarxvfnrpe-2.15.tar.gz-C/usr/local/src/[root@XueGod64~]#cd/usr/local/src/nagios-plugins-2.1.1/[root@XueGod64nagios-plugins-2.1.1]#./configure&&make&&makeinstall[root@XueGod64nagios-plugins-2.1.1]#cd../nrpe-2.15/[root@XueGod64nrpe-2.15]#./configure&&make&&makeinstall[root@XueGod64nrpe-2.15]#makeinstall-daemon-config 用make-install-plugin#default:#description:NRPE(NagiosRemotePluginExecutor)servicenrpe{#default:#description:NRPE(NagiosRemotePluginExecutor)servicenrpe{== ==== =-c/usr/local/nagios/etc/nrpe.cfg--log_on_failure+==nagios服務器地址235nrpeIP#2:#iptables-L不加-n參數(shù),80轉(zhuǎn)->www}echo#NRPE">># 客戶端nrpe命[root@XueGod64~]#vim-w38%-c35%-p/dev/sda1-w42%-c43%-pcommand[check_swap]=/usr/local/nagios/libexec/check_swapw20-c10%#-w-C為告急sda242%[root@XueGod64~]#servicexinetd服務端手動測NRPE[root@XueGod63Nagios]#/usr/local/nagios/libexec/check_nrpeNRPE[root@xuegod73[root@xuegod73~]#/usr/local/nagios/libexec/check_nrpe-H4-cDISKOK-freespace:/20752MB(74%#CHECK_NRPE:Error-CouldnotcompleteSSLhandshake.定義被監(jiān)控主define define statusmap_image}定義需要監(jiān)控的服[root@XueGod63objects]#vimdefinedefineRoot#/root}defineTotal}defineCurrent}定義NRPE監(jiān)控命[root@XueGod63objects]#vimdefinedefine $USER1$/check_nrpe-H$HOSTADDRESS$-c}$ARG1$表示調(diào)用后面的參數(shù)。[root@XueGod63objects]#servicenagios前端監(jiān)rootpartition[root@XueGod64~]#ddif=/dev/zeroof=1.txtcount=100[root@XueGod64~rm-rf 1:(2:NRPE定義主機,定義服務(check_nrpe!check_ping),定義命令(check_nrpe)還有一個定義命令(客戶端做command[check_adfadf])-w–cxinetdroot@XueGod63Nagios]#yuminstall-ysendmail[root@XueGod63Nagios]#/etc/init.d/sendmailstart[root@XueGod63Nagios]#chkconfigsendmailonsendmail --configdefinedefineNagios }[root@XueGod63objects]#servicenagios[root@XueGod64~]#servicemysqld [root@XueGod64~]#/etc/init.d/mysqld 139Windows大概步驟下載安裝windows代理插修改配置文件NSC.INI1、去掉在[modulesCheckWMI.dllRemoteConfiguration.dll;啟動服務nsclient++.exe啟動代理服務,并設置服務和桌面交互Nagios主控端配置修改主配置文件,啟用監(jiān)控windows配置文件編輯這個配置文件,修改監(jiān)控主機信息vimdefineusegeneric-servicehost_namewinserverservice_descriptionUptimecheck_commandcheck_nt!UPTIME}defineusegeneric-servicehost_namewinserverservice_descriptionCPULoadcheck_commandcheck_nt!CPULOAD!-ldefineusegeneric-servicehost_nameservice_descriptionMemorycheck_commandcheck_nt!MEMUSE!-w80-c機器的機器的defineusegeneric-servicehost_nameservice_descriptionC:\Drivecheck_commandcheck_nt!USEDDISKSPACE!-lc-w80-cdefineusegeneric-servicehost_namewinserverservice_descriptionW3SVCcheck_commandcheck_nt!SERVICESTATE!-dSHOWALL-l}defineusegeneric-servicehost_namewinserverservice_descriptionExplorercheck_commandcheck_nt!PROCSTATE!-dSHOWALL-l}定義監(jiān)控命令vi##這個命令已經(jīng)存在,只需要添加-s123456就可以指定密definecommand{command_namecheck_ntcommand_line$USER1$/check_nt-H$HOSTADDRESS$-p12489-s456-v$ARG1$}注意:這里的-s123456密碼一定要windows配置文件的密碼保持一致,重啟如果修改好Nagios配置文件,需要驗證你的配置文件并重啟動Nagios。件。一定要保證驗證過程中不再有出錯信息后再啟動或重啟動Nagios!詳細配置參考/uid-24426415-id-pnp4nagiosprocess_perfdata.plrrdtoolnagiosPnp4nagios使用的是RRDtool工具來實現(xiàn)畫圖的[root@XueGod63Nagios]#yuminstall-yrrdtoolphp-gdperl-Time-HiRes[root@XueGod63Nagios]#tarxvfpnp4nagios-0.6.25.tar.gz[root@XueGod63Nagios]#cdpnp4nagios-0.6.25[root@XueGod63pnp4nagios-0.6.25]#./configure--prefix=/usr/local/pnp4nagios--with-nagios-[root@XueGod63pnp4nagios-0.6.25]#makeall&&makeinstall&&makeinstall-webconf&&makeinstall-config&&makeinstall-init[root@XueGod63pnp4nagios-0.6.25]#makefullinstallpnp4naigos和nagios[root@XueGod63pnp4nagios]###修改以下幾個內(nèi)#修#取消注[root@XueGod63pnp4nagios]###'process-host-perfdata'commanddefinitiondefinecommand{ /usr/bin/perl/usr/local/pnp4nagios/libexec/process_perfdata.pl-dHOSTPERFDATA}#'process-service-perfdata'commanddefinitiondefinecommand{ /usr/bin/perl/usr/local/pnp4nagios/libexec/p}[root@XueGod63pnp4nagios]#definedefinehost action_url/pnp4nagios/index.php/graph?host=$HOSTNAME$' 1}defines

溫馨提示

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

評論

0/150

提交評論