Nagios插件开发指南_第1页
Nagios插件开发指南_第2页
Nagios插件开发指南_第3页
Nagios插件开发指南_第4页
Nagios插件开发指南_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Nagiosplug-indevelopmentguidelinesNagiosPluginsDevelopmentTeamCopyright©2000-2009NagiosPluginsDevelopmentTeamTableofContentsPrefaceDevelopmentplatformrequirements开发平台要求PluginOutputforNagiosNagios插件输出Printonlyonelineoftext只输出一行文本Verboseoutput详细输出ScreenOutput屏幕输出PluginReturnCodesplugin返回代码Thresholdandranges阀值和区间Performancedata性能数据Translations翻译SystemCommandsandAuxiliaryFiles系统命令和附录文件Don'texecutesystemcommandswithoutspecifyingtheirfullpath不指定完整路径的情况下请不要执行系统命令Usespopen()ifexternalcommandsmustbeexecuted使用spopen()执行夕卜部命令Don'tmaketempfilesunlessabsolutelyrequired如果不是绝对需要不要创建临时文件Don'tbetrickedintofollowingsymlinks不要被下面的符号连接欺骗Validateallinput验证所有输入PerlPluginsPerl插件RuntimeTimeouts运行时超时UseDEFAULTSOCKETTIMEOUT使用DEFAULT_SOCKET_TIMEOUTAddalarmstonetworkplugins添加报警到网络插件PluginOptions插件选项OptionProcessing选项处理Pluginswithmorethanonetypeofthreshold,orwiththresholdranges有多个临界值或有临界值序列的插件Testcases测试用例Testcasesforplugins插件测试用例TestingtheClibraryfunctions测试C库函数Codingguidelines编码向导CcodingC编码Creditingsources认证源码CVScommentsCVS提交Translationsfordevelopers开发者翻译Translationsfortranslators翻译人员翻译Submissionofnewpluginsandpatches提交新插件或补丁Patches补丁Contributedplugins分发插件Newplugins新插件ListofTablesVerboseoutputlevels详细输出级别PluginReturnCodes插件返回代码Exampleranges系列实例Commandlineexamples命令行实例PrefaceThepurposeofthisguidelinesistoprovideareferencefortheplug-indevelopersandencouragethestandarizationofthedifferentkindofplug-ins:C,shell,perl,python,。2这个向导的目的是为插件开发者提供一个手册,并为不同类型插件(如:C,shell,perl,python等)提供一个标准。NagiosPlug-inDevelopmentGuidelinesCopyright(C)2000-2009(NagiosPluginsTeam)Permissionisgrantedtomakeanddistributeverbatimcopiesofthismanualprovidedthecopyrightnoticeandthispermissionnoticearepreservedonallcopies.Thepluginsthemselvesarecopyrightedbytheirrespectiveauthors.插件的版权归开发者个人。TableofContentsDevelopmentplatformrequirementsPluginOutputforNagiosPrintonlyonelineoftextVerboseoutputScreenOutputPluginReturnCodesThresholdandrangesPerformancedataTranslationsSystemCommandsandAuxiliaryFilesDon'texecutesystemcommandswithoutspecifyingtheirfullpathUsespopen()ifexternalcommandsmustbeexecutedDon'tmaketempfilesunlessabsolutelyrequiredDon'tbetrickedintofollowingsymlinksValidateallinputPerlPluginsRuntimeTimeoutsUseDEFAULTSOCKETTIMEOUTAddalarmstonetworkpluginsPluginOptionsOptionProcessingPluginswithmorethanonetypeofthreshold,orwiththresholdrangesTestcasesTestcasesforpluginsTestingtheClibraryfunctionsCodingguidelinesCcodingCreditingsourcesCVScommentsTranslationsfordevelopersTranslationsfortranslatorsSubmissionofnewpluginsandpatchesPatchesContributedpluginsNewplugins1.DevelopmentplatformrequirementsNagiospluginsaredevelopedtotheGNUstandard,soanyOSwhichissupportedbyGNUshouldruntheplugins.WhiletherequirementsforcompilingtheNagiospluginsreleaseareverybasic,developingfromtheGitrepositoryrequiresadditionalsoftwaretobeinstalled.Thesearetheminimumlevelsofsoftwarerequired:下面是最基本软件环境要求:GNUmake3.79GNUautomake1.9.2GNUautoconf2.59GNUm41.4.2GNUlibtool1.5TocompilefromGit,afteryouhaveclonedtherepository,run:从Git编译,从库中复制了代码后,运行以下命令:tools/setup./configuremakemakeinstall2.PluginOutputforNagiosYoushouldalwaysprintsomethingtoSTDOUTthattellsiftheserviceisworkingorwhyitisfailing.Trytokeeptheoutputshort-probablylessthat80characters.Rememberthatyouideallywouldliketheentireoutputtoappearinapagermessage,whichwillgetchoppedoffafteracertainlength.你总是应该输出一些东西到STDOUT来说明服务正在工作或者它为什么会失败了。试着保持输出的简短一最好少于80个字符。记住最理想的是在一个页面中输出全部的消息,否则它们达到一定的长度会被裁掉。AsNagiosdoesnotcapturestderroutput,youshouldonlyoutputtoSTDOUTandnotprinttoSTDERR.Nagios不捕获STDERR输出,你应该只输出到STDOUT而不要打印到STDERR中。Printonlyonelineoftext输出一行文本NagioswillonlygrabthefirstlineoftextfromSTDOUTwhenitnotifiescontactsaboutpotentialproblems.Ifyouprintmultiplelines,you'reoutofluck(thoughthiswillbeafeatureofNagios3).Remember,keepyouroutputshortandtothepoint.Nagios从STDOUT中只抓取第一行文本,当它通知联系人可能的问题时。如果你输出多行,你就不走运了(尽管这可能会是Nagios3的一个特征)。记住,保持你的输出简短和切题。Outputshouldbeintheformat:输出的格式如下:SERVICESTATUS:InformationtextHowever,notethatthisisnotarequirementoftheAPI,soyoucannotdependonthisbeinganaccuratereflectionofthestatusoftheservice-thestatusshouldalwaysbedeterminedbythereturncode.注意这不是API的要求,所以你不必依赖于它,来精确地反映服务的状态一状态总是由返回的代码决定的。Verboseoutput详细输出Usethe-vflagforverboseoutput.Youshouldallowmultiple-voptionsforadditionalverbosity,uptoamaximumof3.Thestandardtypeofoutputshouldbe:使用-v标记详细输出。你应该为更详细的内容允许多个-v选项。最多可以达到3个。标准的输出类型可以是:Table1.VerboseoutputlevelsVerbositylevelTypeofoutput0Singleline,minimaloutput.Summary单行,最小输出,简要1Singleline,additionalinformation(eglistprocessesthatfail)单行,附加信息(比如失败的过程处理)2Multiline,configurationdebugoutput(egpscommandused)多行,配置高度输出(如进程命令使用)3Lotsofdetailforpluginproblemdiagnosis很多的插件详细问题诊断等ScreenOutput屏幕输出Theplug-inshouldprintthediagnosticandjusttheusagepartofthehelpmessage.Awellwrittenpluginwouldthenhave--helpasawaytogettheverbosehelp.插件应该打印诊断信息,它只是有用的帮助信息的一部分。一个编写良好的插件应该有一个--help作为一个获得详细帮助的一种。Codeandoutputshouldtrytorespectthe80x25sizeofacrt(rememberwhenfixingstuffintheserverroom!)代码和输出应该试着遵守80x25尺寸的显示器PluginReturnCodes插件返回代码ThereturncodesbelowarebasedonthePOSIXspecofreturningapositivevalue.NetsaintpriortoV0.0.7supportednon-POSIXcompliantreturncodeof"-1"forunknown.NagiossupportsPOSIXreturncodesbydefault.下面的返回代码是基于POSIX细则返回一个正值。之前的V0.0.7版本支持non-POSIX兼容,返回-1代码来表示一个UNKNOWN状态。Nagios默认支持POSIX返回代码。Note:SomepluginswillonoccasionprintonSTDOUTthatanerroroccurredanderrorcodeis138or255orsomesuchnumber.Theseareusuallycausedbypluginsusingsystemcommandsandhavingnotenoughcheckstocatchunexpectedoutput.Developersshouldincludeadefaultcatch-allforsystemcommandoutputthatreturnsanUNKNOWNreturncode.注意:一些插件偶尔在向STDOUT输出,当一个错误发生时,错误代码是138或255或者是一个些其它数字。这些通常是由于使用系统命令并且没有足够的检查来捕获异常输出。开发着应该为系统命令输出包含一个默认的捕获全部来返回一个UNKNOWN代码。Table2.PluginReturnCodes插件返回代码NumericValueServiceStatusStatusDescription0OKThepluginwasabletochecktheserviceanditappearedtobefunctioningproperly插件可以检查服务并且可以正确呈现功能1WarningThepluginwasabletochecktheservice,butitappearedtobeabovesome"warning"thresholdordidnotappeartobeworkingproperly插件可以检查服务,但是它呈现出一些临界警告信息,或者不能正确工作2CriticalTheplugindetectedthateithertheservicewasnotrunningoritwasabovesome"critical"threshold插件检测到服务可能没有运行或者它达到某些临界值3UnknownInvalidcommandlineargumentsweresuppliedtothepluginorlow-levelfailuresinternaltotheplugin(suchasunableto

NumericValueServiceStatusStatusDescriptionfork,oropenatcpsocket)thatpreventitfromperformingthespecifiedoperation.Higher-levelerrors(suchasnameresolutionerrors,sockettimeouts,etc)areoutsideofthecontrolofpluginsandshouldgenerallyNOTbereportedasUNKNOWNstates.向插件提供了不详的命令行参数或者插件低级内部失败(如不能创建子进程或打开tcp连接)阻止了它处理指定的操作。高级错误(比如一些误差,socket超时等)是插件控制之外的并且通常不能被报告的即为UNKOWN状态。Notes:1.2.3.start<endstartand":"isnotrequiredifstart=0如果1.2.3.start<endstartand":"isnotrequiredifstart=0如果start=0则start和":"不需要ifrangeisofformat"start:"andendisnotspecified,assumeendisinfinity如果区间的格式为"start:"且没有指定end,则假定end为无限大4.5.6.tospecifynegativeinfinity,use"〜"指定负无限大使用〜alertisraisedifmetricisoutsidestartandendrange(inclusiveofendpoints)如果度量标准超出start或end区间(包括)报警发生ifrangestartswith"@",thenalertifinsidethisrange(inclusiveofendpoints)如果区间以@开始,则当度量标准在区间内(包含)时报警发生Note:Notallpluginsarecodedtoexpectrangesinthisformatyet.Therewillbesomeworkinprovidingmultiplemetrics.注意:使用这种格式,并非所有的插件都被编码为预期的区间。它需要一些工作来提供多个度量标准。Table3.Exampleranges区间实例RangedefinitionGenerateanalertifx...10<0or>10,(outsidetherangeof(0..10})超出0-10区间10:<10,(outside(10..°°))超出10-8区间~:10>10,(outsidetherangeof(-°..10))超出-°-10区间10:20<10or>20,(outsidetherangeof(10..20})超出10-20区间@10:20N10andW20,(insidetherangeof(10..20))在10-20区间10<0or>10,(outsidetherangeof(0..10})超出0-10区间CommandlineMeaningcheck_stuff-w10-c20Criticalif"stuff"isover20,elsewarnifover10(willcriticalif"stuff"islessthan0)如果stuff高于20则critical,否则如果超过10则warning(如果stuff低于0则critical)Table4.Commandlineexamples命令行实例beCommandlineMeaningcheck_stuff-w~:10-c~:20Sameasabove.Negative"stuff"isOK同上,负stuff为正常值check_stuff-w10:-c20Criticalif"stuff"isover20,elsewarnif"stuff"isbel10(willbecriticalif"stuff"islessthan0)如果stuff高于20则critical,否则如果超过10则warning(如果stuff低于0贝Ucritical)check_stuff-c1:Criticalif"stuff"islessthan1如果stuff超过1则criticalcheck_stuff-w~:0-c10Criticalif"stuff"isabove10;Warnif"stuff"isabovezero如果stuff高于10则critical,高于0则warning,负数为正常check_stuff-c5:6Theonlynoncriticalrangeis5:6只有5-6区间为非criticalcheck_stuff-c10:20Criticalif"stuff"is10to20如果stuff为10-20则critical(似乎文档有误!)owPerformancedata性能数据PerformancedataisdefinedbyNagiosas"everythingaftertheIofthepluginoutput"-pleaserefertoNagiosdocumentationforinformationoncapturingthisdatatologfiles.However,itistheresponsibilityofthepluginwritertoensuretheperformancedataisina"Nagiosplugins"format.Thisistheexpectedformat:性能数据被Nagios定义为“|之后的输出部分”一请参考Nagios文档信息来捕获这些数据到日志文件。不管怎样,插件编写人员的职责是,确保性能数据满足“Nagios插件”格式。下面是预期的格式:'label'=value[UOM];[warn];[crit];[min];[max]Notes:spaceseparatedlistoflabel/valuepairs空格分隔label/value对labelcancontainanycharacters其中label可以包含任意字符thesinglequotesforthelabelareoptional.Requiredifspaces,=or'areinthelabel单引号可选。包含空格,等号或单引号时单引号为必须。labellengthisarbitrary,butideallythefirst19charactersareunique(duetoalimitationinRRD).BeawareofalimitationintheamountofdatathatNRPEreturnstoNagios其中label的长度为任意的,但是比较理想的前19个字符应该是不重复的(由于RRD的限制)。须知NRPE返回给Nagios的数据的限制。tospecifyaquotecharacter,usetwosinglequotes要指定一个单引号,使用两个单引号warn,crit,minormaxmaybenull(forexample,ifthethresholdisnotdefinedorminandmaxdonotapply).Trailingunfilledsemicolonscanbedropped其中warn,crit,min,max也可为null(比如临界值没有被定义或者最小最大值没有被应用)。后面空的分号可以省略minandmaxarenotrequiredifUOM=%其中min和max是不需要的,如果UOM为%value,minandmaxinclass[-0-9.].MustallbethesameUOM??看不懂warnandcritareintherangeformat(seeSection2.5).MustbethesameUOMUOM(unitofmeasurement)isoneof:nounitspecified-assumeanumber(intorfloat)ofthings(eg,users,processes,loadaverages)s -seconds(alsous,ms)%-percentageB-bytes(alsoKB,MB,TB)c-acontinouscounter(suchasbytestransmittedonaninterface)ItisuptothirdpartyprogramstoconverttheNagiospluginsperformancedataintographs.TranslationsIfpossible,usetranslationtoolsforalloutputtorespecttheuser'slanguagesettings.SeeSection8.4forguidelinesforthecoreplugins.SystemCommandsandAuxiliaryFilesDon'texecutesystemcommandswithoutspecifyingtheirfullpath在没有指定完整路径的情况下不执行系统命令Don'tuseexec(),popen(),etc.toexecuteexternalcommandswithoutexplicityusingthefullpathoftheexternalprogram,在没有明确指定一个外部程序的完整路径的情况下,不要使用exec(),popen()等函数来执行外部命令Doingotherwisemakesthepluginvulnerabletohijackingbyatrojanhorseearlierinthesearchpath.Seethemainplugindistributionforexamplesonhowthisisdone.否则会使得插件很脆弱而很容易被木马劫持。查看主插件分发实例,这些实例说明了这些是怎么发生的。Usespopen()ifexternalcommandsmustbeexecuted使用spopen(),如果外部命令必须执行Ifyouhavetoexecuteexternalcommandsfromwithinyourpluginandyou'rewritingitinC,usethespopen()functionthatKarlDeBisschophaswritten,如果你必须在你的插件内部执行外部命令,并且你是在用C写插件,使用KarlDeBisschop编写的spopen()函数Thecodeforspopen()andspclose()isincludedwiththecoreplugindistribution,函数spopen()和spclose()的代码已经在核心插件发布中被包含。Don'tmaketempfilesunlessabsolutelyrequired如果不是绝对需要不要使用临时文件Iftempfilesareneeded,makesurethatthepluginwillfailcleanlyifthefilecan'tbewritten(e.g.,toofewfilehandles,outofdiskspace,incorrectpermissions,etc.)anddeletethetempfilewhenprocessingiscomplete.如果需要使用临时文件,确保插件可以干净地失败,在文件不能被写入的情况下(如:过少的文件处理?,磁盘空间不足,不正确的权限等),并且保证处理完成后删除临时文件。Don'tbetrickedintofollowingsymlinks不要被符号链接欺骗Ifyourpluginopensanyfiles,takestepstoensurethatyouarenotfollowingasymlinktoanotherlocationonthesystem,如果你的插件打开了一些文件,请采取措施确保你没有被一个符号链接重定向到系统的其它地址。Validateallinput验证所有输入useroutinesinutils.corutils.pmandwritemoreasneeded使用utils.c或utils.pm中的函数,或自己写如果需要PerlPluginsPerlpluginsarecodedalittlemoredefensivelythanotherpluginsbecauseofembeddedPerl.Whenconfiguredassuch,embeddedPerlNagios(ePN)requiresstricteruseofthesomeofPerl'sfeatures.ThissectionoutlinessomeofthestepsneededtouseePNeffectively.DonotuseBEGINandENDblockssincetheywillbecalledonlyonce(whenNagiosstartsandshutsdown)withEmbeddedPerl(ePN).Inparticular,donotuseBEGINblockstoinitializevariables.Touseutils.pm,youneedtoprovideafullpathtothemoduleinorderforittowork.e.g.uselib"/usr/local/nagios/libexec";useutilsqw(...);Perlscriptsshouldbecalledwith"-w"AllPerlpluginsmustcompilecleanlyunder"usestrict"-i.e.atleastexplicitlypackagenamesasin"$main::x"orpredeclareeveryvariable.Explicitlyinitializeeachvariableinuse.Otherwisewithcachingenabled,thepluginwillnotberecompiledeachtime,andthereforePerlwillnotreinitializeallthevariables.Alloldvariablevalueswillstillbeineffect.Donotuse>DATA<handles(thesesimplydonotcompileunderePN).Donotuseglobalvariablesinnamedsubroutines.Thisisbadpractiseanyway,butwithePNthecompilerwillreportanerror"<global_var>willnotstayshared..”.Valuesusedbysubroutinesshouldbepassedintheargumentlist.Ifwritingtoafile(perhapsrecordingperformancedata)explicitlyclosecloseit.Thepluginnevercallsexit;thatiscaughtbyp1.pl,sooutputstreamsareneverclosed.AsinSection5allpluginsneedtomonitortheirruntime,speciallyiftheyareusingnetworkresources.UseofthealarmisrecommendednotingthatsomePerlmodules(egLWP)managetimers,sothatanalarmsetbyapluginusingsuchamoduleisoverwrittenbythemodule.(workaroundsarecunning(TM)orusingthemoduletimer)Pluginsmayimportadefaulttimeout($TIMEOUT)fromutils.pm.Perlpluginsshouldimport%ERRORSfromutils.pmandthen"exit$ERRORS{'OK'}"ratherthan"exit0"RuntimeTimeoutsPluginshaveaverylimitedruntime-typically10sec.Asaresult,itisveryimportantforpluginstomaintaininternalcodetoexitifruntimeexceedsathreshold.插件有一个特有的限制的运行时间一代表性地是10秒。因此,保持当内部代码运行时间超出一个阀值时退出非常重要。Allpluginsshouldtimeoutgracefully,notjustnetworkingplugins.Forinstance,dfmaylockifyouhaveautomounteddrivesandyournetworkfails-butonfirstglance,who'dthinkdfcouldlockuplikethat.Plus,itshouldjustbemoreerrorresistanttobeabletotimeoutratherthanconsumeresources.所有插件应该优雅地超时,并不仅仅是联网插件。比如,df命令会锁定如果你自动挂载驱动并且你的网络失败了一但是第一次扫视,你最好认为df会那样锁定。另外,UseDEFAULT_SOCKET_TIMEOUTAllnetworkpluginsshoulduseDEFAULT_SOCKET_TIMEOUTtotimeoutAddalarmstonetworkpluginsIfyouwriteapluginwhichcommunicateswithanothernetworkedhost,youshouldmakesuretosetanalarm()inyourcodethatpreventsthepluginfromhangingduetoabnormalsocketclosures,etc.Nagiostakesstepstoprotectitselfagainstunrulypluginsthattimeout,butanypluginsyoucreateshouldbewellbehavedontheirown,如果你写了一个插件,这个插件会同其它网络主机交互,你应该确保设置一个alarm()在你的代码中,来防止插件因为不正常的socket关闭而挂起等。Nagios采取措施来保护它自己来对抗不守规矩的插件,那就是超时。但是你创建的所有插件应该是运自身行良好的。PluginOptionsAwellwrittenpluginshouldhave--helpasawaytogetverbosehelp.Codeandoutputshouldtrytorespectthe80x25sizeofacrt(rememberwhenfixingstuffintheserverroom!)OptionProcessingForpluginswritteninC,werecommendtheCstandardgetoptlibraryforshortoptions.Getopt_longisalwaysavailable.ForpluginswritteninPerl,werecommendGetopt::Longmodule.Positionalargumentsarestronglydiscouraged.Thereareafewreservedoptionsthatshouldnotbeusedforotherpurposes:-Vversion(--version)-hhelp(--help)-ttimeout(--timeout)-wwarningthreshold(--warning)-ccriticalthreshold(--critical)-Hhostname(--hostname)-vverbose(--verbose)Inadditiontothereservedoptionsabove,someotherstandardoptionsare:-CSNMPcommunity(--community)-aauthenticationpassword(--authentication)-lloginname(--logname)-pportorpassword(--portor--passwd/--password)monitorsoperational-uurlorusername(--urlor--username)Lookatcheck_pgsqlandcheck_procstoseehowIcurrentlythinkthiscanwork.Standardoptionsare:Theoption-Vor--versionshouldbepresentinallplugins.ForCpluginsitshouldresultinacalltoprint_revision,afunctioninutils.cwhichtakestwocharacterarguments,thecommandnameandthepluginrevision.The-?option,oranyotherunparsablesetofoptions,shouldprintoutashortusagestatement.Characterwidthshouldbe80andlessandnomorethat23linesshouldbeprinted(itshoulddisplaycleanlyonadumbterminalinaserverroom).Theoption-hor--helpshouldbepresentinallplugins.InCplugins,itshouldresultinacalltoprint_help(orequivalent).Thefunctionprint_helpshouldcallprint_revision,thenprint_usage,thenshouldprovidedetailedhelp.Helptextshouldfitonan80-characterwidthdisplay,butmayrunasmanylinesasneeded.Theoption-vor--verboseshouldbepresentinallplugins.Theusershouldbeallowedtospecify-vmultipletimestoincreasetheverbositylevel,asdescribedinTable1.Pluginswithmorethanonetypeofthreshold,orwiththresholdrangesOldstylewastodothingslike-ctforcriticaltimeand-cvforcriticalvalue.ThatgoesoutthewindowwithPOSIXgetopt.Theallowablealternativesare:1.longoptionslike-critical-time(or-ctand-cv,Isuppose).1.repeatedoptionslike'check_load-w10-w6-w4-c16-c10-c10'forbrevity,theabovecanbeexpressedas'check_load-w10,6,4-c16,10,10'rangesareexpressedwithcolonsasin'check_procs-Chttpd-w1:20-c1:30'whichwillwarnabove20instances,andcriticalat0andabove30listsareexpressedwithcommas,soJacob'scheck_nmapusesconstructslike'-p1000,1010,1050:1060,2000'Ifpossiblewhenwritinglists,usetokenstomakethelisteasytorememberandnon-orderdependent-socheck_diskuses'-c10000,10%'sothatitisclearwhichistheprecentageandwhichistheKBvalues(notethatduetomyownlackofforesight,thatusedtobe'-c10000:10%'butsuchconstructsshouldallbechangedforconsistency,thoughprovidingreversecompatibilityisfairlyeasy).Asalways,commentsarewelcome-makingthisconsistentwithoutahostoflongoptionswasquiteahassle,andIwouldsuspectthatthereareflawsinthisstrategy.TestcasesTestsarethebestwayofknowingifthepluginsworkasexpected.Pleasecreateandupdatetestcaseswherepossible.Torunatest,fromthetopleveldirectory,run"maketest".Thiswillrunallthecurrenttestsandreportanoverallsuccessrate.SeetheNagiosPluginsTinderboxserverforthedailytestresults.TestcasesforpluginsTheseuseperl'sTest::More.Todoaonetimetest,run"cdplugins&&perlt/check_disk.t".Therewillsomtimesbefailuresseeninthisoutputwhichareknownfailuresthatneedtobefixed.Aslongasthereturncodeis0,itwillbereportedas"testpass".(Ifyouhaveafixsothatthespecifictestpasses,thatwillbegratefullyreceived!)Ifyouwantasummarytest,run:"cdplugins&&provet/check_disk.t".Thisrunsthetestinasummaryformat.ForagoodandamusingtutorialonusingTest::More,seethislinkTestingtheClibraryfunctionsWeusethelibtaplibrary,whichgivesperl'sTAP(TestAnythingProtocol)output.ThisisusedbytheFreeBSDteamfortheirregressiontesting.Toruntestsusingthelibtaplibrary,downloadthelatesttarballandextract.Thereisaproblemwithtap-1.01wherepthreadsupportdoesn'tappeartoworkproperlyonnon-FreeBSDsystems.Installwith'CPPFLAGS="-UHAVE_LIBPTHREAD"./configure&&make&&makecheck&&makeinstall'.WhenyourunNagiosPlugins'configure,itwilllookforthetaplibraryandwillautomaticallysetupthetests.Run"maketest"torunallthetests.CodingguidelinesSeeGNUCodingstandardsforgeneralguidelines.CcodingVariablesshouldbedeclaredatthebeginningofcodeblocksandnotinlinebecauseofportabilitywitholdercompilers.Youshoulduse/**/forcommentsandnot//assomecompilersdonothandlethelatterform.Youshouldalsoavoidusingthetype"bool"anditsvalues"true"and"false".Insteadusethe"int"typeandtheplugins'own"TRUE"/"FALSE"valuestokeepthecodeuniformly.CreditingsourcesIfyouhavecopiedaroutinefromanothersource,makesurethelicencefromyoursourceallowsthis.AddacommentreferencingtheACKNOWLEDGEMENTSfile,whereyoucanputmoredetailaboutthesource.Forcontributedcode,donotaddanynamedcreditsinthesourcecode-contributorsshouldbeaddedintotheTHANKS.infileinstead.CVScommentsIfthechangeisduetoacontribution,pleasequotethecontributor'snameand,ifapplicable,addtheSourceForgeTrackernumber.Don'tforgettoupdatetheTHANKS.infile.Ifyouhaveachangethatisusefulfornotinginthenextrelease,pleaseupdatetheNEWSfile.AllcommitcommentswillbewrittentoaChangeLogatreleasetime.TranslationsfordevelopersTomakethejobeasierfortranslators,pleasefollowtheseguidelines:Beforecreatingnewstrings,checkthepo/nagios-plugins.potfiletoseeifasimilarstringalreadyexistsForhelptexts,breakintoindividualoptionssothatthesecanbereusedbetweenpluginsTrytoavoidlinefeedsunlessyouareworkingonablockoftextShorthelpisnottranslatedLonghelphasoptionsinEnglishlanguage,buttexttranslated"Copyright"keptinEnglishCopyrightholdernameskeptinoriginaltextDebuggingoutputdoesnotneedtobetranslatedTranslationsfortranslatorsTocreateanuptodatelistoftranslatablestrings,run:tools/gen_locale.sh9.Submissionofnewpluginsandpatches提交新插件和补丁PatchesIfyouhaveabugpatch,pleasesupplyaunifiedorcontextdiffagainsttheversionyouareusing.Fornewfeatures,pleasesupplyadiffagainsttheGit"master"branch,如果你有一个补丁,请提供一个与你当前使用的版本一致的,或者提供与你当前使用的版本的差异。PatchesshouldbesubmittedviaSourceForge'strackersystemforNagiosplugpatchesandbeannouncedtothenagiosplug-develmailinglist.Submissionofapatchimpliesthatthesubmmitteracknowledgesthattheyaretheauthorofthecode(orhavepermissionfromtheauthortoreleasethecode)andagreethatthecodecanbereleasedundertheGPL.ThecopyrightforthechangeswillthenreverttotheNagiosPluginDevelopmentTeam-thisisrequiredsothatanycopyrightinfringementscanbeinvestigatedquicklywithoutcontactingahugelistofcopyrightholders.Creditwillalwaysbegivenforanypatchesthr

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论