]> granicus.if.org Git - icinga2/commitdiff
Add database plugins check_mysql_health, check_mssql_health, check_oracle_health...
authorDirk Goetz <dirk.goetz@netways.de>
Mon, 16 Mar 2015 10:00:26 +0000 (11:00 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Mon, 20 Apr 2015 06:53:10 +0000 (08:53 +0200)
fixes #8760

Signed-off-by: Gunnar Beutner <gunnar@beutner.name>
doc/7-icinga-template-library.md
itl/plugins-contrib.d/CMakeLists.txt
itl/plugins-contrib.d/databases.conf [new file with mode: 0644]

index 31ad0611b579d2ea168ca45137fbaa9588a1b712..b2df41a3a443ce70faceb398d1110428b30f82db 100644 (file)
@@ -1034,6 +1034,113 @@ The Plugins contrib collects various contributed command definitions.
 These check commands assume that the global constant named `PluginContribDir`
 is set to the path where the user installs custom plugins and can be enabled by uncommenting the corresponding line in icinga2.conf.
 
+## <a id="plugins-contrib-databases"></a> Databases
+
+All database plugins go in this category.
+
+### <a id="plugins-contrib-command-mssql_health"></a> mssql_health
+
+The plugin `mssql_health` utilises Perl DBD::Sybase based on FreeTDS to connect to MSSQL databases for monitoring.
+For release tarballs, detailed documentation especially on the different modes and scripts for creating a monitoring user see [https://labs.consol.de](https://labs.consol.de/nagios/check_mssql_health/). For development check [https://github.com](https://github.com/lausser/check_mssql_health).
+
+Custom Attributes:
+
+Name                             | Description
+---------------------------------|------------------------------------------------------------------------------------------------------------------------------
+mssql_health_hostname            | **Optional.** Specifies the database hostname or address. No default because you typically use "mssql_health_server".
+mssql_health_port                | **Optional.** Specifies the database port. No default because you typically use "mssql_health_server".
+mssql_health_server              | **Optional.** The name of a predefined connection (in freetds.conf).
+mssql_health_currentdb           | **Optional.** The name of a database which is used as the current database for the connection.
+mssql_health_username            | **Optional.** The username for the database connection.
+mssql_health_password            | **Optional.** The password for the database connection.
+mssql_health_warning             | **Optional.** The warning threshold depending on the mode.
+mssql_health_critical            | **Optional.** The critical threshold depending on the mode.
+mssql_health_mode                | **Required.** The mode uses predefined keywords for the different checks. For example "connection-time", "database-free" or "sql".
+mssql_health_name                | **Optional.** Depending on the mode this could be the database name or a SQL statement.
+mssql_health_name2               | **Optional.** If "mssql_health_name" is a sql statement, "mssql_health_name2" can be used to appear in the output and the performance data.
+mssql_health_regexep             | **Optional.** If set to true, "mssql_health_name" will be interpreted as a regular expression. Defaults to false.
+mssql_health_units               | **Optional.** This is used for a better output of mode=sql and for specifying thresholds for mode=tablespace-free. Possible values are "%", "KB", "MB" and "GB".
+mssql_health_offlineok           | **Optional.** Set this to true, if offline databases are perfectly ok for you. Defaults to false.
+mssql_health_commit              | **Optional.** Set this to true to turn on autocommit for the dbd::sybase module. Defaults to false.
+
+### <a id="plugins-contrib-command-mysql_health"></a> mysql_health
+
+The plugin `mysql_health` utilises Perl DBD::MySQL to connect to MySQL databases for monitoring.
+For release tarballs and detailed documentation especially on the different modes and required permissions see [https://labs.consol.de](https://labs.consol.de/nagios/check_mysql_health/). For development check [https://github.com](https://github.com/lausser/check_mysql_health).
+
+Custom Attributes:
+
+Name                             | Description
+---------------------------------|------------------------------------------------------------------------------------------------------------------------------
+mysql_health_hostname            | **Required.** Specifies the database hostname or address. Defaults to "$address$" or "$address6$" if the `address` attribute is not set.
+mysql_health_port                | **Optional.** Specifies the database port. Defaults to 3306 (or 1186 for "mysql_health_mode" cluster).
+mysql_health_socket              | **Optional.** Specifies the database unix socket. No default.
+mysql_health_username            | **Optional.** The username for the database connection.
+mysql_health_password            | **Optional.** The password for the database connection.
+mysql_health_database            | **Optional.** The database to connect to. Defaults to information_schema.
+mysql_health_warning             | **Optional.** The warning threshold depending on the mode.
+mysql_health_critical            | **Optional.** The critical threshold depending on the mode.
+mysql_health_mode                | **Required.** The mode uses predefined keywords for the different checks. For example "connection-time", "slave-lag" or "sql".
+mysql_health_name                | **Optional.** The SQL statement to be executed with "mysql_health_mode" sql.
+mysql_health_name2               | **Optional.** If "mysql_health_name" is a sql statement, "mysql_health_name2" can be used to appear in the output and the performance data.
+mysql_health_units               | **Optional.** This is used for a better output of mode=sql and for specifying thresholds for mode=tablespace-free. Possible values are "%", "KB", "MB" and "GB".
+mysql_health_labelformat         | **Optional.** One of those formats pnp4nagios or groundwork. Defaults to pnp4nagios.
+
+### <a id="plugins-contrib-command-oracle_health"></a> oracle_health
+
+The plugin `oracle_health` utilises Perl DBD::Oracle based on oracle-instantclient-sdk or sqlplus to connect to Oracle databases for monitoring.
+For release tarballs and detailed documentation especially on the different modes and required permissions see [https://labs.consol.de](https://labs.consol.de/nagios/check_oracle_health/). For development check [https://github.com](https://github.com/lausser/check_oracle_health).
+
+Custom Attributes:
+
+Name                             | Description
+---------------------------------|------------------------------------------------------------------------------------------------------------------------------
+oracle_health_connect            | **Required.** Specifies the database connection string (from tnsnames.ora).
+oracle_health_username           | **Optional.** The username for the database connection.
+oracle_health_password           | **Optional.** The password for the database connection.
+oracle_health_warning            | **Optional.** The warning threshold depending on the mode.
+oracle_health_critical           | **Optional.** The critical threshold depending on the mode.
+oracle_health_mode               | **Required.** The mode uses predefined keywords for the different checks. For example "connection-time", "flash-recovery-area-usage" or "sql".
+oracle_health_name               | **Optional.** The tablespace, datafile, wait event, latch, enqueue depending on the mode or SQL statement to be executed with "oracle_health_mode" sql.
+oracle_health_name2              | **Optional.** If "oracle_health_name" is a sql statement, "oracle_health_name2" can be used to appear in the output and the performance data.
+oracle_health_units              | **Optional.** This is used for a better output of mode=sql and for specifying thresholds for mode=tablespace-free. Possible values are "%", "KB", "MB" and "GB".
+oracle_health_ident              | **Optional.** If set to true outputs instance and database names. Defaults to false.
+oracle_health_commit             | **Optional.** Set this to true to turn on autocommit for the dbd::oracle module. Defaults to false.
+oracle_health_noperfdata         | **Optional.** Set this to true if you want to disable perfdata. Defaults to false.
+
+Environment Macros:
+
+Name                | Description
+--------------------|------------------------------------------------------------------------------------------------------------------------------------------
+ORACLE_HOME         | **Required.** Specifies the location of the oracle instant client libraries. Defaults to "/usr/lib/oracle/11.2/client64/lib". Can be overridden by setting "oracle_home".
+TNS_ADMIN           | **Required.** Specifies the location of the tnsnames.ora including the database connection strings. Defaults to "/etc/icinga2/plugin-configs". Can be overridden by setting "oracle_tns_admin".
+
+### <a id="plugins-contrib-command-postgres"></a> postgres
+
+The plugin `postgres` utilises the psql binary to connect to PostgreSQL databases for monitoring.
+For release tarballs and detailed documentation especially the different actions and required persmissions see [https://bucardo.org/wiki/Check_postgres](https://bucardo.org/wiki/Check_postgres). For development check [https://github.com](https://github.com/bucardo/check_postgres).
+
+Custom Attributes:
+
+Name                             | Description
+---------------------------------|------------------------------------------------------------------------------------------------------------------------------
+postgres_host        | **Optional.** Specifies the database hostname or address. Defaults to "$address$" or "$address6$" if the `address` attribute is not set. If "postgres_unixsocket" is set to true falls back to unix socket.
+postgres_port        | **Optional.** Specifies the database port. Defaults to 5432.
+postgres_dbname      | **Optional.** Specifies the database name to connect to. Defaults to "postgres" or "template1".
+postgres_dbuser      | **Optional.** The username for the database connection. Defaults to "postgres".
+postgres_dbpass      | **Optional.** The password for the database connection. You can use a .pgpass file instead.
+postgres_dbservice   | **Optional.** Specifies the service name to use inside of pg_service.conf.
+postgres_warning     | **Optional.** Specifies the warning threshold, range depends on the action.
+postgres_critical    | **Optional.** Specifies the critical threshold, range depends on the action.
+postgres_include     | **Optional.** Specifies name(s) items to specifically include (e.g. tables), depends on the action.
+postgres_exclude     | **Optional.** Specifies name(s) items to specifically exclude (e.g. tables), depends on the action.
+postgres_includeuser | **Optional.** Include objects owned by certain users.
+postgres_excludeuser | **Optional.** Exclude objects owned by certain users.
+postgres_standby     | **Optional.** Assume that the server is in continious WAL recovery mode if set to true. Defaults to false.
+postgres_production  | **Optional.** Assume that the server is in production mode if set to true. Defaults to false.
+postgres_action      | **Required.** Determines the test executed.
+postgres_unixsocket  | **Optional.** If "postgres_unixsocket" is set to true the unix socket is used instead of an address. Defaults to false.
+
 ## <a id="plugins-contrib-ipmi"></a> IPMI Devices
 
 This category includes all plugins for IPMI devices.
index da60ca0e0c5b5223415f1fe5312c25c1ad39f842..8ca955013211ae79fc2dd2b16b44b424f2e2b98d 100644 (file)
@@ -16,6 +16,6 @@
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
 install(
-  FILES ipmi.conf network-components.conf operating-system.conf virtualization.conf vmware.conf web.conf
+  FILES databases.conf ipmi.conf network-components.conf operating-system.conf virtualization.conf vmware.conf web.conf
   DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2/include/plugins-contrib.d
 )
diff --git a/itl/plugins-contrib.d/databases.conf b/itl/plugins-contrib.d/databases.conf
new file mode 100644 (file)
index 0000000..7025e02
--- /dev/null
@@ -0,0 +1,305 @@
+/******************************************************************************
+ * Icinga 2                                                                   *
+ * Copyright (C) 2012-2015 Icinga Development Team (https://www.icinga.org)   *
+ *                                                                            *
+ * This program is free software; you can redistribute it and/or              *
+ * modify it under the terms of the GNU General Public License                *
+ * as published by the Free Software Foundation; either version 2             *
+ * of the License, or (at your option) any later version.                     *
+ *                                                                            *
+ * This program is distributed in the hope that it will be useful,            *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
+ * GNU General Public License for more details.                               *
+ *                                                                            *
+ * You should have received a copy of the GNU General Public License          *
+ * along with this program; if not, write to the Free Software Foundation     *
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
+ ******************************************************************************/
+
+object CheckCommand "mssql_health" {
+       import "plugin-check-command"
+
+       command = [ PluginDir + "/check_mssql_health" ]
+
+       arguments = {
+               "--hostname" = {
+                       value = "$mssql_health_hostname$"
+                       description = "the database server's hostname"
+               }
+               "--port" = {
+                       value = "$mssql_health_port$"
+                       description = "the database's port"
+               }
+               "--server" = {
+                       value = "$mssql_health_server$"
+                       description = "the name of a predefined connection"
+               }
+               "--currentdb" = {
+                       value = "$mssql_health_currentdb$"
+                       description = "the name of a database which is used as the current database for the connection"
+               }
+               "--username" = {
+                       value = "$mssql_health_username$"
+                       description = "the mssql db user"
+               }
+               "--password" = {
+                       value = "$mssql_health_password$"
+                       description = "the mssql db user's password"
+               }
+               "--warning" = {
+                       value = "$mssql_health_warning$"
+                       description = "the warning range"
+               }
+               "--critical" = {
+                       value = "$mssql_health_critical$"
+                       description = "the critical range"
+               }
+               "--mode" = {
+                       value = "$mssql_health_mode$"
+                       description = "the mode of the plugin"
+               }
+               "--name" = {
+                       value = "$mssql_health_name$"
+                       description = "the name of the database etc depending on the mode"
+               }
+               "--name2" = {
+                       value = "$mssql_health_name2$"
+                       description = "if name is a sql statement, name2 can be used to appear in the output and the performance data"
+               }
+               "--regexep" = {
+                       set_if = "$mssql_health_regexep$"
+                       description = "name will be interpreted as a regular expression"
+               }
+               "--units" = {
+                       value = "$mssql_health_units$"
+                       description = "This is used for a better output of mode=sql and for specifying thresholds for mode=tablespace-free"
+               }
+               "--offlineok" = {
+                       set_if = "$mssql_health_offlineok$"
+                       description = "if offline databases are perfectly ok for you"
+               }
+               "--commit" = {
+                       set_if = "$mssql_health_commit$"
+                       description = "turns on autocommit for the dbd::sybase module"
+               }
+       }
+
+       vars.mssql_health_regexep = false
+       vars.mssql_health_offlineok = false
+       vars.mssql_health_commit = false
+}
+
+object CheckCommand "mysql_health" {
+       import "plugin-check-command"
+       import "ipv4-or-ipv6"
+
+       command = [ PluginDir + "/check_mysql_health" ]
+
+       arguments = {
+               "--hostname" = {
+                       value = "$mysql_health_hostname$"
+                       description = "the database server's hostname"
+               }
+               "--port" = {
+                       value = "$mysql_health_port$"
+                       description = "the database's port"
+               }
+               "--socket" = {
+                       value = "$mysql_health_socket$"
+                       description = "the database's unix socket"
+               }
+               "--username" = {
+                       value = "$mysql_health_username$"
+                       description = "the mysql db user"
+               }
+               "--password" = {
+                       value = "$mysql_health_password$"
+                       description = "the mysql db user's password"
+               }
+               "--database" = {
+                       value = "$mysql_health_database$"
+                       description = "the database's name"
+               }
+               "--warning" = {
+                       value = "$mysql_health_warning$"
+                       description = "the warning range"
+               }
+               "--critical" = {
+                       value = "$mysql_health_critical$"
+                       description = "the critical range"
+               }
+               "--mode" = {
+                       value = "$mysql_health_mode$"
+                       description = "the mode of the plugin"
+               }
+               "--name" = {
+                       value = "$mysql_health_name$"
+                       description = "currently only used for sql statements"
+               }
+               "--name2" = {
+                       value = "$mysql_health_name2$"
+                       description = "if name is a sql statement, name2 can be used to appear in the output and the performance data"
+               }
+               "--units" = {
+                       value = "$mysql_health_units$"
+                       description = "This is used for a better output of mode=sql and for specifying thresholds for mode=tablespace-free"
+               }
+               "--labelformat" = {
+                       value = "$mysql_health_labelformat$"
+                       description = "one of pnp4nagios (which is the default) or groundwork"
+               }
+       }
+
+       vars.mysql_health_hostname = "$check_address$"
+}
+
+object CheckCommand "oracle_health" {
+       import "plugin-check-command"
+
+       command = [ PluginDir + "/check_oracle_health" ]
+
+       arguments = {
+               "--connect" = {
+                       value = "$oracle_health_connect$"
+                       description = "the connect string"
+               }
+               "--username" = {
+                       value = "$oracle_health_username$"
+                       description = "the oracle user"
+               }
+               "--password" = {
+                       value = "$oracle_health_password$"
+                       description = "the oracle user's password"
+               }
+               "--warning" = {
+                       value = "$oracle_health_warning$"
+                       description = "the warning range"
+               }
+               "--critical" = {
+                       value = "$oracle_health_critical$"
+                       description = "the critical range"
+               }
+               "--mode" = {
+                       value = "$oracle_health_mode$"
+                       description = "the mode of the plugin"
+               }
+               "--name" = {
+                       value = "$oracle_health_name$"
+                       description = "the name of the tablespace, datafile, wait event, latch, enqueue, or sql statement depending on the mode"
+               }
+               "--name2" = {
+                       value = "$oracle_health_name2$"
+                       description = "if name is a sql statement, name2 can be used to appear in the output and the performance data"
+               }
+               "--regexep" = {
+                       set_if = "$oracle_health_regexep$"
+                       description = "name will be interpreted as a regular expression"
+               }
+               "--units" = {
+                       value = "$oracle_health_units$"
+                       description = "This is used for a better output of mode=sql and for specifying thresholds for mode=tablespace-free"
+               }
+               "--ident" = {
+                       set_if = "$oracle_health_ident$"
+                       description = "outputs instance and database names"
+               }
+               "--commit" = {
+                       set_if = "$oracle_health_commit$"
+                       description = "turns on autocommit for the dbd::oracle module"
+               }
+               "--noperfdata" = {
+                       set_if = "$oracle_health_noperfdata$"
+                       description = "do not output performance data"
+               }
+       }
+
+       env = {
+               "ORACLE_HOME" = "$oracle_home$"
+               "TNS_ADMIN" = "$oracle_tns_admin$"
+       }
+
+       vars.oracle_health_regexep = false
+       vars.oracle_health_ident = false
+       vars.oracle_health_commit = false
+       vars.oracle_health_noperfdata = false
+
+       vars.oracle_home = "/usr/lib/oracle/11.2/client64/lib"
+       vars.oracle_tns_admin = SysconfDir + "/icinga2/plugin-configs"
+}
+
+object CheckCommand "postgres" {
+       import "plugin-check-command"
+       import "ipv4-or-ipv6"
+
+       command = [ PluginDir + "/check_postgres.pl" ]
+
+       arguments = {
+               "-H" = {
+                       value = "$postgres_host$"
+                       set_if = {{ macro("$postgres_unixsocket$") == false }}
+                       description = "hostname(s) to connect to; defaults to none (Unix socket)"
+               }
+               "-p" = {
+                       value = "$postgres_port$"
+                       description = "port(s) to connect to; defaults to 5432"
+               }
+               "-db" = {
+                       value = "$postgres_dbname$"
+                       description = "database name(s) to connect to; defaults to 'postgres' or 'template1'"
+               }
+               "-u" = {
+                       value = "$postgres_dbuser$"
+                       description = "database user(s) to connect as; defaults to 'postgres'"
+               }
+               "--dbpass" = {
+                       value = "$postgres_dbpass$"
+                       description = "database password(s); use a .pgpass file instead when possible"
+               }
+               "--dbservice" = {
+                       value = "$postgres_dbservice$"
+                       description = "service name to use inside of pg_service.conf"
+               }
+               "-w" = {
+                       value = "$postgres_warning$"
+                       description = "the warning threshold, range depends on the action"
+               }
+               "-c" = {
+                       value = "$postgres_critical$"
+                       description = "the critical threshold, range depends on the action"
+               }
+               "--include" = {
+                       value = "$postgres_include$"
+                       description = "name(s) items to specifically include (e.g. tables), depends on the action"
+               }
+               "--exclude" = {
+                       value = "$postgres_exclude$"
+                       description = "name(s) items to specifically exclude (e.g. tables), depends on the action"
+               }
+               "--includeuser" = {
+                       value = "$postgres_includeuser$"
+                       description = "include objects owned by certain users"
+               }
+               "--excludeuser" = {
+                       value = "$postgres_excludeuser$"
+                       description = "exclude objects owned by certain users"
+               }
+               "--assume-standby-mode" = {
+                       set_if = "$postgres_standby$"
+                       description = "assume that server in continious WAL recovery mode"
+               }
+               "--assume-prod" = {
+                       set_if = "$postgres_production$"
+                       description = "assume that server in production mode"
+               }
+               "--action" = {
+                       value = "$postgres_action$"
+                       description = "determines the test executed"
+               }
+       }
+
+       vars.postgres_host = "$check_address$"
+       vars.postgres_standby = false
+       vars.postgres_production = false
+       vars.postgres_unixsocket = false
+}