]> granicus.if.org Git - icinga2/blob - doc/11-cli-commands.md
Merge pull request #7353 from Icinga/bugfix/influxdbwriter-skip-tags-7341
[icinga2] / doc / 11-cli-commands.md
1 # Icinga 2 CLI Commands <a id="cli-commands"></a>
2
3 Icinga 2 comes with a number of CLI commands which support bash autocompletion.
4
5 These CLI commands will allow you to use certain functionality
6 provided by and around Icinga 2.
7
8 Each CLI command provides its own help and usage information, so please
9 make sure to always run them with the `--help` parameter.
10
11 Run `icinga2` without any arguments to get a list of all available global
12 options.
13
14 ```
15 # icinga2
16 icinga2 - The Icinga 2 network monitoring daemon (version: v2.11.0)
17
18 Usage:
19   icinga2 <command> [<arguments>]
20
21 Supported commands:
22   * api setup (setup for API)
23   * ca list (lists all certificate signing requests)
24   * ca restore (restores a removed certificate request)
25   * ca remove (removes an outstanding certificate request)  
26   * ca sign (signs an outstanding certificate request)
27   * console (Icinga debug console)
28   * daemon (starts Icinga 2)
29   * feature disable (disables specified feature)
30   * feature enable (enables specified feature)
31   * feature list (lists all available features)
32   * node setup (set up node)
33   * node wizard (wizard for node setup)
34   * object list (lists all objects)
35   * pki new-ca (sets up a new CA)
36   * pki new-cert (creates a new CSR)
37   * pki request (requests a certificate)
38   * pki save-cert (saves another Icinga 2 instance's certificate)
39   * pki sign-csr (signs a CSR)
40   * pki ticket (generates a ticket)
41   * variable get (gets a variable)
42   * variable list (lists all variables)
43
44 Global options:
45   -h [ --help ]             show this help message
46   -V [ --version ]          show version information
47   --color                   use VT100 color codes even when stdout is not a
48                             terminal
49   -D [ --define ] arg       define a constant
50   -a [ --app ] arg          application library name (default: icinga)
51   -l [ --library ] arg      load a library
52   -I [ --include ] arg      add include search directory
53   -x [ --log-level ] arg    specify the log level for the console log.
54                             The valid value is either debug, notice,
55                             information (default), warning, or critical
56   -X [ --script-debugger ]  whether to enable the script debugger
57
58 Report bugs at <https://github.com/Icinga/icinga2>
59 Icinga home page: <https://icinga.com/>
60 ```
61
62
63 ## Icinga 2 CLI Bash Autocompletion <a id="cli-commands-autocompletion"></a>
64
65 Bash Auto-Completion (pressing `<TAB>`) is provided only for the corresponding context.
66
67 While `--config` suggests and auto-completes files and directories on disk,
68 `feature enable` only suggests disabled features.
69
70 RPM and Debian packages install the bash completion files into
71 `/etc/bash_completion.d/icinga2`.
72
73 You need to install the `bash-completion` package if not already installed.
74
75 RHEL/CentOS/Fedora:
76
77 ```
78 # yum install bash-completion
79 ```
80
81 SUSE:
82
83 ```
84 # zypper install bash-completion
85 ```
86
87 Debian/Ubuntu:
88
89 ```
90 # apt-get install bash-completion
91 ```
92
93 Ensure that the `bash-completion.d` directory is added to your shell
94 environment. You can manually source the icinga2 bash-completion file
95 into your current session and test it:
96
97 ```
98 # source /etc/bash-completion.d/icinga2
99 ```
100
101
102 ## Icinga 2 CLI Global Options <a id="cli-commands-global-options"></a>
103
104 ### Application Type
105
106 By default the `icinga2` binary loads the `icinga` library. A different application type
107 can be specified with the `--app` command-line option.
108 Note: This is not needed by the average Icinga user, only developers.
109
110 ### Libraries
111
112 Instead of loading libraries using the [`library` config directive](17-language-reference.md#library)
113 you can also use the `--library` command-line option.
114 Note: This is not needed by the average Icinga user, only developers.
115
116 ### Constants
117
118 [Global constants](17-language-reference.md#constants) can be set using the `--define` command-line option.
119
120 ### Config Include Path <a id="config-include-path"></a>
121
122 When including files you can specify that the include search path should be
123 checked. You can do this by putting your configuration file name in angle
124 brackets like this:
125
126 ```
127 include <test.conf>
128 ```
129
130 This causes Icinga 2 to search its include path for the configuration file
131 `test.conf`. By default the installation path for the [Icinga Template Library](10-icinga-template-library.md#icinga-template-library)
132 is the only search directory.
133
134 Using the `--include` command-line option additional search directories can be
135 added.
136
137 ## CLI command: Api <a id="cli-command-api"></a>
138
139 Provides helper functions to enable and setup the
140 [Icinga 2 API](12-icinga2-api.md#icinga2-api-setup).
141
142 ### CLI command: Api Setup <a id="cli-command-api-setup "></a>
143
144 ```
145 # icinga2 api setup --help
146 icinga2 - The Icinga 2 network monitoring daemon (version: v2.11.0)
147
148 Usage:
149   icinga2 api setup [<arguments>]
150
151 Setup for Icinga 2 API.
152
153 Global options:
154   -h [ --help ]             show this help message
155   -V [ --version ]          show version information
156   --color                   use VT100 color codes even when stdout is not a
157                             terminal
158   -D [ --define ] arg       define a constant
159   -I [ --include ] arg      add include search directory
160   -x [ --log-level ] arg    specify the log level for the console log.
161                             The valid value is either debug, notice,
162                             information (default), warning, or critical
163   -X [ --script-debugger ]  whether to enable the script debugger
164
165 Command options:
166   --cn arg                  The certificate's common name
167
168 Report bugs at <https://github.com/Icinga/icinga2>
169 Get support: <https://icinga.com/support/>
170 Documentation: <https://icinga.com/docs/>
171 Icinga home page: <https://icinga.com/>
172 ```
173
174 ## CLI command: Ca <a id="cli-command-ca"></a>
175
176 List and manage incoming certificate signing requests. More details
177 can be found in the [signing methods](06-distributed-monitoring.md#distributed-monitoring-setup-sign-certificates-master)
178 chapter. This CLI command is available since v2.8.
179
180 ```
181 # icinga2 ca --help
182 icinga2 - The Icinga 2 network monitoring daemon (version: v2.11.0)
183
184 Usage:
185   icinga2 <command> [<arguments>]
186
187 Supported commands:
188   * ca list (lists all certificate signing requests)
189   * ca sign (signs an outstanding certificate request)
190   * ca restore (restores a removed certificate request)
191   * ca remove (removes an outstanding certificate request)
192
193 Global options:
194   -h [ --help ]             show this help message
195   -V [ --version ]          show version information
196   --color                   use VT100 color codes even when stdout is not a
197                             terminal
198   -D [ --define ] arg       define a constant
199   -a [ --app ] arg          application library name (default: icinga)
200   -l [ --library ] arg      load a library
201   -I [ --include ] arg      add include search directory
202   -x [ --log-level ] arg    specify the log level for the console log.
203                             The valid value is either debug, notice,
204                             information (default), warning, or critical
205   -X [ --script-debugger ]  whether to enable the script debugger
206
207 Report bugs at <https://github.com/Icinga/icinga2>
208 Icinga home page: <https://icinga.com/>
209 ```
210
211
212 ### CLI command: Ca List <a id="cli-command-ca-list"></a>
213
214 ```
215 icinga2 ca list --help
216 icinga2 - The Icinga 2 network monitoring daemon (version: v2.11.0)
217
218 Usage:
219   icinga2 ca list [<arguments>]
220
221 Lists pending certificate signing requests.
222
223 Global options:
224   -h [ --help ]             show this help message
225   -V [ --version ]          show version information
226   --color                   use VT100 color codes even when stdout is not a
227                             terminal
228   -D [ --define ] arg       define a constant
229   -I [ --include ] arg      add include search directory
230   -x [ --log-level ] arg    specify the log level for the console log.
231                             The valid value is either debug, notice,
232                             information (default), warning, or critical
233   -X [ --script-debugger ]  whether to enable the script debugger
234
235 Command options:
236   --all                     List all certificate signing requests, including
237                             signed. Note: Old requests are automatically
238                             cleaned by Icinga after 1 week.
239   --removed                 List all removed CSRs (for use with 'ca restore')
240   --json                    encode output as JSON
241
242 Report bugs at <https://github.com/Icinga/icinga2>
243 Get support: <https://icinga.com/support/>
244 Documentation: <https://icinga.com/docs/>
245 Icinga home page: <https://icinga.com/>
246 ```
247
248 ## CLI command: Console <a id="cli-command-console"></a>
249
250 The CLI command `console` can be used to debug and evaluate Icinga 2 config expressions,
251 e.g. to test [functions](17-language-reference.md#functions) in your local sandbox.
252
253 ```
254 $ icinga2 console
255 Icinga 2 (version: v2.11.0)
256 <1> => function test(name) {
257 <1> ..   log("Hello " + name)
258 <1> .. }
259 null
260 <2> => test("World")
261 information/config: Hello World
262 null
263 <3> =>
264 ```
265
266 Further usage examples can be found in the [library reference](18-library-reference.md#library-reference) chapter.
267
268 ```
269 # icinga2 console --help
270 icinga2 - The Icinga 2 network monitoring daemon (version: v2.11.0)
271
272 Usage:
273   icinga2 console [<arguments>]
274
275 Interprets Icinga script expressions.
276
277 Global options:
278   -h [ --help ]             show this help message
279   -V [ --version ]          show version information
280   --color                   use VT100 color codes even when stdout is not a
281                             terminal
282   -D [ --define ] arg       define a constant
283   -a [ --app ] arg          application library name (default: icinga)
284   -l [ --library ] arg      load a library
285   -I [ --include ] arg      add include search directory
286   -x [ --log-level ] arg    specify the log level for the console log.
287                             The valid value is either debug, notice,
288                             information (default), warning, or critical
289   -X [ --script-debugger ]  whether to enable the script debugger
290
291 Command options:
292   -c [ --connect ] arg      connect to an Icinga 2 instance
293   -e [ --eval ] arg         evaluate expression and terminate
294   -r [ --file ] arg         evaluate a file and terminate
295   --syntax-only             only validate syntax (requires --eval or --file)
296   --sandbox                 enable sandbox mode
297
298 Report bugs at <https://github.com/Icinga/icinga2>
299 Icinga home page: <https://icinga.com/>
300 ```
301
302
303 On operating systems without the `libedit` library installed there is no
304 support for line-editing or a command history. However you can
305 use the `rlwrap` program if you require those features:
306
307 ```
308 $ rlwrap icinga2 console
309 ```
310
311 The debug console can be used to connect to a running Icinga 2 instance using
312 the [REST API](12-icinga2-api.md#icinga2-api). [API permissions](12-icinga2-api.md#icinga2-api-permissions)
313 are required for executing config expressions and auto-completion.
314
315 > **Note**
316 >
317 > The debug console does not currently support TLS certificate verification.
318 >
319 > Runtime modifications are not validated and might cause the Icinga 2
320 > daemon to crash or behave in an unexpected way. Use these runtime changes
321 > at your own risk and rather *inspect and debug objects read-only*.
322
323 You can specify the API URL using the `--connect` parameter.
324
325 Although the password can be specified there process arguments on UNIX platforms are
326 usually visible to other users (e.g. through `ps`). In order to securely specify the
327 user credentials the debug console supports two environment variables:
328
329   Environment variable | Description
330   ---------------------|-------------
331   ICINGA2_API_USERNAME | The API username.
332   ICINGA2_API_PASSWORD | The API password.
333
334 Here's an example:
335
336 ```
337 $ ICINGA2_API_PASSWORD=icinga icinga2 console --connect 'https://root@localhost:5665/'
338 Icinga 2 (version: v2.11.0)
339 <1> =>
340 ```
341
342 Once connected you can inspect variables and execute other expressions by entering them at the prompt:
343
344 ```
345 <1> => var h = get_host("icinga2-agent1.localdomain")
346 null
347 <2> => h.last_check_result
348 {
349         active = true
350         check_source = "icinga2-agent1.localdomain"
351         command = [ "/usr/local/sbin/check_ping", "-H", "127.0.0.1", "-c", "5000,100%", "-w", "3000,80%" ]
352         execution_end = 1446653527.174983
353         execution_start = 1446653523.152673
354         exit_status = 0.000000
355         output = "PING OK - Packet loss = 0%, RTA = 0.11 ms"
356         performance_data = [ "rta=0.114000ms;3000.000000;5000.000000;0.000000", "pl=0%;80;100;0" ]
357         schedule_end = 1446653527.175133
358         schedule_start = 1446653583.150000
359         state = 0.000000
360         type = "CheckResult"
361         vars_after = {
362                 attempt = 1.000000
363                 reachable = true
364                 state = 0.000000
365                 state_type = 1.000000
366         }
367         vars_before = {
368                 attempt = 1.000000
369                 reachable = true
370                 state = 0.000000
371                 state_type = 1.000000
372         }
373 }
374 <3> =>
375 ```
376
377 You can use the `--eval` parameter to evaluate a single expression in batch mode.
378 Using the `--file` option you can specify a file which should be evaluated.
379 The output format for batch mode is JSON.
380
381 The `--syntax-only` option can be used in combination with `--eval` or `--file`
382 to check a script for syntax errors. In this mode the script is parsed to identify
383 syntax errors but not evaluated.
384
385 Here's an example that retrieves the command that was used by Icinga to check the `icinga2-agent1.localdomain` host:
386
387 ```
388 $ ICINGA2_API_PASSWORD=icinga icinga2 console --connect 'https://root@localhost:5665/' --eval 'get_host("icinga2-agent1.localdomain").last_check_result.command' | python -m json.tool
389 [
390     "/usr/local/sbin/check_ping",
391     "-H",
392     "127.0.0.1",
393     "-c",
394     "5000,100%",
395     "-w",
396     "3000,80%"
397 ]
398 ```
399
400 ## CLI command: Daemon <a id="cli-command-daemon"></a>
401
402 The CLI command `daemon` provides the functionality to start/stop Icinga 2.
403 Furthermore it allows to run the [configuration validation](11-cli-commands.md#config-validation).
404
405 ```
406 # icinga2 daemon --help
407 icinga2 - The Icinga 2 network monitoring daemon (version: v2.11.0)
408
409 Usage:
410   icinga2 daemon [<arguments>]
411
412 Starts Icinga 2.
413
414 Global options:
415   -h [ --help ]             show this help message
416   -V [ --version ]          show version information
417   --color                   use VT100 color codes even when stdout is not a
418                             terminal
419   -D [ --define ] arg       define a constant
420   -a [ --app ] arg          application library name (default: icinga)
421   -l [ --library ] arg      load a library
422   -I [ --include ] arg      add include search directory
423   -x [ --log-level ] arg    specify the log level for the console log.
424                             The valid value is either debug, notice,
425                             information (default), warning, or critical
426   -X [ --script-debugger ]  whether to enable the script debugger
427
428 Command options:
429   -c [ --config ] arg       parse a configuration file
430   -z [ --no-config ]        start without a configuration file
431   -C [ --validate ]         exit after validating the configuration
432   -e [ --errorlog ] arg     log fatal errors to the specified log file (only
433                             works in combination with --daemonize or
434                             --close-stdio)
435   -d [ --daemonize ]        detach from the controlling terminal
436   --close-stdio             do not log to stdout (or stderr) after startup
437
438 Report bugs at <https://github.com/Icinga/icinga2>
439 Icinga home page: <https://icinga.com/>
440 ```
441
442 ### Config Files <a id="cli-command-daemon-config-files"></a>
443
444 You can specify one or more configuration files with the `--config` option.
445 Configuration files are processed in the order they're specified on the command-line.
446
447 When no configuration file is specified and the `--no-config` is not used
448 Icinga 2 automatically falls back to using the configuration file
449 `ConfigDir + "/icinga2.conf"` (where ConfigDir is usually `/etc/icinga2`).
450
451 ### Validation <a id="cli-command-daemon-validation"></a>
452
453 The `--validate` option can be used to check if configuration files
454 contain errors. If any errors are found, the exit status is 1, otherwise 0
455 is returned. More details in the [configuration validation](11-cli-commands.md#config-validation) chapter.
456
457 ## CLI command: Feature <a id="cli-command-feature"></a>
458
459 The `feature enable` and `feature disable` commands can be used to enable and disable features:
460
461 ```
462 # icinga2 feature disable <tab>
463 --app              --define           --include          --log-level        --version          checker            graphite           mainlog
464 --color            --help             --library          --script-debugger  api                command            ido-mysql          notification
465 ```
466
467 ```
468 # icinga2 feature enable <tab>
469 --app              --define           --include          --log-level        --version          debuglog           ido-pgsql          livestatus         perfdata           syslog
470 --color            --help             --library          --script-debugger  compatlog          gelf               influxdb           opentsdb           statusdata
471 ```
472
473 The `feature list` command shows which features are currently enabled:
474
475 ```
476 # icinga2 feature list
477 Disabled features: compatlog debuglog gelf ido-pgsql influxdb livestatus opentsdb perfdata statusdata syslog
478 Enabled features: api checker command graphite ido-mysql mainlog notification
479 ```
480
481 ## CLI command: Node <a id="cli-command-node"></a>
482
483 Provides the functionality to setup master and client
484 nodes in a [distributed monitoring](06-distributed-monitoring.md#distributed-monitoring) scenario.
485
486 ```
487 # icinga2 node --help
488 icinga2 - The Icinga 2 network monitoring daemon (version: v2.11.0)
489
490 Usage:
491   icinga2 <command> [<arguments>]
492
493 Supported commands:
494   * node setup (set up node)
495   * node wizard (wizard for node setup)
496
497 Global options:
498   -h [ --help ]             show this help message
499   -V [ --version ]          show version information
500   --color                   use VT100 color codes even when stdout is not a
501                             terminal
502   -D [ --define ] arg       define a constant
503   -a [ --app ] arg          application library name (default: icinga)
504   -l [ --library ] arg      load a library
505   -I [ --include ] arg      add include search directory
506   -x [ --log-level ] arg    specify the log level for the console log.
507                             The valid value is either debug, notice,
508                             information (default), warning, or critical
509   -X [ --script-debugger ]  whether to enable the script debugger
510
511 Report bugs at <https://github.com/Icinga/icinga2>
512 Icinga home page: <https://icinga.com/>
513 ```
514
515 ## CLI command: Object <a id="cli-command-object"></a>
516
517 The `object` CLI command can be used to list all configuration objects and their
518 attributes. The command also shows where each of the attributes was modified and as such
519 provides debug information for further configuration problem analysis.
520 That way you can also identify which objects have been created from your [apply rules](17-language-reference.md#apply).
521
522 Runtime modifications via the [REST API](12-icinga2-api.md#icinga2-api-config-objects)
523 are not immediately updated. Furthermore there is a known issue with
524 [group assign expressions](17-language-reference.md#group-assign) which are not reflected in the host object output.
525 You need to restart Icinga 2 in order to update the `icinga2.debug` cache file.
526
527 More information can be found in the [troubleshooting](15-troubleshooting.md#troubleshooting-list-configuration-objects) section.
528
529 ```
530 # icinga2 object --help
531 icinga2 - The Icinga 2 network monitoring daemon (version: v2.11.0)
532
533 Usage:
534   icinga2 <command> [<arguments>]
535
536 Supported commands:
537   * object list (lists all objects)
538
539 Global options:
540   -h [ --help ]             show this help message
541   -V [ --version ]          show version information
542   --color                   use VT100 color codes even when stdout is not a
543                             terminal
544   -D [ --define ] arg       define a constant
545   -a [ --app ] arg          application library name (default: icinga)
546   -l [ --library ] arg      load a library
547   -I [ --include ] arg      add include search directory
548   -x [ --log-level ] arg    specify the log level for the console log.
549                             The valid value is either debug, notice,
550                             information (default), warning, or critical
551   -X [ --script-debugger ]  whether to enable the script debugger
552
553 Report bugs at <https://github.com/Icinga/icinga2>
554 Icinga home page: <https://icinga.com/>
555 ```
556
557 ## CLI command: Pki <a id="cli-command-pki"></a>
558
559 Provides the CLI commands to
560
561 * generate a new certificate authority (CA)
562 * generate a new CSR or self-signed certificate
563 * sign a CSR and return a certificate
564 * save a master certificate manually
565 * request a signed certificate from the master
566 * generate a new ticket for the client setup
567
568 This functionality is used by the [node setup/wizard](11-cli-commands.md#cli-command-node) CLI commands.
569 You will need them in the [distributed monitoring chapter](06-distributed-monitoring.md#distributed-monitoring).
570
571 ```
572 # icinga2 pki --help
573 icinga2 - The Icinga 2 network monitoring daemon (version: v2.11.0)
574
575 Usage:
576   icinga2 <command> [<arguments>]
577
578 Supported commands:
579   * pki new-ca (sets up a new CA)
580   * pki new-cert (creates a new CSR)
581   * pki request (requests a certificate)
582   * pki save-cert (saves another Icinga 2 instance's certificate)
583   * pki sign-csr (signs a CSR)
584   * pki ticket (generates a ticket)
585
586 Global options:
587   -h [ --help ]             show this help message
588   -V [ --version ]          show version information
589   --color                   use VT100 color codes even when stdout is not a
590                             terminal
591   -D [ --define ] arg       define a constant
592   -a [ --app ] arg          application library name (default: icinga)
593   -l [ --library ] arg      load a library
594   -I [ --include ] arg      add include search directory
595   -x [ --log-level ] arg    specify the log level for the console log.
596                             The valid value is either debug, notice,
597                             information (default), warning, or critical
598   -X [ --script-debugger ]  whether to enable the script debugger
599
600 Report bugs at <https://github.com/Icinga/icinga2>
601 Icinga home page: <https://icinga.com/>
602 ```
603
604 ## CLI command: Variable <a id="cli-command-variable"></a>
605
606 Lists all configured variables (constants) in a similar fashion like [object list](11-cli-commands.md#cli-command-object).
607
608 ```
609 # icinga2 variable --help
610 icinga2 - The Icinga 2 network monitoring daemon (version: v2.11.0)
611
612 Usage:
613   icinga2 <command> [<arguments>]
614
615 Supported commands:
616   * variable get (gets a variable)
617   * variable list (lists all variables)
618
619 Global options:
620   -h [ --help ]             show this help message
621   -V [ --version ]          show version information
622   --color                   use VT100 color codes even when stdout is not a
623                             terminal
624   -D [ --define ] arg       define a constant
625   -a [ --app ] arg          application library name (default: icinga)
626   -l [ --library ] arg      load a library
627   -I [ --include ] arg      add include search directory
628   -x [ --log-level ] arg    specify the log level for the console log.
629                             The valid value is either debug, notice,
630                             information (default), warning, or critical
631   -X [ --script-debugger ]  whether to enable the script debugger
632
633 Report bugs at <https://github.com/Icinga/icinga2>
634 Icinga home page: <https://icinga.com/>
635 ```
636
637 ## Enabling/Disabling Features <a id="enable-features"></a>
638
639 Icinga 2 provides configuration files for some commonly used features. These
640 are installed in the `/etc/icinga2/features-available` directory and can be
641 enabled and disabled using the `icinga2 feature enable` and `icinga2 feature disable`
642 [CLI commands](11-cli-commands.md#cli-command-feature), respectively.
643
644 The `icinga2 feature enable` CLI command creates symlinks in the
645 `/etc/icinga2/features-enabled` directory which is included by default
646 in the example configuration file.
647
648 You can view a list of enabled and disabled features:
649
650 ```
651 # icinga2 feature list
652 Disabled features: api command compatlog debuglog graphite icingastatus ido-mysql ido-pgsql livestatus notification perfdata statusdata syslog
653 Enabled features: checker mainlog notification
654 ```
655
656 Using the `icinga2 feature enable` command you can enable features:
657
658 ```
659 # icinga2 feature enable graphite
660 Enabling feature graphite. Make sure to restart Icinga 2 for these changes to take effect.
661 ```
662
663 You can disable features using the `icinga2 feature disable` command:
664
665 ```
666 # icinga2 feature disable ido-mysql livestatus
667 Disabling feature ido-mysql. Make sure to restart Icinga 2 for these changes to take effect.
668 Disabling feature livestatus. Make sure to restart Icinga 2 for these changes to take effect.
669 ```
670
671 The `icinga2 feature enable` and `icinga2 feature disable` commands do not
672 restart Icinga 2. You will need to restart Icinga 2 using the init script
673 after enabling or disabling features.
674
675
676
677 ## Configuration Validation <a id="config-validation"></a>
678
679 Once you've edited the configuration files make sure to tell Icinga 2 to validate
680 the configuration changes. Icinga 2 will log any configuration error including
681 a hint on the file, the line number and the affected configuration line itself.
682
683 The following example creates an apply rule without any `assign` condition.
684
685 ```
686 apply Service "my-ping4" {
687   import "generic-service"
688   check_command = "ping4"
689   //assign where host.address
690 }
691 ```
692
693 Validate the configuration:
694
695 ```
696 # icinga2 daemon -C
697
698 [2014-05-22 17:07:25 +0200] critical/ConfigItem: Location:
699 /etc/icinga2/conf.d/tests/my.conf(5): }
700 /etc/icinga2/conf.d/tests/my.conf(6):
701 /etc/icinga2/conf.d/tests/my.conf(7): apply Service "my-ping4" {
702                                         ^^^^^^^^^^^^^
703 /etc/icinga2/conf.d/tests/my.conf(8):   import "test-generic-service"
704 /etc/icinga2/conf.d/tests/my.conf(9):   check_command = "ping4"
705
706 Config error: 'apply' is missing 'assign'
707 [2014-05-22 17:07:25 +0200] critical/ConfigItem: 1 errors, 0 warnings.
708 Icinga 2 detected configuration errors.
709 ```
710
711 If you encounter errors during configuration validation, please make sure
712 to read the [troubleshooting](15-troubleshooting.md#troubleshooting) chapter.
713
714 You can also use the [CLI command](11-cli-commands.md#cli-command-object) `icinga2 object list`
715 after validation passes to analyze object attributes, inheritance or created
716 objects by apply rules.
717 Find more on troubleshooting with `object list` in [this chapter](15-troubleshooting.md#troubleshooting-list-configuration-objects).
718
719
720 ## Reload on Configuration Changes <a id="config-change-reload"></a>
721
722 Every time you have changed your configuration you should first tell Icinga 2
723 to [validate](11-cli-commands.md#config-validation). If there are no validation errors, you can
724 safely reload the Icinga 2 daemon.
725
726 ```
727 # systemctl reload icinga2
728 ```
729
730 The `reload` action will send the `SIGHUP` signal to the Icinga 2 daemon
731 which will validate the configuration in a separate process and not stop
732 the other events like check execution, notifications, etc.