]> granicus.if.org Git - icinga2/blob - doc/7-addons-plugins.md
Update documentation
[icinga2] / doc / 7-addons-plugins.md
1 # <a id="addons-plugins"></a> Icinga 2 Addons and Plugins
2
3 ## <a id="addons"></a> Addons
4
5 ### <a id="addons-graphing-reporting"></a> Graphing Addons
6
7 #### <a id="addons-graphing-pnp"></a> PNP
8
9 [PNP](http://www.pnp4nagios.org) must be configured using the
10 [bulk mode with npcd and npcdmod](http://docs.pnp4nagios.org/pnp-0.6/modes#bulk_mode_with_npcd_and_npcdmod)
11 hence Icinga 2's [PerfdataWriter](3-monitoring-basics.md#performance-data) acts as npcdmod. NPCD will collect
12 the rotated performance data files.
13
14 #### <a id="addons-graphing-ingraph"></a> inGraph
15
16 [inGraph](https://www.netways.org/projects/ingraph/wiki) requires the ingraph-collector addon
17 to be configured to point at the perfdata files. Icinga 2's [PerfdataWriter](3-monitoring-basics.md#performance-data) will
18 write to the performance data spool directory.
19
20 #### <a id="addons-graphing-graphite"></a> Graphite
21
22 There are Graphite addons available for collecting the performance data files as well. But
23 natively you can use the [GraphiteWriter](3-monitoring-basics.md#graphite-carbon-cache-writer) feature.
24
25 #### <a id="addons-reporting"></a> Icinga Reporting
26
27 By enabling the DB IDO feature you can use the Icinga Reporting package.
28
29
30 ### <a id="addons-visualization"></a> Visualization
31
32 #### <a id="addons-visualization-nagvis"></a> NagVis
33
34 By using either Livestatus or DB IDO as a backend you can create your own network maps
35 based on your monitoring configuration and status data using [NagVis](http://www.nagvis.org).
36
37 ### <a id="addons-web-interfaces"></a> Web Interfaces
38
39 As well as the Icinga supported web interfaces (Classic UI 1.x, Web 1.x, Web 2) there are a
40 number of community provided web interfaces too:
41
42 * [Thruk](http://www.thruk.org) based on the [Livestatus](9-livestatus.md#setting-up-livestatus) feature
43
44
45 ## <a id="plugins"></a> Plugins
46
47 For some services you may need additional 'check plugins' which are not provided
48 by the official Monitoring Plugins project.
49
50 All existing Nagios or Icinga 1.x plugins work with Icinga 2. Here's a
51 list of popular community sites which host check plugins:
52
53 * [Icinga Exchange](https://exchange.icinga.org)
54 * [Icinga Wiki](https://wiki.icinga.org)
55
56 The recommended way of setting up these plugins is to copy them to a common directory
57 and create a new global constant, e.g. `CustomPluginDir` in your [constants.conf](4-configuring-icinga-2.md#constants-conf)
58 configuration file:
59
60     # cp check_snmp_int.pl /opt/plugins
61     # chmod +x /opt/plugins/check_snmp_int.pl
62
63     # cat /etc/icinga2/constants.conf
64     /**
65      * This file defines global constants which can be used in
66      * the other configuration files. At a minimum the
67      * PluginDir constant should be defined.
68      */
69
70     const PluginDir = "/usr/lib/nagios/plugins"
71     const CustomPluginDir = "/opt/monitoring"
72
73 Prior to using the check plugin with Icinga 2 you should ensure that it is working properly
74 by trying to run it on the console using whichever user Icinga 2 is running as:
75
76     # su - icinga -s /bin/bash
77     $ /opt/plugins/check_snmp_int.pl --help
78
79 Additional libraries may be required for some plugins. Please consult the plugin
80 documentation and/or plugin provided README for installation instructions.
81 Sometimes plugins contain hard-coded paths to other components. Instead of changing
82 the plugin it might be easier to create logical links which is (more) update-safe.
83
84 Each plugin requires a [CheckCommand](15-object-types.md#objecttype-checkcommand) object in your
85 configuration which can be used in the [Service](15-object-types.md#objecttype-service) or
86 [Host](15-object-types.md#objecttype-host) object definition.
87
88 There are the following conventions to follow when adding a new command object definition:
89
90 * Always import the `plugin-check-command` template
91 * Use [command-arguments](#) whenever possible. The `command` attribute must be an array
92 in `[ ... ]` then for shell escaping.
93 * Define a unique `prefix` for the command's specific command arguments. That way you can safely
94 set them on host/service level and you'll always know which command they control.
95 * Use command argument default values, e.g. for thresholds
96 * Use [advanced conditions](15-object-types.md#objecttype-checkcommand) like `set_if` definitions.
97
98 Example for a custom `my-snmp-int` check command:
99
100     object CheckCommand "my-snmp-int" {
101       import "plugin-check-command"
102
103       command = [ PluginDir + "/check_snmp_int.pl" ]
104
105       arguments = {
106             "-H" = "$snmp_address$"
107             "-C" = "$snmp_community$"
108                 "-p" = "$snmp_port$"
109                 "-2" = {
110           set_if = "$snmp_v2$"
111                 }
112                 "-n" = "$snmp_interface$"
113                 "-f" = {
114                         set_if = "$snmp_perf$"
115                 }
116                 "-w" = "$snmp_warn$"
117                 "-c" = "$snmp_crit$"
118       }
119
120       vars.snmp_v2 = true
121       vars.snmp_perf = true
122           vars.snmp_warn = "300,400"
123           vars.snmp_crit = "0,600"
124     }
125
126 You can find an existing `CheckCommand` definition for the `check_snmp_int.pl` plugin
127 shipped with the optional [Manubulon Plugin Check Command](16-icinga-template-library.md#snmp-manubulon-plugin-check-commands)
128 definitions already.
129
130
131 For further information on your monitoring configuration read the
132 [monitoring basics](3-monitoring-basics.md#monitoring-basics).
133 You can find plugins (additional to the ones at [Monitoring Plugins](https://www.monitoring-plugins.org)) over at
134 [Icinga Exchange](https://exchange.icinga.org)
135
136 More details on the plugins can also be found on the Icinga Wiki at https://wiki.icinga.org
137
138 ## <a id="plugin-api"></a> Plugin API
139
140 Currently Icinga 2 supports the native plugin API specification from the `Monitoring Plugins`
141 project.
142
143 The `Monitoring Plugin API` is defined in the [Monitoring Plugins Development Guidelines](https://www.monitoring-plugins.org/doc/guidelines.html).
144
145 There are no output length restrictions using Icinga 2. This is different to the
146 [Icinga 1.x plugin api definition](http://docs.icinga.org/latest/en/pluginapi.html#outputlengthrestrictions).
147
148 ## <a id="configuration-tools"></a> Configuration Tools
149
150 If you require your favourite configuration tool to export Icinga 2 configuration, please get in
151 touch with their developers. The Icinga project does not provide a configuration web interface
152 or similar.
153
154 > **Tip**
155 >
156 > Get to know the new configuration format and the advanced [apply](3-monitoring-basics.md#using-apply) rules and
157 > use [syntax highlighting](7-addons-plugins.md#configuration-syntax-highlighting) in vim/nano.
158
159 If you're looking for puppet manifests, chef cookbooks, ansible recipes, etc - we're happy
160 to integrate them upstream, so please get in touch at [https://support.icinga.org](https://support.icinga.org).
161
162 These tools are in development and require feedback and tests:
163
164 * [Ansible Roles](https://github.com/Icinga/icinga2-ansible)
165 * [Puppet Module](https://github.com/Icinga/puppet-icinga2)
166
167 ## <a id="configuration-syntax-highlighting"></a> Configuration Syntax Highlighting
168
169 Icinga 2 ships configuration examples for syntax highlighting using the `vim` and `nano` editors.
170 The RHEL, SUSE and Debian package `icinga2-common` install these files into
171 `/usr/share/*/icinga2-common/syntax`. Sources provide these files in `tools/syntax`.
172
173 ### <a id="configuration-syntax-highlighting-vim"></a> Configuration Syntax Highlighting using Vim
174
175 Create a new local vim configuration storage, if not already existing.
176 Edit `vim/ftdetect/icinga2.vim` if your paths to the Icinga 2 configuration
177 differ.
178
179     $ PREFIX=~/.vim
180     $ mkdir -p $PREFIX/{syntax,ftdetect}
181     $ cp vim/syntax/icinga2.vim $PREFIX/syntax/
182     $ cp vim/ftdetect/icinga2.vim $PREFIX/ftdetect/
183
184 Test it:
185
186     $ vim /etc/icinga2/conf.d/templates.conf
187
188 ### <a id="configuration-syntax-highlighting-nano"></a> Configuration Syntax Highlighting using Nano
189
190 Copy the `/etc/nanorc` sample file to your home directory. Create the `/etc/nano` directory
191 and copy the provided `icinga2.nanorc` into it.
192
193     $ cp /etc/nanorc ~/.nanorc
194
195     # mkdir -p /etc/nano
196     # cp icinga2.nanorc /etc/nano/
197
198 Then include the icinga2.nanorc file in your ~/.nanorc by adding the following line:
199
200     $ vim ~/.nanorc
201
202     ## Icinga 2
203     include "/etc/nano/icinga2.nanorc"
204
205 Test it:
206
207     $ nano /etc/icinga2/conf.d/templates.conf
208
209