Herramientas de usuario

Herramientas del sitio


unattended_installations:cli_command

Icinga 2 CLI Commands

Icinga 2 comes with a number of CLI commands which support bash autocompletion.

These CLI commands will allow you to use certain functionality provided by and around the Icinga 2 daemon.

Each CLI command provides its own help and usage information, so please make sure to always run them with the –help parameter.

Run icinga2 without any arguments to get a list of all available global options.

# 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)
* feature disable (disables specified feature)
* feature enable (enables specified feature)
* feature list (lists all enabled features)
* node add (add node)
* node blacklist add (adds a new blacklist filter)
* node blacklist list (lists all blacklist filters)
* node blacklist remove (removes a blacklist filter)
* node list (lists all nodes)
* node remove (removes node)
* node set (set node attributes)
* node setup (set up node)
* node update-config (update node config)
* node whitelist add (adds a new whitelist filter)
* node whitelist list (lists all whitelist filters)
* node whitelist remove (removes a whitelist filter)
* node wizard (wizard for node setup)
* object list (lists all objects)
* pki new-ca (sets up a new CA)
* pki new-cert (creates a new CSR)
* pki request (requests a certificate)
* pki save-cert (saves another Icinga 2 instance's certificate)
* pki sign-csr (signs a CSR)
* pki ticket (generates a ticket)
* repository clear-changes (clear uncommitted repository changes)
* repository commit (commit repository changes)
* repository endpoint add (adds a new Endpoint object)
* repository endpoint list (lists all Endpoint objects)
* repository endpoint remove (removes a Endpoint object)
* repository host add (adds a new Host object)
* repository host list (lists all Host objects)
* repository host remove (removes a Host object)
* repository service add (adds a new Service object)
* repository service list (lists all Service objects)
* repository service remove (removes a Service object)
* repository zone add (adds a new Zone object)
* repository zone list (lists all Zone objects)
* repository zone remove (removes a Zone object)
* 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 --color use VT100 color codes even when stdout is not a terminal
-D [ --define ] arg    define a constant
-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
  

Report bugs at <https://dev.icinga.org/>

Icinga home page: <https://www.icinga.org/>

Icinga 2 CLI Bash Autocompletion

Bash Auto-Completion (pressing <TAB>) is provided only for the corresponding context.

While –config will suggest and auto-complete files and directories on disk, feature enable will only suggest disabled features. repository will know about object specific attributes, and so on. Try it yourself.

Debian packages install the bash completion files into /etc/bash_completion.d/icinga2.

You will need to install the bash-completion package if not already installed.

# apt-get install bash-completion

CLI command: Console

The CLI command console can be used to evaluate Icinga config expressions, e.g. to test assign where rules.

$ icinga2 console
Icinga (version: v2.2.0-435-gc95d2f1)
<1> => function test(name) {
<1> ..   log("Hello " + name)
<1> .. }
null
<2> => test("World")
information/config: Hello World
null

The console command does not support line-editing or a command history. However you can use the rlwrap program if you require those features:

$ rlwrap icinga2 console

CLI command: Daemon

The CLI command daemon provides the functionality to start/stop Icinga 2.

# icinga2 daemon --help
icinga2 - The Icinga 2 network monitoring daemon (version: v2.1.1-299-gf695275)
Usage:
 icinga2 daemon [<arguments>]
Starts Icinga 2.
Global options:
 -h [ --help ]          show this help message
 -V [ --version ]       show version information --color use VT100 color codes even when stdout is not a terminal
 -D [ --define ] arg    define a constant
 -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:
 -c [ --config ] arg   parse a configuration file
 -z [ --no-config ]    start without a configuration file
 -C [ --validate ]     exit after validating the configuration
 -e [ --errorlog ] arg log fatal errors to the specified log file (only works in combination with --daemonize)
 -d [ --daemonize ]    detach from the controlling terminal

Config Files

Using the –config option you can specify one or more configuration files. Config files are processed in the order they're specified on the command-line.

When no configuration file is specified and the –no-config is not used Icinga 2 automatically falls back to using the configuration file SysconfDir + “/icinga2/icinga2.conf” (where SysconfDir is usually /etc).

Config Validation

The –validate option can be used to check if your configuration files contain errors. If any errors are found the exit status is 1, otherwise 0 is returned.

CLI command: Feature

The feature enable and feature disable commands can be used to enable and disable features:

# icinga2 feature disable <tab>
checker  --color  --define  --help  --include  --library  --log-level  mainlog  notification  --version

# icinga2 feature enable <tab>
api  command  debuglog  graphite  icingastatus  ido-pgsql  --library  --log-level  statusdata  --version 
--color  compatlog   --define   --help  ido-mysql   --include   livestatus  perfdata   syslog

The feature list command shows which features are currently enabled:

# icinga2 feature list
Disabled features: agent command compatlog debuglog gelf graphite icingastatus notification perfdata statusdata syslog
Enabled features: api checker livestatus mainlog

CLI command: Node

Provides the functionality to install and manage master and client nodes in a remote monitoring or distributed cluster scenario.

# icinga2 node --help
icinga2 - The Icinga 2 network monitoring daemon (version: v2.1.1-299-gf695275)
Usage:
 icinga2 <command> [<arguments>]
Supported commands:
 * node add (add node)
 * node blacklist add (adds a new blacklist filter)
 * node blacklist list (lists all blacklist filters)
 * node blacklist remove (removes a blacklist filter)
 * node list (lists all nodes)
 * node remove (removes node)
 * node set (set node attributes)
 * node setup (set up node)
 * node update-config (update node config)
 * node whitelist add (adds a new whitelist filter)
 * node whitelist list (lists all whitelist filters)
 * node whitelist remove (removes a whitelist filter)
 * node wizard (wizard for node setup)

CLI command: Object

The object CLI command can be used to list all configuration objects and their attributes. The command also shows where each of the attributes was modified.

 # icinga2 object --help
 icinga2 - The Icinga 2 network monitoring daemon (version: v2.1.1-299-gf695275)
 Usage:
  icinga2 <command> [<arguments>]
 Supported commands:
  * object list (lists all objects)

CLI command: Pki

Provides the CLI commands to

  • generate a new local CA
  • generate a new CSR or self-signed certificate
  • sign a CSR and return a certificate
  • save a master certificate manually
  • request a signed certificate from the master
  • generate a new ticket for the client setup
# icinga2 pki --help
icinga2 - The Icinga 2 network monitoring daemon (version: v2.1.1-299-gf695275)
Usage:
 icinga2 <command> [<arguments>]
Supported commands:
 * pki new-ca (sets up a new CA)
 * pki new-cert (creates a new CSR)
 * pki request (requests a certificate)
 * pki save-cert (saves another Icinga 2 instance's certificate)
 * pki sign-csr (signs a CSR)
 * pki ticket (generates a ticket)

CLI command: Repository

Provides the functionality to manage the Icinga 2 configuration repository in /etc/icinga2/repository.d. All changes are logged and must be committed or cleared after review.

Note

  The CLI command repository only supports basic configuration manipulation (add, remove) and a limited set of objects required for the [remote client] integration. Future versions will support more options (set, etc.).

Please check the Icinga 2 development roadmap for updates.

  # icinga2 repository --help
  icinga2 - The Icinga 2 network monitoring daemon (version: v2.1.1-299-gf695275)
 Usage:
  icinga2 <command> [<arguments>]
 Supported commands:
  * repository clear-changes (clear uncommitted repository changes)
  * repository commit (commit repository changes)
  * repository endpoint add (adds a new Endpoint object)
  * repository endpoint list (lists all Endpoint objects)
  * repository endpoint remove (removes a Endpoint object)
  * repository host add (adds a new Host object)
  * repository host list (lists all Host objects)
  * repository host remove (removes a Host object)
  *  repository service add (adds a new Service object)
  * repository service list (lists all Service objects)
  * repository service remove (removes a Service object)
  * repository zone add (adds a new Zone object)
  * repository zone list (lists all Zone objects)
  * repository zone remove (removes a Zone object)

CLI command: Troubleshoot

Collects basic information like version, paths, log files and crash reports for troubleshooting purposes and prints them to a file or the console.

Its output defaults to a file named troubleshooting-[TIMESTAMP].log so it won't overwrite older troubleshooting files.

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.
 This is only a tool to collect information to help others help you, it will not attempt to fix anything.
 # icinga2 troubleshoot --help
 icinga2 - The Icinga 2 network monitoring daemon (version: v2.2.0-551-g1d0f6ed)
Usage:
 icinga2 troubleshoot [<arguments>]
Command options:
 -c [ --console ]       print to console instead of file
 -o [ --output ] arg    path to output file
 --include-vars         print variables to separate file
 --inluce-objects       print object to separate file

CLI command: Variable

Lists all configured variables (constants) in a similar fasion like object list.

 # icinga2 variable --help
 icinga2 - The Icinga 2 network monitoring daemon (version: v2.1.1-299-gf695275)
Usage:
 icinga2 <command> [<arguments>]
Supported commands:
 * variable get (gets a variable)
 * variable list (lists all variables)
unattended_installations/cli_command.txt · Última modificación: 2022/11/02 17:58 por 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki