Nagios安裝配置1-Linux配置-坐沙發(fā)上等戈多_第1頁
Nagios安裝配置1-Linux配置-坐沙發(fā)上等戈多_第2頁
Nagios安裝配置1-Linux配置-坐沙發(fā)上等戈多_第3頁
Nagios安裝配置1-Linux配置-坐沙發(fā)上等戈多_第4頁
Nagios安裝配置1-Linux配置-坐沙發(fā)上等戈多_第5頁
已閱讀5頁,還剩17頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

Nagios安裝配置[1]-Linux 配置 -坐沙發(fā)上等戈多安裝問題 (我找到的中文版之中最好的一個 ,我照著手冊裝了一下,不成功,轉而按照此文,最終成,限于篇幅原因就不在貼上來了,我自己的安裝步驟基本上和這篇相同)/index.php?play=search&make=view&id=282&key=nagios我的安裝步驟(操作系統(tǒng) centoslinxu4.3)1、所需軟件nagios-pluginsimagepak-basenrpeapache2、nagios安裝首先安裝apache 具體過程參考 手冊不在贅述w[]#addusernagios[]#groupaddnagios[]#mkdir/usr/local/nagios[]#./configure--prefix=/usr/local/nagios--with-gd-lib=/usr/local/lib--with-gd-inc=/usr/local/include上面命令用到的 libgd庫,在centos下的安裝可以用以下命令[]#yuminstallgd(gdbphp-gdglib-develgd-devellibpng-devellibpng10-devellibjpeg-develmod_perl-develglibcmod_perl)具體的可參考我上文給出的聯(lián)接[]#makeall[]#makeinstall[]#makeinstall-init ##Thisinstallstheinitscriptin/usr/local/etc/rc.d[]#makeinstall-commandmode[]#makeinstall-config ##將初始的配置文件安裝到/usr/local/nagios/etc2.2、nagios-plugins 的安裝[]#tar–[]#mkdir/usr/local/nagios-plugins[]#./configure--prefix=/usr/local/nagios-plugins[]#makeall[]#makeinstall安裝完成以后在/usr/local/nagios-plugins會產生一個libexec的目錄,將該目錄全部移動到/usr/local/nagios目錄下[]#cp/usr/local/nagios-plugins/libexec/usr/local/nagios/libexec2.3、imagepak-base 的安裝[]#tar–解壓以后是 base目錄[]#cp–Rbase/usr/local/nagios/share/images/logos2.4、安裝過程全部結束4、Nagios的設定:1、配置apache在apache的配置文件httpd.conf中追加(注意,要有image這段,不然 nagios不能顯示圖片,這三段順序好象不能變,不然啟動nagios的時候會提示錯誤 )Alias/nagios/cgi-bin/images/"/usr/local/nagios/share/images/"<Directory"/usr/local/nagios/share/images/">AllowOverrideNoneOptionsNoneOrderallow,denyAllowfromallAuthName"NagiosAccess"AuthTypeBasicAuthUserFile/usr/local/nagios/etc/.htpasswdRequirevalid-user</Directory>ScriptAlias/nagios/cgi-bin/"/usr/local/nagios/sbin/"<Directory"/usr/local/nagios/sbin/">AllowOverrideNoneOptionsNoneOrderallow,denyAllowfromallAuthName"NagiosAccess"AuthTypeBasicAuthUserFile/usr/local/nagios/etc/.htpasswdRequirevalid-user</Directory>Alias/nagios/"/usr/local/nagios/share/"<Directory"/usr/local/nagios/share/">AllowOverrideNoneOptionsNoneOrderallow,denyAllowfromallAuthName"NagiosAccess"AuthTypeBasicAuthUserFile/usr/local/nagios/etc/.htpasswdRequirevalid-user</Directory>2、設置訪問權限在/usr/local/nagios/share目錄下[]#/usr/local/www/bin/htpasswd –c/usr/local/nagios/etc/.htpasswdnagios這個apache目錄根據安裝目錄的不同而不同 ,主要所以用.htpasswd 這個命令生成用戶名和密碼3、配置nagios3.1、在/usr/local/nagios/etc 下是nagios的配置模板文件.cfg-sample,把.cfg-sample文件全部拷貝成.cfg例如:[]#cpnagios.cfg-samplenagios.cfg全部拷貝完成即可 .修改minimal.cfg,把里面所有定義 command 的全部注釋掉[]#vi/etc/minimal.cfg(這個我注釋掉好象有問題 待改正)修改cgi.cfg 改use_authentication=1 為use_authentication=0, 即不用驗證.不然有一些頁面不會顯示。建立所有的 cfg文件[]#touchcontactgroups.cfgcontacts.cfghostgroups.cfghosts.cfgservices.cfgtimeperiods.cfg[]#chownnagios.nagioscontactgroups.cfgcontacts.cfghostgroups.cfghosts.cfgservices.cfgtimeperiods.cfg然后檢查配置文件是否出錯/usr/local/nagios/bin/nagios –v/usr/local/nagios/etc/nagios.cfg出現TotalWarnings:0TotalErrors: 0為正常出錯的話,就是.cfg文件有問題 根據錯誤提示 一個個修正3.5、啟動后臺進程/usr/local/nagios/bin/nagios-d/usr/local/nagios/etc/nagios.cfg/usr/local/etc/rc.d/nagiosstart3.6、(如果有些頁面看不到的話 .可以在cgi.cfg文件中把帶有authorized 的選項前的#號去掉即可)這些配置完以后,基本的 nagios配置完成。5、NRPE的安裝.及監(jiān)按指令的布署nrpe 安裝與使用1、遠程主機的配置1.1、安裝openssl[]#yuminstallopenssl(openssl-devel 等等)1.2、安裝nrpe與配置[]#./configure--enable-ssl--with-ssl-lib=/usr/local/nagios/openssl/lib--with-kerberos-inc=/usr/local/nagios/openssl/include--enable-command-args[]#makeall[]#cpsample-config/nrpe.cfg/usr/local/nagios/etc[]#cpsrc/nrpe/usr/local/nagios/bin[]#vi/usr/local/nagios/etc/nrpe.cfg改成你允許的 IP 是nagios服務器)1.3、啟動nrpe,端口為5666/usr/local/nagios/bin/nrpe-c/etc/nrpe.cfg-d1.4、安裝監(jiān)測的模塊nagios-plugins 的安裝tar–mkdir/usr/local/nagios-pluginscdnagios-plugins-1.4./configure--prefix=/usr/local/nagios-pluginsmakeallmakeinstall安裝完成以后在/usr/local/nagios-plugins會產生一個libexec的目錄,將該目錄全部移動到/usr/local/nagios目錄下mv/usr/local/nagios-plugins/libexec/usr/local/nagios2、服務器上的配置2.1、安裝openssl[]#./config--prefix=/usr/local/nagios/openssl[]#make[]#makeinstall2.2、安裝nrpe(主要是使用 check_nrpe 模塊)[]#./configure--enable-ssl--with-ssl-lib=/usr/local/nagios/openssl/lib--with-kerberos-inc=/usr/local/nagios/openssl/include--enable-command-args[]#makeall[]#cpsrc/check_nrpe/usr/local/nagios/libexec2.3、nagios文件的配置vicheckcommands.cfg定義check_nrpe 命令'check_nrep'commanddefinitiondefinecommand{command_namecheck_nrpecommand_line/usr/local/nagios/libexec/check_nrpe-H$HOSTADDRESS$-c$ARG1$}定義檢查遠程主機服務參見Timeperiods[me@mymachinenagios]vimtimeperiods.cfg‘24×7′timeperioddefinitiondefinetimeperiod{timeperiod_name24 ×7alias24HoursADay,7DaysAWeeksunday00:00-24:00monday00:00-24:00tuesday00:00-24:00wednesday00:00-24:00thursday00:00-24:00friday00:00-24:00saturday00:00-24:00}‘workhours’timeperioddefinitiondefinetimeperiod{timeperiod_nameworkhoursalias“Normal”WorkingHoursmonday08:00-17:00tuesday08:00-17:00wednesday08:00-17:00thursday08:00-17:00friday08:00-17:00}‘nonworkhourstimeperiod’definitiondefinetimeperiod{timeperiod_namenonworkhoursaliasNon-WorkHourssunday00:00-24:00monday00:00-09:00,17:00-24:00tuesday00:00-09:00,17:00-24:00wednesday00:00-09:00,17:00-24:00thursday00:00-09:00,17:00-24:00friday00:00-09:00,17:00-24:00saturday00:00-24:00}‘none’timeperioddefinitiondefinetimeperiod{timeperiod_namenonealiasNoTimeIsAGoodTime}Youcanspecifyasmanyoftheseasyouwant.Forinstance,sayyouhaveaneedtocontactfolksonlyontheweekends.Youcancreateatemplate “weekends”anduseonlyFriday,Saturday,Sundaywiththeappropriatetimesasyouseefit.Contacts/ContactGroupsContactsaresplitintotwodifferentfiles.Oneholdstheactualcontactoptions,andtheotherholdscontactstogetheringroups.ThegroupsarewhomyouspecifyNagiostocontactlateron.[me@mymachinenagios]vimcontacts.cfgservice_notification_optionsarew,u,c,r,f,nw=warningu=unknownc=criticalr=recoveryf=flappingn=nonehost_notification_optionsd,u,r,f,nd=downu=unreachabler=recoveryf=flappingn=nonedefinecontact{contact_namemealiasmeservice_notification_period24×7host_notification_period24×7service_notification_optionsc,rhost_notification_optionsd,rservice_notification_commandsnotify-by-emailhost_notification_commandshost-notify-by-emailemailme@myemailaddress.whatever}definecontact{contact_nameyoualiasyouservice_notification_periodworkhourshost_notification_periodworkhoursservice_notification_optionsc,rhost_notification_optionsd,rservice_notification_commandsnotify-by-emailhost_notification_commandshost-notify-by-emailemailyou@youremailaddress.whatever}Youcanchoosetodoasyouwish,butformypurposesIonlysetcontactsuptobenotifiedoncriticalandrecoveryalerts.IreallyhavenointerestinmostthingsI ’mmonitoringalertingmewhentheremaybeatemporaryglitch,orwhensomethingisinawarningstate,especiallyat4:00a.m.ThereasonIdon ’tisbecausea)IfrequentlychecktheNagiosCGIinterfacethroughouttheday,andb)allofmyalertsgetforwardedtoaticketingsystem.Withthatsaid,Idon ’twantunnecessaryticketsbeinggeneratedsimplybecauseapluginfailedtoexecutethistimearound.IfIwasveryinspired,Icouldsetupaseparatecontactandgrouptoreceiveonlythewarningandunknowns,andthenpipethesethroughadifferente-mailaddress.Again,completelyadaptivetoyourneeds.Also,I ’m-mailusingeonly.Mye-mailsystemtakescareofprocessingwherethealertsaregoing.However,youcouldsetupnagiostopipemessagesstraighttopagers.Again,checktheobjectconfigurationoptionsfortimeperiods.cfgonthedocs.Ifyouwanttoseethecommandsbeingprosecutedforalerts,checkout/etc/nagios/misccommands.cfg.Ontothecontactgroups.[me@mymachinenagios]vimcontactgroups.cfg‘einsteins’contactgroupdefinitionsdefinecontactgroup{contactgroup_nameeinsteinsaliaseinsteinsmembersme,you}Thisisasimpleexampleofcontactsandcontactgroups.Youcannestasmanypossibilitiesasyoureallywantto.Youcancreateasmanycontactsyouneedaswell.Itratherstraightforward.HostsandHostGroupsHostandhostgroupinformationisstoredinthetwofileshosts.cfgandhostgroups.cfg.Justasyoucanmixandmatchcontactsinvariouscontactgroups,youcandothesamethingwithhostnamesinhostgroups.IprefertocreatetemplateconfigurationsthatIcanleechoffoflater

’soninmyconfigurationfile.Itsavesyouanincredibleamountoftimetypingdowntheroad.[me@mymachinenagios]vimhosts.cfgGenerichostdefinitionsdefinehost{namegeneric-host;Generictemplatenamenotifications_enabled1;Hostnotificationsareenabledevent_handler_enabled1;Hosteventhandlerisenabledflap_detection_enabled1;Flapdetectionisenabledprocess_perf_data1;Processperformancedataretain_status_information1;Retainstatusinformationacrossprogramrestartsretain_nonstatus_information1;Retainnon-statusinformationacrossprogramrestartsregister0;DONTREGISTERTHISDEFINITION-ITSNOTAREALHOST,JUSTATEMPLATE!}Thiscreatesagenerictemplatethatanyhostcanuse.Notifiesnever,checks15timesbeforeshowingcriticalonCGIinterface,definehost{namebasic-hostusegeneric-hostcheck_commandcheck-host-alivemax_check_attempts15notification_interval0notification_periodnonenotification_optionsnregister0}Thiscreatesagenerichostthatyourrouterscanusemonitorshost(s)24×notifies7,ondownandrecovery,checks15timesbeforegoingcritical,notifiesthecontact_groupevery30minutesdefinehost{nameyour-routers-hostusegeneric-hostcheck_commandcheck-host-alivemax_check_attempts15notification_interval30notification_period24 ×7contact_groupseinsteinsnotification_optionsd,rregister0}definehost{usebasic-hosthost_namemymachine1aliasmymachine1}definehost{useyour-routers-hosthost_namerouter1aliasrouter1}Youcanbegintoseehowmuchtimepredefinedtemplatescansaveyoudowntheroadwhenaddinghosts.I’mmonitoringaround100hostsandover200services,sodoingthingsthetemplatewaycanreallybeproductiveinthelonghaul.Itcangetalittleconfusing,butsticktothedocsandyou ’lllearnprettyquickly.Whenitcomestoallofthetemplateobjectoptionseachfilecancontain,lookforthishttp://localhost(oryourIP)/nagios/docs/configobject.html.Thiswillhelpyoutremendously,becausetherearesomanyoptionsNagiosallowsyoutochoosefrom.IsplitthingsupbecauseIwantnotificationsonyour-routers-host,butIdon’twantnotificationonthebasic-hostcontainer.Startingtounderstandwhyyouusetemplates?Ok,nowontohostgroups.[me@mymachinenagios]vimhostgroups.cfgdefinehostgroup{hostgroup_namebasic-clientsaliasbasicclientsmembersmymachine1}definehostgroup{hostgroup_nameyour-routersaliasroutersmembersrouter1}That’saboutassimpleasthiscanget.Youspecifyyourclientsfromhosts.cfgintohostgroupsinthisfile.Youcansplitthemintomultiplegroups.Forinstance,mymachine1canlivewithinboththebasic-clientsandyour-routersgroupifyousodesired.Prettysimple ?ServicesTostart,you’regoingtoneedatleastoneservicetomonitor.Thiswouldbeasimplecheck-host-alive,orping.Again,Isplitthingsintotemplatestomakeiteasierdowntheroadjustasdemonstratedabove.[me@mymachinenagios]vimservices.cfgGenericservicedefinitiontemplatedefineservice{namegeneric-service;Genericservicenameactive_checks_enabled1;Activeservicechecksareenabledpassive_checks_enabled1;Passiveservicechecksareenabled/acceptedparallelize_check1;Activeservicechecksshouldbeparallelized(don ’tdisable)obsess_over_service1;Weshouldobsessoverthisservice(ifnecessary)check_freshness0;DefaultistoNOTcheckservice‘freshness’notifications_enabled1;Servicenotificationsareenabledevent_handler_enabled1;Serviceeventhandlerisenabledflap_detection_enabled1;Flapdetectionisenabledprocess_perf_data1;Processperformancedataretain_status_information1;Retainstatusinformationacrossprogramrestartsretain_nonstatus_information1;Retainnon-statusinformationacrossprogramrestartsregister0;DONTREGISTERTHISDEFINITION-ITSNOTAREALSERVICE,JUSTATEMPLATE!}Genericforallservicesdefineservice{usegeneric

溫馨提示

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

評論

0/150

提交評論