




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Nagios安装配置[1]-Linux 配置 -坐沙发上等戈多安装问题 (我找到的中文版之中最好的一个 ,我照着手册装了一下,不成功,转而按照此文,最终成,限于篇幅原因就不在贴上来了,我自己的安装步骤基本上和这篇相同)/index.php?play=search&make=view&id=282&key=nagios我的安装步骤(操作系统 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)具体的可参考我上文给出的联接[]#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的安装.及监按指令的布署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、安装监测的模块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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 租地合同附属协议
- 山东省济宁市任城区2024-2025学年七年级上学期期末生物学试题(含答案)
- 湖南省郴州市2024-2025学年高一上学期期末考试生物学试题(含答案)
- 离婚协议书条款补充协议
- 初中数学竞赛指导策略训练课教案
- 水务工程设计与施工合同管理协议
- 非谓语动词的用法与解析:高中英语语法
- (一模)2025届安徽省“江南十校”高三联考地理试卷(含官方答案)
- 电气物资知识培训课件
- 水疗产品知识培训课件
- 科学通史学习通超星期末考试答案章节答案2024年
- 手提花篮培训课件
- 高职旅游专业《旅游心理学》说课稿
- 三至六年级重点句型(素材)湘少版小学英语
- 二年级数学上册100道口算题大全 (每日一套共26套)
- 围手术期过敏反应课件
- 《水电工程边坡设计规范》(NB/T10512-2021)
- 立案委托书法律文书撰写指南
- HGT 6332-2024《液体脲醛缓释肥料》
- 综述的写作方法和技巧
- 区块链与人工智能的融合
评论
0/150
提交评论