title: Writing graceful timeout for Nagios plugin
body: <p>From <a href="https://nagios-plugins.org/doc/guidelines.html#RUNTIME" rel="nofollow noreferrer">Nagios' Plugin Development Guidelines</a>:</p>
  <blockquote>
  <p>Plugins have a very limited runtime - typically 10 sec. As a result, it is very important for plugins to maintain internal code to exit if runtime exceeds a threshold.</p>
  <p>All plugins should timeout gracefully, not just networking plugins.</p>
  </blockquote>
  <p>How can I implement a timeout mechanism into my custom plugin? Basically I want my plugin to return a status code 3 - UNKNOWN instead of the default 1 - CRITICAL when the plugin times out, to reduce the number of false positives generated.</p>
  <p><strong>EDIT:</strong> My plugin is written in Bash.</p>