File: intermediate.rst

package info (click to toggle)
nagiosplugin 1.3.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 948 kB
  • sloc: python: 1,857; makefile: 139; sh: 8
file content (113 lines) | stat: -rw-r--r-- 2,459 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
.. _intermediate-data-api:

Intermediate data API
=====================

The following classes allow to handle intermediate data that are used during the
plugin's execution in a structured way. Most of them are used by the
:mod:`nagiosplugin` library itself to create objects which are passed into
code written by plugin authors. Other classes (like
:class:`~nagiosplugin.metric.Metric`) are used by plugin authors to generate
intermediate data during :term:`acquisition` or :term:`evaluation` steps.

.. note::

   All classes that plugin authors typically need are imported directly into the
   :mod:`nagiosplugin` name space. For example, use ::

      import nagiosplugin
      # ...
      result = nagiosplugin.Result(nagiosplugin.Ok)

   to get a :class:`~nagiosplugin.result.Result` instance.


nagiosplugin.metric
-------------------

.. automodule:: nagiosplugin.metric
   :no-members:

.. autoclass:: Metric

   .. automethod:: __new__
   .. automethod:: __str__


nagiosplugin.state
------------------

.. automodule:: nagiosplugin.state
   :no-members:

.. autoclass:: ServiceState

   .. automethod:: __str__
   .. automethod:: __int__

.. note::

   :class:`ServiceState` is not imported into the :mod:`nagiosplugin`
   top-level name space since there is usually no need to access it directly.

.. autofunction:: nagiosplugin.state.worst

State subclasses
^^^^^^^^^^^^^^^^

The state subclasses are singletons. Plugin authors should use the class
name (without parentheses) to access the instance. For example::

   state = nagiosplugin.Critical


.. autoclass:: nagiosplugin.state.Ok
.. autoclass:: nagiosplugin.state.Warn
.. autoclass:: nagiosplugin.state.Critical
.. autoclass:: nagiosplugin.state.Unknown


nagiosplugin.performance
------------------------

.. automodule:: nagiosplugin.performance
   :no-members:

.. autoclass:: Performance

   .. automethod:: __new__
   .. automethod:: __str__


nagiosplugin.range
------------------

.. automodule:: nagiosplugin.range
   :no-members:

.. autoclass:: Range

   .. automethod:: __new__
   .. automethod:: __str__
   .. automethod:: __repr__


nagiosplugin.result
-------------------

.. automodule:: nagiosplugin.result
   :no-members:

.. autoclass:: Result

   .. automethod:: __new__
   .. automethod:: __str__

.. autoclass:: ScalarResult

.. autoclass:: Results

   .. automethod:: __iter__
   .. automethod:: __len__
   .. automethod:: __getitem__
   .. automethod:: __contains__