# icinga2
icinga2 - The Icinga 2 network monitoring daemon (version: v2.1.1-299-gf695275)
-
+
Usage:
icinga2 <command> [<arguments>]
-
+
Supported commands:
* console (Icinga console)
* daemon (starts Icinga 2)
* troubleshoot (collect information for troubleshooting)
* variable get (gets a variable)
* variable list (lists all variables)
-
+
Global options:
-h [ --help ] show this help message
-V [ --version ] show version information
-l [ --library ] arg load a library
-I [ --include ] arg add include search directory
-x [ --log-level ] arg specify the log level for the console log
-
+
Command options:
-
- Report bugs at <https://dev.icinga.org/>
+
+ Report bugs at <https://dev.icinga.org/>
Icinga home page: <https://www.icinga.org/>
Collects basic information like version, paths, log files and crash reports for troubleshooting purposes and prints them to a file or the console. See [troubleshooting](17-troubleshooting.md#troubleshooting-information-required).
-Its output defaults to a file named `troubleshooting-[TIMESTAMP].log` so it won't overwrite older troubleshooting files.
+Its output defaults to a file named `troubleshooting-[TIMESTAMP].log` so it won't overwrite older troubleshooting files.
-> **Note**
+> **Note**
> Keep in mind that this tool can not collect information from other icinga2 nodes, you will have to run it on
-> each of one of you instances.
+> each of one of you instances.
> This is only a tool to collect information to help others help you, it will not attempt to fix anything.
Example filtered by `Service` objects with the name `ping*`:
# icinga2 object list --type Service --name *ping*
- Object 'nbmif.int.netways.de!ping4' of type 'Service':
- * __name = 'nbmif.int.netways.de!ping4'
+ Object 'icinga.org!ping4' of type 'Service':
+ * __name = 'icinga.org!ping4'
* check_command = 'ping4'
% = modified in '/etc/icinga2/conf.d/services.conf', lines 17:3-17:25
* check_interval = 60
% = modified in '/etc/icinga2/conf.d/templates.conf', lines 28:3-28:21
- * host_name = 'nbmif.int.netways.de'
+ * host_name = 'icinga.org'
% = modified in '/etc/icinga2/conf.d/services.conf', lines 14:1-14:21
* max_check_attempts = 3
% = modified in '/etc/icinga2/conf.d/templates.conf', lines 27:3-27:24
Now pass the basic auth information to curl and send a GET request to the API:
- $ curl -u root:icinga -k -s 'https://localhost:5665/v1'
+ $ curl -u root:icinga -k -s 'https://icinga.org:5665/v1'
In case you will get an `Unauthorized` error message make sure to
check the API user credentials.
Example for all services in NOT-OK state:
- https://localhost:5665/v1/services?filter=service.state!=0
+ https://icinga.org:5665/v1/services?filter=service.state!=0
Example for matching all hosts by name (**Note**: `"` are url-encoded as `%22`):
- https://localhost:5665/v1/hosts?filter=match(%22nbmif*%22,host.name)
+ https://icinga.org:5665/v1/hosts?filter=match(%22nbmif*%22,host.name)
**TODO**
Reschedule a service check for all services in NOT-OK state:
- $ curl -u root:icinga -k -s 'https://localhost:5665/v1/actions/reschedule-check?filter=service.state!=0&type=Service' -X POST | python -m json.tool
+ $ curl -u root:icinga -k -s 'https://icinga.org:5665/v1/actions/reschedule-check?filter=service.state!=0&type=Service' -X POST | python -m json.tool
{
"results": [
{
"code": 200.0,
- "status": "Successfully rescheduled check for nbmif.int.netways.de!http."
+ "status": "Successfully rescheduled check for icinga.org!http."
},
{
"code": 200.0,
- "status": "Successfully rescheduled check for nbmif.int.netways.de!disk."
+ "status": "Successfully rescheduled check for icinga.org!disk."
},
{
"code": 200.0,
- "status": "Successfully rescheduled check for nbmif.int.netways.de!disk /."
+ "status": "Successfully rescheduled check for icinga.org!disk /."
}
]
}
Example for the main url endpoint `/v1/status`:
- $ curl -k -s -u root:icinga 'https://localhost:5665/v1/status' | python -m json.tool
+ $ curl -k -s -u root:icinga 'https://icinga.org:5665/v1/status' | python -m json.tool
{
"results": [
{
- "name": "ApiListener"
+ "name": "ApiListener",
+ "perfdata": [ ... ],
+ "status": [ ... ]
},
...
{
- "name": "Collection"
+ "name": "IcingaAplication",
+ "perfdata": [ ... ],
+ "status": [ ... ]
},
...
]
}
-`/v1/status/Collection` is always available as virtual status url endpoint.
+`/v1/status` is always available as virtual status url endpoint.
It provides all feature status information into a collected overview.
Example for the icinga application url endpoint `/v1/status/IcingaApplication`:
- $ curl -k -s -u root:icinga 'https://localhost:5665/v1/status/IcingaApplication' | python -m json.tool
+ $ curl -k -s -u root:icinga 'https://icinga.org:5665/v1/status/IcingaApplication' | python -m json.tool
{
"results": [
{
"enable_notifications": true,
"enable_perfdata": true,
"enable_service_checks": true,
- "node_name": "mbmif.int.netways.de",
+ "node_name": "icinga.org",
"pid": 59819.0,
"program_start": 1443019345.093372,
"version": "v2.3.0-573-g380a131"
Send a `GET` request to `/v1/hosts` to list all host objects and
their attributes.
- $ curl -u root:icinga -k -s 'https://localhost:5665/v1/hosts'
+ $ curl -u root:icinga -k -s 'https://icinga.org:5665/v1/hosts'
#### <a id="icinga2-api-hosts-create"></a> Create New Host Object
Example:
- $ curl -u root:icinga -k -s 'https://localhost:5665/v1/hosts/google.com' \
+ $ curl -u root:icinga -k -s 'https://icinga.org:5665/v1/hosts/google.com' \
-X PUT \
-d '{ "templates": [ "generic-host" ], "attrs": { "address": "8.8.8.8", "vars.os" : "Linux" } }' \
| python -m json.tool
If the configuration validation fails, the new object will not be created and the response body
contains a detailed error message. The following example omits the required `check_command` attribute.
- $ curl -u root:icinga -k -s 'https://localhost:5665/v1/hosts/google.com' \
+ $ curl -u root:icinga -k -s 'https://icinga.org:5665/v1/hosts/google.com' \
-X PUT \
-d '{ "attrs": { "address": "8.8.8.8", "vars.os" : "Linux" } }' \
| python -m json.tool
Send a `GET` request including the host name inside the url:
- $ curl -u root:icinga -k -s 'https://localhost:5665/v1/hosts/google.com'
+ $ curl -u root:icinga -k -s 'https://icinga.org:5665/v1/hosts/google.com'
You can select specific attributes by adding them as url parameters using `?attrs=...`. Multiple
attributes must be added one by one, e.g. `?attrs=host.address&attrs=host.name`.
- $ curl -u root:icinga -k -s 'https://localhost:5665/v1/hosts/google.com?attrs=host.name&attrs=host.address' | python -m json.tool
+ $ curl -u root:icinga -k -s 'https://icinga.org:5665/v1/hosts/google.com?attrs=host.name&attrs=host.address' | python -m json.tool
{
"results": [
{
Example for existing object `google.com`:
- $ curl -u root:icinga -k -s 'https://localhost:5665/v1/hosts/google.com' \
+ $ curl -u root:icinga -k -s 'https://icinga.org:5665/v1/hosts/google.com' \
-X POST \
-d '{ "attrs": { "address": "8.8.4.4", "vars.os" : "Windows" } }' \
| python -m json.tool
Example:
- $ curl -u root:icinga -k -s 'https://localhost:5665/v1/hosts/google.com?cascade=1' -X DELETE | python -m json.tool
+ $ curl -u root:icinga -k -s 'https://icinga.org:5665/v1/hosts/google.com?cascade=1' -X DELETE | python -m json.tool
{
"results": [
{
Send a `POST` request to a new config package called `puppet` in this example. This
will create a new empty configuration package.
- $ curl -k -s -u root:icinga -X POST https://localhost:5665/v1/config/packages/puppet | python -m json.tool
+ $ curl -k -s -u root:icinga -X POST https://icinga.org:5665/v1/config/packages/puppet | python -m json.tool
{
"results": [
{
Note: This example contains an error (`chec_command`), do not blindly copy paste it.
- $ curl -k -s -u root:icinga -X POST -d '{ "files": { "conf.d/test.conf": "object Host \"cfg-mgmt\" { chec_command = \"dummy\" }" } }' https://localhost:5665/v1/config/stages/puppet | python -m json.tool
+ $ curl -k -s -u root:icinga -X POST -d '{ "files": { "conf.d/test.conf": "object Host \"cfg-mgmt\" { chec_command = \"dummy\" }" } }' https://icinga.org:5665/v1/config/stages/puppet | python -m json.tool
{
"results": [
{
The following example contains one configuration package `puppet`.
The latter already has a stage created, but it is not active.
- $ curl -k -s -u root:icinga https://localhost:5665/v1/config/packages | python -m json.tool
+ $ curl -k -s -u root:icinga https://icinga.org:5665/v1/config/packages | python -m json.tool
{
"results": [
{
Sent a `GET` request to the url endpoint `/v1/config/stages` including the package
(`puppet`) and stage (`nbmif-1441625839-0`) name.
- $ curl -k -s -u root:icinga https://localhost:5665/v1/config/stages/puppet/nbmif-1441625839-0 | python -m json.tool
+ $ curl -k -s -u root:icinga https://icinga.org:5665/v1/config/stages/puppet/nbmif-1441625839-0 | python -m json.tool
{
"results": [
...
The following example fetches the faulty configuration inside `conf.d/test.conf`
for further analysis.
- $ curl -k -s -u root:icinga https://localhost:5665/v1/config/files/puppet/nbmif-1441625839-0/conf.d/test.conf
+ $ curl -k -s -u root:icinga https://icinga.org:5665/v1/config/files/puppet/nbmif-1441625839-0/conf.d/test.conf
object Host "cfg-mgmt" { chec_command = "dummy" }
Note: The returned files are plain-text instead of JSON-encoded.
Fetch the `startup.log` file and check the config validation errors:
- $ curl -k -s -u root:icinga https://localhost:5665/v1/config/files/puppet/imagine-1441133065-1/startup.log
+ $ curl -k -s -u root:icinga https://icinga.org:5665/v1/config/files/puppet/imagine-1441133065-1/startup.log
...
critical/config: Error: Attribute 'chec_command' does not exist.