Plugin Debugging

Debugging plugins can sometimes be complicated since there are so many classes, which are tied together in an implicit way. I have collected some frequent questions about debugging.

An uncaught exception makes the plugin return UNKNOWN. Where is the cause?

When your plugin raises an exception, you may get very little output. Example:

USERS UNKNOWN: RuntimeError: error

Set the verbose parameter of main() to some value greater than zero and you will get the full traceback:

$ -v
USERS UNKNOWN: RuntimeError: error
Traceback (most recent call last):
  File "nagiosplugin/", line 38, in wrapper
    return func(*args, **kwds)
  File "nagiosplugin/examples/", line 104, in main
    check.main(args.verbose, args.timeout)
  File "nagiosplugin/", line 110, in main
    runtime.execute(self, verbose, timeout)
  File "nagiosplugin/", line 118, in execute
    with_timeout(self.timeout,, check)
  File "nagiosplugin/platform/", line 19, in with_timeout
    func(*args, **kwargs)
  File "nagiosplugin/", line 107, in run
  File "nagiosplugin/", line 95, in __call__
  File "nagiosplugin/", line 73, in _evaluate_resource
    metrics = resource.probe()
  File "nagiosplugin/examples/", line 57, in probe
    self.users = self.list_users()
  File "nagiosplugin/examples/", line 34, in list_users
    raise RuntimeError('error')
RuntimeError: error

A Check constructor dies with “cannot add type <…>”

When you see the following exception raised from Check() (or Check.add()):

UNKNOWN: TypeError: ("cannot add type <class '__main__.Users'> to check", <__main__.Users object at 0x7f0c64f73f90>)

chances are high that you are trying to add an object that is not an instance from Resource, Context, Summary, or Results or its subclasses. A common error is to base a resource class on object instead of Resource.

I’m trying to use pdb but I get a timeout after 10s

When using an interactive debugger like pdb on plugins, you may experience that your debugging session is aborted with a timeout after 10 seconds. Just set the timeout parameter in main() to 0 to avoid this.