developer-guidelines.sgml 28 KB

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