×

微信扫一扫,快捷登录!

Nagios plug-in development guidelines(2)

标签: 暂无标签
本帖最后由 monicazhang 于 2015-10-30 21:23 编辑

20151030淡然
续上




2. Plugin Output for Nagios
You should always print something to STDOUT that tells if the service is working or why it is failing. Try to keep the output short - probably less that 80 characters. Remember that you ideally would like the entire output to appear in a pager message, which will get chopped off after a certain length. 你总是应该输出一些东西到 STDOUT 来说明服务正在工作或者它为什么会失败了。试着保持输出的简短—最好少于80个字符。记住最理想的是在一个页面中输出全部的消息,否则它们达到一定的长度会被裁掉。                             nagios安装
As Nagios does not capture stderr output, you should only output to STDOUT and not print to STDERR. Nagios不捕获STDERR输出,你应该只输出到STDOUT而不要打印到STDERR中。


2.1. Print only one line of text输出一行文本
Nagios will only grab the first line of text from STDOUT when it notifies contacts about potential problems. If you print multiple lines, you're out of luck (though this will be a feature of Nagios 3). Remember, keep your output short and to the point. Nagios从STDOUT中只抓取第一行文本,当它通知联系人可能的问题时。如果你输出多行,你就不走运了(尽管这可能会是Nagios3的一个特征)。记住,保持你的输出简短和切题。
Output should be in the format: 输出的格式如下:
SERVICE STATUS: Information text
However, note that this is not a requirement of the API, so you cannot depend on this being an accurate reflection of the status of the service - the status should always be determined by the return code. 注意这不是API的要求,所以你不必依赖于它,来精确地反映服务的状态—状态总是由返回的代码决定的。


2.2. Verbose output详细输出
Use the -v flag for verbose output. You should allow multiple -v options for additional verbosity, up to a maximum of 3. The standard type of output should be: 使用 –v 标记详细输出。你应该为更详细的内容允许多个-v选项。最多可以达到3个。标准的输出类型可以是:
Table 1. Verbose output levels
[td]
Verbosity level
Type of output
0
Single line, minimal output. Summary 单行,最小输出,简要
1
       Single line, additional information (eg list processes that fail) 单行,附加信息(比如失败的过程处理)
2
Multi line, configuration debug output (eg ps command used) 多行,配置高度输出(如进程命令使用)
3
Lots of detail for plugin problem diagnosis 很多的插件详细问题诊断等                           开源监控软件


2.3. Screen Output屏幕输出
The plug-in should print the diagnostic and just the usage part of the help message. A well written plugin would then have --help as a way to get the verbose help.  插件应该打印诊断信息,它只是有用的帮助信息的一部分。一个编写良好的插件应该有一个 -- help 作为一个获得详细帮助的一种。
Code and output should try to respect the 80x25 size of a crt (remember when fixing stuff in the server room!) 代码和输出应该试着遵守 80x25 尺寸的显示器


2.4. Plugin Return Codes插件返回代码
The return codes below are based on the POSIX spec of returning a positive value. Netsaint prior to v0.0.7 supported non-POSIX compliant return code of "-1" for unknown. Nagios supports POSIX return codes by default. 下面的返回代码是基于POSIX细则返回一个正值。之前的v0.0.7版本支持non-POSIX兼容,返回-1代码来表示一个UNKNOWN状态。Nagios默认支持POSIX返回代码。
Note: Some plugins will on occasion print on STDOUT that an error occurred and error code is 138 or 255 or some such number. These are usually caused by plugins using system commands and having not enough checks to catch unexpected output. Developers should include a default catch-all for system command output that returns an UNKNOWN return code. 注意:一些插件偶尔在向STDOUT输出,当一个错误发生时,错误代码是138或255或者是一个些其它数字。这些通常是由于使用系统命令并且没有足够的检查来捕获异常输出。开发着应该为系统命令输出包含一个默认的捕获全部来返回一个UNKNOWN代码。                                           nagios配置

Table 2. Plugin Return Codes 插件返回代码
[td]
Numeric Value
Service Status
Status Description
0
OK
The plugin was able to check the service and it appeared to be functioning properly 插件可以检查服务并且可以正确呈现功能
1
Warning
The plugin was able to check the service, but it appeared to be above some "warning" threshold or did not appear to be working properly 插件可以检查服务,但是它呈现出一些临界警告信息,或者不能正确工作
2
Critical
The plugin detected that either the service was not running or it was above some "critical" threshold 插件检测到服务可能没有运行或者它达到某些临界值                     监控软件
3
Unknown
Invalid command line arguments were supplied to the plugin or low-level failures internal to the plugin (such as unable to fork, or open a tcp socket) that prevent it from performing the specified operation. Higher-level errors (such as name resolution errors, socket timeouts, etc) are outside of the control of plugins and should generally NOT be reported as UNKNOWN states. 向插件提供了不详的命令行参数或者插件低级内部失败(如不能创建子进程或打开tcp连接)阻止了它处理指定的操作。高级错误(比如一些误差,socket超时等)是插件控制之外的并且通常不能被报告的即为UNKOWN状态。


2.5. Threshold and ranges临界和区间
A range is defined as a start and end point (inclusive) on a numeric scale (possibly negative or positive infinity). 区间被定义来作为一个开始和结束点(包含)数值范围(可能是负数或下无穷大)                                        nagios实施
A threshold is a range with an alert level (either warning or critical). Use the set_thresholds(thresholds *, char *, char *) function to set the thresholds. 一个阀值是一个报警级别的区间(warning或critical)。使用函数set_thresholds(thresholds *, char *, char *)来设置阀值。
The theory is that the plugin will do some sort of check which returns back a numerical value, or metric, which is then compared to the warning and critical thresholds. Use the get_status(double, thresholds *) function to compare the value against the thresholds. 理论上,插件会做一些简短的检查,这些检查会返回一个数据值,或者度量标准,这些值会同warning和critical阀值进行比较。使用函数get_status(double, thresholds *)来与阀值进行比较。
This is the generalised format for ranges: 下面是区间的通常格式:                      nagios培训
[@]start:end




待续:http://www.ITILxf.com/thread-53034-1-1.html
本帖关键字:Nagios




上一篇:Nagios plug-in development guidelines(1)
下一篇:Nagios plug-in development guidelines(3)
monicazhang

写了 2297 篇文章,拥有财富 12859,被 21 人关注

您需要登录后才可以回帖 登录 | 立即注册
B Color Link Quote Code Smilies

成为第一个吐槽的人

返回顶部