developer-guidelines.sgml 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V4.1//EN" >
  2. <book>
  3. <title>Nagios Plug-in Developer Guidelines</title>
  4. <bookinfo>
  5. <authorgroup>
  6. <author>
  7. <affiliation>
  8. <orgname>Nagios Plugins Development Team</orgname>
  9. </affiliation>
  10. </author>
  11. </authorgroup>
  12. <pubdate>2005</pubdate>
  13. <title>Nagios plug-in development guidelines</title>
  14. <revhistory>
  15. <revision>
  16. <revnumber>$Revision$</revnumber>
  17. <date>$Date$</date>
  18. </revision>
  19. </revhistory>
  20. <copyright>
  21. <year>2000 - 2005</year>
  22. <holder>Nagios Plugins Development Team</holder>
  23. </copyright>
  24. </bookinfo>
  25. <preface id="preface"><title>Preface</title>
  26. <para>The purpose of this guidelines is to provide a reference for
  27. the plug-in developers and encourage the standarization of the
  28. different kind of plug-ins: C, shell, perl, python, etc.</para>
  29. <para>Nagios Plug-in Development Guidelines Copyright (C) 2000-2005
  30. (Nagios Plugins Team)</para>
  31. <para>Permission is granted to make and distribute verbatim
  32. copies of this manual provided the copyright notice and this
  33. permission notice are preserved on all copies.</para>
  34. <para>The plugins themselves are copyrighted by their respective
  35. authors.</para>
  36. </preface>
  37. <article>
  38. <section id="DevRequirements"><title>Development platform requirements</title>
  39. <para>
  40. Nagios plugins are developed to the GNU standard, so any OS which is supported by GNU
  41. should run the plugins. While the requirements for compiling the Nagios plugins release
  42. is very small, to develop from CVS needs additional software to be installed. These are the
  43. minimum levels of software required:
  44. <literallayout>
  45. gnu make 3.79
  46. automake 1.8
  47. autoconf 2.58
  48. gettext 0.11.5
  49. gnu libtool 1.5.6
  50. </literallayout>
  51. To compile from CVS, after you have checked out the code, run:
  52. <literallayout>
  53. tools/setup
  54. ./configure
  55. make
  56. make install
  57. </literallayout>
  58. </para>
  59. </section>
  60. <section id="PlugOutput"><title>Plugin Output for Nagios</title>
  61. <para>You should always print something to STDOUT that tells if the
  62. service is working or why it is failing. Try to keep the output short -
  63. probably less that 80 characters. Remember that you ideally would like
  64. the entire output to appear in a pager message, which will get chopped
  65. off after a certain length.</para>
  66. <section><title>Print only one line of text</title>
  67. <para>Nagios will only grab the first line of text from STDOUT
  68. when it notifies contacts about potential problems. If you print
  69. multiple lines, you're out of luck. Remember, keep it short and
  70. to the point.</para>
  71. <para>Output should be in the format:</para>
  72. <literallayout>
  73. SERVICE STATUS: Information text
  74. </literallayout>
  75. <para>However, note that this is not a requirement of the API, so you cannot depend on this
  76. being an accurate reflection of the status of the service - the status should always
  77. be determined by the return code.</para>
  78. </section>
  79. <section><title>Verbose output</title>
  80. <para>Use the -v flag for verbose output. You should allow multiple
  81. -v options for additional verbosity, up to a maximum of 3. The standard
  82. type of output should be:</para>
  83. <table id="verboselevels"><title>Verbose output levels</title>
  84. <tgroup cols="2">
  85. <thead>
  86. <row>
  87. <entry><para>Verbosity level</para></entry>
  88. <entry><para>Type of output</para></entry>
  89. </row>
  90. </thead>
  91. <tbody>
  92. <row>
  93. <entry align="center"><para>0</para></entry>
  94. <entry><para>Single line, minimal output. Summary</para></entry>
  95. </row>
  96. <row>
  97. <entry align="center"><para>1</para></entry>
  98. <entry><para>Single line, additional information (eg list processes that fail)</para></entry>
  99. </row>
  100. <row>
  101. <entry align="center"><para>2</para></entry>
  102. <entry><para>Multi line, configuration debug output (eg ps command used)</para></entry>
  103. </row>
  104. <row>
  105. <entry align="center"><para>3</para></entry>
  106. <entry><para>Lots of detail for plugin problem diagnosis</para></entry>
  107. </row>
  108. </tbody>
  109. </tgroup>
  110. </table>
  111. </section>
  112. <section><title>Screen Output</title>
  113. <para>The plug-in should print the diagnostic and just the
  114. synopsis part of the help message. A well written plugin would
  115. then have --help as a way to get the verbose help.</para>
  116. <para>Code and output should try to respect the 80x25 size of a
  117. crt (remember when fixing stuff in the server room!)</para>
  118. </section>
  119. <section><title>Plugin Return Codes</title>
  120. <para>The return codes below are based on the POSIX spec of returning
  121. a positive value. Netsaint prior to v0.0.7 supported non-POSIX
  122. compliant return code of "-1" for unknown. Nagios supports POSIX return
  123. codes by default.</para>
  124. <para>Note: Some plugins will on occasion print on STDOUT that an error
  125. occurred and error code is 138 or 255 or some such number. These
  126. are usually caused by plugins using system commands and having not
  127. enough checks to catch unexpected output. Developers should include a
  128. default catch-all for system command output that returns an UNKNOWN
  129. return code.</para>
  130. <table id="ReturnCodes"><title>Plugin Return Codes</title>
  131. <tgroup cols="3">
  132. <thead>
  133. <row>
  134. <entry><para>Numeric Value</para></entry>
  135. <entry><para>Service Status</para></entry>
  136. <entry><para>Status Description</para></entry>
  137. </row>
  138. </thead>
  139. <tbody>
  140. <row>
  141. <entry align="center"><para>0</para></entry>
  142. <entry valign="middle"><para>OK</para></entry>
  143. <entry><para>The plugin was able to check the service and it
  144. appeared to be functioning properly</para></entry>
  145. </row>
  146. <row>
  147. <entry align="center"><para>1</para></entry>
  148. <entry valign="middle"><para>Warning</para></entry>
  149. <entry><para>The plugin was able to check the service, but it
  150. appeared to be above some "warning" threshold or did not appear
  151. to be working properly</para></entry>
  152. </row>
  153. <row>
  154. <entry align="center"><para>2</para></entry>
  155. <entry valign="middle"><para>Critical</para></entry>
  156. <entry><para>The plugin detected that either the service was not
  157. running or it was above some "critical" threshold</para></entry>
  158. </row>
  159. <row>
  160. <entry align="center"><para>3</para></entry>
  161. <entry valign="middle"><para>Unknown</para></entry>
  162. <entry><para>Invalid command line arguments were supplied to the
  163. plugin or low-level failures internal to the plugin (such as unable to fork,
  164. or open a tcp socket) that prevent it from performing the specified
  165. operation. Higher-level errors (such as name resolution errors,
  166. socket timeouts, etc) are outside of the control of plugins and should
  167. generally NOT be reported as UNKNOWN states.
  168. </para></entry>
  169. </row>
  170. </tbody>
  171. </tgroup>
  172. </table>
  173. </section>
  174. <section id="thresholdformat"><title>Threshold and ranges</title>
  175. <para>A range is defined as a start and end point (inclusive) on a numeric scale (possibly
  176. negative or positive infinity).
  177. </para>
  178. <para>A threshold is a range with an alert level (either warning or critical). Use the
  179. set_thresholds(thresholds *, char *, char *) function to set the thresholds.
  180. </para>
  181. <para>The theory is that the plugin will do some sort of check which returns
  182. back a numerical value, or metric, which is then compared to the warning and
  183. critical thresholds. Use the get_status(double, thresholds *) function to
  184. compare the value against the thresholds.</para>
  185. <para>This is the generalised format for ranges:</para>
  186. <literallayout>
  187. [@]start:end
  188. </literallayout>
  189. <para>Notes:</para>
  190. <orderedlist>
  191. <listitem><para>start &le; end</para>
  192. </listitem>
  193. <listitem><para>start and ":" is not required if start=0</para>
  194. </listitem>
  195. <listitem><para>if range is of format "start:" and end is not specified,
  196. assume end is infinity</para>
  197. </listitem>
  198. <listitem><para>to specify negative infinity, use "~"</para>
  199. </listitem>
  200. <listitem><para>alert is raised if metric is outside start and end range
  201. (inclusive of endpoints)</para>
  202. </listitem>
  203. <listitem><para>if range starts with "@", then alert if inside this range
  204. (inclusive of endpoints)</para>
  205. </listitem>
  206. </orderedlist>
  207. <para>Note: Not all plugins are coded to expect ranges in this format yet.
  208. There will be some work in providing multiple metrics.</para>
  209. </section>
  210. <section><title>Performance data</title>
  211. <para>Performance data is defined by Nagios as "everything after the | of the plugin output" -
  212. please refer to Nagios documentation for information on capturing this data to logfiles.
  213. However, it is the responsibility of the plugin writer to ensure the
  214. performance data is in a "Nagios plugins" format.
  215. This is the expected format:</para>
  216. <literallayout>
  217. 'label'=value[UOM];[warn];[crit];[min];[max]
  218. </literallayout>
  219. <para>Notes:</para>
  220. <orderedlist>
  221. <listitem><para>space separated list of label/value pairs</para>
  222. </listitem>
  223. <listitem><para>label can contain any characters</para>
  224. </listitem>
  225. <listitem><para>the single quotes for the label are optional. Required if
  226. spaces, = or ' are in the label</para>
  227. </listitem>
  228. <listitem><para>label length is arbitrary, but ideally the first 19 characters
  229. are unique (due to a limitation in RRD). Be aware of a limitation in the
  230. amount of data that NRPE returns to Nagios</para>
  231. </listitem>
  232. <listitem><para>to specify a quote character, use two single quotes</para>
  233. </listitem>
  234. <listitem><para>warn, crit, min or max may be null (for example, if the threshold is
  235. not defined or min and max do not apply). Trailing unfilled semicolons can be
  236. dropped</para>
  237. </listitem>
  238. <listitem><para>min and max are not required if UOM=%</para>
  239. </listitem>
  240. <listitem><para>value, min and max in class [-0-9.]. Must all be the
  241. same UOM</para>
  242. </listitem>
  243. <listitem><para>warn and crit are in the range format (see
  244. <xref linkend="thresholdformat">). Must be the same UOM</para>
  245. </listitem>
  246. <listitem><para>UOM (unit of measurement) is one of:</para>
  247. <orderedlist>
  248. <listitem><para>no unit specified - assume a number (int or float)
  249. of things (eg, users, processes, load averages)</para>
  250. </listitem>
  251. <listitem><para>s - seconds (also us, ms)</para></listitem>
  252. <listitem><para>% - percentage</para></listitem>
  253. <listitem><para>B - bytes (also KB, MB, TB)</para></listitem>
  254. <listitem><para>c - a continous counter (such as bytes
  255. transmitted on an interface)</para></listitem>
  256. </orderedlist>
  257. </listitem>
  258. </orderedlist>
  259. <para>It is up to third party programs to convert the Nagios plugins
  260. performance data into graphs.</para>
  261. </section>
  262. <section><title>Translations</title>
  263. <para>If possible, use translation tools for all output to respect the user's language
  264. settings. See <xref linkend="translationsdevelopers"> for guidelines
  265. for the core plugins.
  266. </para>
  267. </section>
  268. </section>
  269. <section id="SysCmdAuxFiles"><title>System Commands and Auxiliary Files</title>
  270. <section><title>Don't execute system commands without specifying their
  271. full path</title>
  272. <para>Don't use exec(), popen(), etc. to execute external
  273. commands without explicity using the full path of the external
  274. program.</para>
  275. <para>Doing otherwise makes the plugin vulnerable to hijacking
  276. by a trojan horse earlier in the search path. See the main
  277. plugin distribution for examples on how this is done.</para>
  278. </section>
  279. <section><title>Use spopen() if external commands must be executed</title>
  280. <para>If you have to execute external commands from within your
  281. plugin and you're writing it in C, use the spopen() function
  282. that Karl DeBisschop has written.</para>
  283. <para>The code for spopen() and spclose() is included with the
  284. core plugin distribution.</para>
  285. </section>
  286. <section><title>Don't make temp files unless absolutely required</title>
  287. <para>If temp files are needed, make sure that the plugin will
  288. fail cleanly if the file can't be written (e.g., too few file
  289. handles, out of disk space, incorrect permissions, etc.) and
  290. delete the temp file when processing is complete.</para>
  291. </section>
  292. <section><title>Don't be tricked into following symlinks</title>
  293. <para>If your plugin opens any files, take steps to ensure that
  294. you are not following a symlink to another location on the
  295. system.</para>
  296. </section>
  297. <section><title>Validate all input</title>
  298. <para>use routines in utils.c or utils.pm and write more as needed</para>
  299. </section>
  300. </section>
  301. <section id="PerlPlugin"><title>Perl Plugins</title>
  302. <para>Perl plugins are coded a little more defensively than other
  303. plugins because of embedded Perl. When configured as such, embedded
  304. Perl Nagios (ePN) requires stricter use of the some of Perl's features.
  305. This section outlines some of the steps needed to use ePN
  306. effectively.</para>
  307. <orderedlist>
  308. <listitem><para> Do not use BEGIN and END blocks since they will be called
  309. only once (when Nagios starts and shuts down) with Embedded Perl (ePN). In
  310. particular, do not use BEGIN blocks to initialize variables.</para>
  311. </listitem>
  312. <listitem><para>To use utils.pm, you need to provide a full path to the
  313. module in order for it to work.</para>
  314. <literallayout>
  315. e.g.
  316. use lib "/usr/local/nagios/libexec";
  317. use utils qw(...);
  318. </literallayout>
  319. </listitem>
  320. <listitem><para>Perl scripts should be called with "-w"</para>
  321. </listitem>
  322. <listitem><para>All Perl plugins must compile cleanly under "use strict" - i.e. at
  323. least explicitly package names as in "$main::x" or predeclare every
  324. variable. </para>
  325. <para>Explicitly initialize each variable in use. Otherwise with
  326. caching enabled, the plugin will not be recompiled each time, and
  327. therefore Perl will not reinitialize all the variables. All old
  328. variable values will still be in effect.</para>
  329. </listitem>
  330. <listitem><para>Do not use &gt;DATA&lt; handles (these simply do not compile under ePN).</para>
  331. </listitem>
  332. <listitem><para>Do not use global variables in named subroutines. This is bad practise anyway, but with ePN the
  333. compiler will report an error "&lt;global_var&gt; will not stay shared ..". Values used by
  334. subroutines should be passed in the argument list.</para>
  335. </listitem>
  336. <listitem><para>If writing to a file (perhaps recording
  337. performance data) explicitly close close it. The plugin never
  338. calls <emphasis role="strong">exit</emphasis>; that is caught by
  339. p1.pl, so output streams are never closed.</para>
  340. </listitem>
  341. <listitem><para>As in <xref linkend="runtime"> all plugins need
  342. to monitor their runtime, specially if they are using network
  343. resources. Use of the <emphasis>alarm</emphasis> is recommended
  344. noting that some Perl modules (eg LWP) manage timers, so that an alarm
  345. set by a plugin using such a module is overwritten by the module.
  346. (workarounds are cunning (TM) or using the module timer)
  347. Plugins may import a default time out ($TIMEOUT) from utils.pm.
  348. </para>
  349. </listitem>
  350. <listitem><para>Perl plugins should import %ERRORS from utils.pm
  351. and then "exit $ERRORS{'OK'}" rather than "exit 0"
  352. </para>
  353. </listitem>
  354. </orderedlist>
  355. </section>
  356. <section id="runtime"><title>Runtime Timeouts</title>
  357. <para>Plugins have a very limited runtime - typically 10 sec.
  358. As a result, it is very important for plugins to maintain internal
  359. code to exit if runtime exceeds a threshold. </para>
  360. <para>All plugins should timeout gracefully, not just networking
  361. plugins. For instance, df may lock if you have automounted
  362. drives and your network fails - but on first glance, who'd think
  363. df could lock up like that. Plus, it should just be more error
  364. resistant to be able to time out rather than consume
  365. resources.</para>
  366. <section><title>Use DEFAULT_SOCKET_TIMEOUT</title>
  367. <para>All network plugins should use DEFAULT_SOCKET_TIMEOUT to timeout</para>
  368. </section>
  369. <section><title>Add alarms to network plugins</title>
  370. <para>If you write a plugin which communicates with another
  371. networked host, you should make sure to set an alarm() in your
  372. code that prevents the plugin from hanging due to abnormal
  373. socket closures, etc. Nagios takes steps to protect itself
  374. against unruly plugins that timeout, but any plugins you create
  375. should be well behaved on their own.</para>
  376. </section>
  377. </section>
  378. <section id="PlugOptions"><title>Plugin Options</title>
  379. <para>A well written plugin should have --help as a way to get
  380. verbose help. Code and output should try to respect the 80x25 size of a
  381. crt (remember when fixing stuff in the server room!)</para>
  382. <section><title>Option Processing</title>
  383. <para>For plugins written in C, we recommend the C standard
  384. getopt library for short options. Getopt_long is always available.
  385. </para>
  386. <para>For plugins written in Perl, we recommend Getopt::Long module.</para>
  387. <para>Positional arguments are strongly discouraged.</para>
  388. <para>There are a few reserved options that should not be used
  389. for other purposes:</para>
  390. <literallayout>
  391. -V version (--version)
  392. -h help (--help)
  393. -t timeout (--timeout)
  394. -w warning threshold (--warning)
  395. -c critical threshold (--critical)
  396. -H hostname (--hostname)
  397. -v verbose (--verbose)
  398. </literallayout>
  399. <para>In addition to the reserved options above, some other standard options are:</para>
  400. <literallayout>
  401. -C SNMP community (--community)
  402. -a authentication password (--authentication)
  403. -l login name (--logname)
  404. -p port or password (--port or --passwd/--password)monitors operational
  405. -u url or username (--url or --username)
  406. </literallayout>
  407. <para>Look at check_pgsql and check_procs to see how I currently
  408. think this can work. Standard options are:</para>
  409. <para>The option -V or --version should be present in all
  410. plugins. For C plugins it should result in a call to print_revision, a
  411. function in utils.c which takes two character arguments, the
  412. command name and the plugin revision.</para>
  413. <para>The -? option, or any other unparsable set of options,
  414. should print out a short usage statement. Character width should
  415. be 80 and less and no more that 23 lines should be printed (it
  416. should display cleanly on a dumb terminal in a server
  417. room).</para>
  418. <para>The option -h or --help should be present in all plugins.
  419. In C plugins, it should result in a call to print_help (or
  420. equivalent). The function print_help should call print_revision,
  421. then print_usage, then should provide detailed
  422. help. Help text should fit on an 80-character width display, but
  423. may run as many lines as needed.</para>
  424. <para>The option -v or --verbose should be present in all plugins.
  425. The user should be allowed to specify -v multiple times to increase
  426. the verbosity level, as described in <xref linkend="verboselevels">.</para>
  427. </section>
  428. <section>
  429. <title>Plugins with more than one type of threshold, or with
  430. threshold ranges</title>
  431. <para>Old style was to do things like -ct for critical time and
  432. -cv for critical value. That goes out the window with POSIX
  433. getopt. The allowable alternatives are:</para>
  434. <orderedlist>
  435. <listitem>
  436. <para>long options like -critical-time (or -ct and -cv, I
  437. suppose).</para>
  438. </listitem>
  439. <listitem>
  440. <para>repeated options like `check_load -w 10 -w 6 -w 4 -c
  441. 16 -c 10 -c 10`</para>
  442. </listitem>
  443. <listitem>
  444. <para>for brevity, the above can be expressed as `check_load
  445. -w 10,6,4 -c 16,10,10`</para>
  446. </listitem>
  447. <listitem>
  448. <para>ranges are expressed with colons as in `check_procs -C
  449. httpd -w 1:20 -c 1:30` which will warn above 20 instances,
  450. and critical at 0 and above 30</para>
  451. </listitem>
  452. <listitem>
  453. <para>lists are expressed with commas, so Jacob's check_nmap
  454. uses constructs like '-p 1000,1010,1050:1060,2000'</para>
  455. </listitem>
  456. <listitem>
  457. <para>If possible when writing lists, use tokens to make the
  458. list easy to remember and non-order dependent - so
  459. check_disk uses '-c 10000,10%' so that it is clear which is
  460. the precentage and which is the KB values (note that due to
  461. my own lack of foresight, that used to be '-c 10000:10%' but
  462. such constructs should all be changed for consistency,
  463. though providing reverse compatibility is fairly
  464. easy).</para>
  465. </listitem>
  466. </orderedlist>
  467. <para>As always, comments are welcome - making this consistent
  468. without a host of long options was quite a hassle, and I would
  469. suspect that there are flaws in this strategy.
  470. </para>
  471. </section>
  472. </section>
  473. <section id="Testcases"><title>Test cases</title>
  474. <para>
  475. Tests are the best way of knowing if the plugins work as expected. Please
  476. create and update test cases where possible.
  477. </para>
  478. <para>
  479. To run a test, from the top level directory, run "make test". This will run
  480. all the current tests and report an overall success rate.
  481. </para>
  482. <para>
  483. See the <ulink url="http://tinderbox.altinity.org">Nagios Plugins Tinderbox server</ulink>
  484. for the daily test results.
  485. </para>
  486. <section><title>Test cases for plugins</title>
  487. <para>These use perl's Test::More. To do a one time test, run "cd plugins && perl t/check_disk.t".
  488. </para>
  489. <para>There will somtimes be failures seen in this output which are known failures that
  490. need to be fixed. As long as the return code is 0, it will be reported as "test pass".
  491. (If you have a fix so that the specific test passes, that will be gratefully received!)
  492. </para>
  493. <para>
  494. If you want a summary test, run: "cd plugins && prove t/check_disk.t".
  495. This runs the test in a summary format.
  496. </para>
  497. <para>
  498. For a good and amusing tutorial on using Test::More, see this
  499. <ulink url="http://search.cpan.org/~mschwern/Test-Simple-0.62/lib/Test/Tutorial.pod">
  500. link</ulink>
  501. </para>
  502. </section>
  503. <section><title>Testing the C library functions</title>
  504. <para>
  505. We use <ulink url="http://jc.ngo.org.uk/trac-bin/trac.cgi/wiki/LibTap">the libtap library</ulink>, which gives
  506. perl's TAP
  507. (Test Anything Protocol) output. This is used by the FreeBSD team for their regression testing.
  508. </para>
  509. <para>
  510. To run tests using the libtap library, download the latest tar ball and extract.
  511. There is a problem with tap-1.01 where
  512. <ulink url="http://jc.ngo.org.uk/trac-bin/trac.cgi/ticket/25">pthread support doesn't appear to work</ulink>
  513. properly on non-FreeBSD systems. Install with 'CPPFLAGS="-UHAVE_LIBPTHREAD" ./configure && make && make check && make install'.
  514. </para>
  515. <para>
  516. When you run Nagios Plugins' configure, it will look for the tap library and will automatically
  517. setup the tests. Run "make test" to run all the tests.
  518. </para>
  519. </section>
  520. </section>
  521. <section id="CodingGuidelines"><title>Coding guidelines</title>
  522. <para>See <ulink url="http://www.gnu.org/prep/standards_toc.html">GNU
  523. Coding standards</ulink> for general guidelines.</para>
  524. <section><title>Comments</title>
  525. <para>You should use /* */ for comments and not // as some compilers
  526. do not handle the latter form.</para>
  527. <para>If you have copied a routine from another source, make sure the licence
  528. from your source allows this. Add a comment referencing the ACKNOWLEDGEMENTS
  529. file, where you can put more detail about the source.</para>
  530. <para>For contributed code, do not add any named credits in the source code
  531. - contributors should be added into the THANKS.in file instead.
  532. </para>
  533. </section>
  534. <section><title>CVS comments</title>
  535. <para>When adding CVS comments at commit time, you can use the following prefixes:
  536. <variablelist>
  537. <varlistentry><term>- comment</term>
  538. <listitem>
  539. <para>for a comment that can be removed from the Changelog</para>
  540. </listitem>
  541. </varlistentry>
  542. <varlistentry><term>* comment</term>
  543. <listitem>
  544. <para>for an important amendment to be included into a features list</para>
  545. </listitem>
  546. </varlistentry>
  547. </variablelist>
  548. </para>
  549. <para>If the change is due to a contribution, please quote the contributor's name
  550. and, if applicable, add the SourceForge Tracker number. Don't forget to
  551. update the THANKS.in file.</para>
  552. </section>
  553. <section id="translationsdevelopers"><title>Translations for developers</title>
  554. <para>To make the job easier for translators, please follow these guidelines:</para>
  555. <orderedlist>
  556. <listitem><para>
  557. Before creating new strings, check the po/nagios-plugins.pot file to
  558. see if a similar string
  559. already exists
  560. </para></listitem>
  561. <listitem><para>
  562. For help texts, break into individual options so that these can be reused
  563. between plugins
  564. </para></listitem>
  565. <listitem><para>Try to avoid linefeeds unless you are working on a block of text</para></listitem>
  566. <listitem><para>Short help is not translated</para></listitem>
  567. <listitem><para>Long help has options in English language, but text translated</para></listitem>
  568. <listitem><para>"Copyright" kept in English</para></listitem>
  569. <listitem><para>Copyright holder names kept in original text</para></listitem>
  570. <listitem><para>Debugging output does not need to be translated</para></listitem>
  571. </orderedlist>
  572. </section>
  573. <section><title>Translations for translators</title>
  574. <para>To create an up to date list of translatable strings, run: tools/gen_locale.sh</para>
  575. </section>
  576. </section>
  577. <section id="SubmittingChanges"><title>Submission of new plugins and patches</title>
  578. <section id="Patches"><title>Patches</title>
  579. <para>If you have a bug patch, please supply a unified or context diff against the
  580. version you are using. For new features, please supply a diff against
  581. the CVS HEAD version.</para>
  582. <para>Patches should be submitted via
  583. <ulink url="http://sourceforge.net/tracker/?group_id=29880&amp;atid=397599">SourceForge's
  584. tracker system for Nagiosplug patches</ulink>
  585. and be announced to the nagiosplug-devel mailing list.</para>
  586. <para>Submission of a patch implies that the submmitter acknowledges that they
  587. are the author of the code (or have permission from the author to release the code)
  588. and agree that the code can be released under the GPL. The copyright for the changes will
  589. then revert to the Nagios Plugin Development Team - this is required so that any copyright
  590. infringements can be investigated quickly without contacting a huge list of copyright holders.
  591. Credit will always be given for any patches through a THANKS file in the distribution.</para>
  592. </section>
  593. <section id="Newplugins"><title>New plugins</title>
  594. <para>If you would like others to use your plugins, please add it to
  595. the official 3rd party plugin repository,
  596. <ulink url="http://www.nagiosexchange.org">NagiosExchange</ulink>.
  597. </para>
  598. <para>We are not accepting requests for inclusion of plugins into
  599. our distribution at the moment, but when we do, these are the minimum
  600. requirements:
  601. </para>
  602. <orderedlist>
  603. <listitem>
  604. <para>Include copyright and license information in all files</para>
  605. </listitem>
  606. <listitem>
  607. <para>The standard command options are supported (--help, --version,
  608. --timeout, --warning, --critical)</para>
  609. </listitem>
  610. <listitem>
  611. <para>It is determined to be not redundant (for instance, we would not
  612. add a new version of check_disk just because someone had provide
  613. a plugin that had perf checking - we would incorporate the features
  614. into an exisiting plugin)</para>
  615. </listitem>
  616. <listitem>
  617. <para>One of the developers has had the time to audit the code and declare
  618. it ready for core</para>
  619. </listitem>
  620. <listitem>
  621. <para>It should also follow code format guidelines, and use functions from
  622. utils (perl or c or sh) rather than using its own</para>
  623. </listitem>
  624. <listitem>
  625. <para>Includes patches to configure.in if required (via the EXTRAS list if
  626. it will only work on some platforms)</para>
  627. </listitem>
  628. <listitem>
  629. <para>If possible, please submit a test harness. Documentation on sample
  630. tests coming soon</para>
  631. </listitem>
  632. </orderedlist>
  633. </section>
  634. </section>
  635. </article>
  636. </book>