Nagios plug-in development guidelines(3)
20151030淡然续上Notes:1.start≤end2.startand":"isnotrequiredifstart=0如果start=0则start和":"不需要3.ifrangeisofformat"start:"andendisnotspecified,assumeendisinfinity如果区间的格式为"start:"且没有指定end,则假定end为无限大4.tospecifynegativeinfinity,use"~"指定负无限大使用~nagios安装5.alertisraisedifmetricisoutsidestartandendrange(inclusiveofendpoints)如果度量标准超出start或end区间(包括)报警发生6.ifrangestartswith"@",thenalertifinsidethisrange(inclusiveofendpoints)如果区间以@开始,则当度量标准在区间内(包含)时报警发生Note:Notallpluginsarecodedtoexpectrangesinthisformatyet.Therewillbesomeworkinprovidingmultiplemetrics.注意:使用这种格式,并非所有的插件都被编码为预期的区间。它需要一些工作来提供多个度量标准。
Table3.Exampleranges区间实例
RangedefinitionGenerateanalertifx...
10<0or>10,(outsidetherangeof{0..10})超出0-10区间开源监控软件
10:<10,(outside{10..∞})超出10-∞区间
~:10>10,(outsidetherangeof{-∞..10})超出-∞-10区间
10:20<10or>20,(outsidetherangeof{10..20})超出10-20区间
@10:20≥10and≤20,(insidetherangeof{10..20})在10-20区间
10<0or>10,(outsidetherangeof{0..10})超出0-10区间
Table4.Commandlineexamples命令行实例
CommandlineMeaning
check_stuff-w10-c20Criticalif"stuff"isover20,elsewarnifover10(willbecriticalif"stuff"islessthan0)如果stuff高于20则critical,否则如果超过10则warning(如果stuff低于0则critical)
check_stuff-w~:10-c~:20Sameasabove.Negative"stuff"isOK同上,负stuff为正常值
check_stuff-w10:-c20Criticalif"stuff"isover20,elsewarnif"stuff"isbelow10(willbecriticalif"stuff"islessthan0)如果stuff高于20则critical,否则如果超过10则warning(如果stuff低于0则critical)
check_stuff-c1:Criticalif"stuff"islessthan1如果stuff超过1则critical
check_stuff-w~:0-c10Criticalif"stuff"isabove10;Warnif"stuff"isabovezero如果stuff高于10则critical,高于0则warning,负数为正常nagios配置
check_stuff-c5:6Theonlynoncriticalrangeis5:6只有5-6区间为非critical
check_stuff-c10:20Criticalif"stuff"is10to20如果stuff为10-20则critical(似乎文档有误!)
2.6.Performancedata性能数据PerformancedataisdefinedbyNagiosas"everythingafterthe|ofthepluginoutput"-pleaserefertoNagiosdocumentationforinformationoncapturingthisdatatologfiles.However,itistheresponsibilityofthepluginwritertoensuretheperformancedataisina"Nagiosplugins"format.Thisistheexpectedformat:性能数据被Nagios定义为“|之后的输出部分”—请参考Nagios文档信息来捕获这些数据到日志文件。不管怎样,插件编写人员的职责是,确保性能数据满足“Nagios插件”格式。下面是预期的格式:'label'=value;;;;Notes:1.spaceseparatedlistoflabel/valuepairs空格分隔label/value对2.labelcancontainanycharacters其中label可以包含任意字符3.thesinglequotesforthelabelareoptional.Requiredifspaces,=or'areinthelabel单引号可选。包含空格,等号或单引号时单引号为必须。4.labellengthisarbitrary,butideallythefirst19charactersareunique(duetoalimitationinRRD).BeawareofalimitationintheamountofdatathatNRPEreturnstoNagios其中label的长度为任意的,但是比较理想的前19个字符应该是不重复的(由于RRD的限制)。须知NRPE返回给Nagios的数据的限制。5.tospecifyaquotecharacter,usetwosinglequotes要指定一个单引号,使用两个单引号6.warn,crit,minormaxmaybenull(forexample,ifthethresholdisnotdefinedorminandmaxdonotapply).Trailingunfilledsemicolonscanbedropped其中warn,crit,min,max也可为null(比如临界值没有被定义或者最小最大值没有被应用)。后面空的分号可以省略7.minandmaxarenotrequiredifUOM=%其中min和max是不需要的,如果UOM为%8.value,minandmaxinclass[-0-9.].MustallbethesameUOM??看不懂监控软件9.warnandcritareintherangeformat(seeSection2.5).MustbethesameUOM10.UOM(unitofmeasurement)isoneof:a.nounitspecified-assumeanumber(intorfloat)ofthings(eg,users,processes,loadaverages)b.s-seconds(alsous,ms)c.%-percentaged.B-bytes(alsoKB,MB,TB)e.c-acontinouscounter(suchasbytestransmittedonaninterface)ItisuptothirdpartyprogramstoconverttheNagiospluginsperformancedataintographs.
2.7.TranslationsIfpossible,usetranslationtoolsforalloutputtorespecttheuser'slanguagesettings.SeeSection8.4forguidelinesforthecoreplugins.
3.SystemCommandsandAuxiliaryFiles3.1.Don'texecutesystemcommandswithoutspecifyingtheirfullpath在没有指定完整路径的情况下不执行系统命令Don'tuseexec(),popen(),etc.toexecuteexternalcommandswithoutexplicityusingthefullpathoftheexternalprogram.在没有明确指定一个外部程序的完整路径的情况下,不要使用exec(),popen()等函数来执行外部命令nagios培训Doingotherwisemakesthepluginvulnerabletohijackingbyatrojanhorseearlierinthesearchpath.Seethemainplugindistributionforexamplesonhowthisisdone.否则会使得插件很脆弱而很容易被木马劫持。查看主插件分发实例,这些实例说明了这些是怎么发生的。3.2.Usespopen()ifexternalcommandsmustbeexecuted使用spopen(),如果外部命令必须执行Ifyouhavetoexecuteexternalcommandsfromwithinyourpluginandyou'rewritingitinC,usethespopen()functionthatKarlDeBisschophaswritten.如果你必须在你的插件内部执行外部命令,并且你是在用C写插件,使用KarlDeBisschop编写的spopen()函数nagios培训Thecodeforspopen()andspclose()isincludedwiththecoreplugindistribution.函数spopen()和spclose()的代码已经在核心插件发布中被包含。3.3.Don'tmaketempfilesunlessabsolutelyrequired如果不是绝对需要不要使用临时文件
待续:http://www.ITILxf.com/thread-53035-1-1.html
本帖关键字:Nagios
页:
[1]