Icinga / icinga2

The core of our monitoring platform with a powerful configuration language and REST API.
https://icinga.com/docs/icinga2/latest
GNU General Public License v2.0
2.03k stars 578 forks source link

db2_health not working with catalogued databases, as --hostname is always used #6338

Closed XnS closed 6 years ago

XnS commented 6 years ago

Expected Behavior

According to the documentation it is possible to connect to cataloged databases. If that's the case, hostname and port are omitted. The check command should be rendered to:

check_db2_health --database $db2_health_database$ --report $db2_health_report$ --username $db2_health_username$ --password $db2_health_password$ --mode $db2_health_mode$ --warning $db2_health_warning$ --critical $db2_health_critical$

So that there's no tcp/ip connection involved.

Current Behavior

The --hostname parameter is always used, thus its not possible to connect to cataloged databases as check_db2_health is using tcp/ip mode if --hostname is present. The rendered check command is:

check_db2_health --hostname $check_address$ --database $db2_health_database$ --report $db2_health_report$ --username $db2_health_username$ --password $db2_health_password$ --mode $db2_health_mode$ --warning $db2_health_warning$ --critical $db2_health_critical$

Possible Solution

It should be possible to specify whether a cataloged database should be used or not. If that's the case, omit --hostname

Steps to Reproduce (for bugs)

  1. Create service which uses db2_health command
  2. Dont configure a hostname and port
  3. Execute check

Context

With the current behaviour no checks of catalogued databases are possible.

Your Environment

Copyright (c) 2012-2017 Icinga Development Team (https://www.icinga.com/) License GPLv2+: GNU GPL version 2 or later http://gnu.org/licenses/gpl2.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

Application information: Installation root: /usr Sysconf directory: /etc Run directory: /run Local state directory: /var Package data directory: /usr/share/icinga2 State path: /var/lib/icinga2/icinga2.state Modified attributes path: /var/lib/icinga2/modified-attributes.conf Objects path: /var/cache/icinga2/icinga2.debug Vars path: /var/cache/icinga2/icinga2.vars PID path: /run/icinga2/icinga2.pid

System information: Platform: SLES Platform version: 12-SP3 Kernel: Linux Kernel version: 4.4.126-94.22-default Architecture: x86_64

Build information: Compiler: GNU 4.8.5 Build host: hostname

* Operating System and version:

icinga01:~ # cat /etc/SuSE-release SUSE Linux Enterprise Server 12 (x86_64) VERSION = 12 PATCHLEVEL = 3

This file is deprecated and will be removed in a future service pack or release.

Please check /etc/os-release for details about this release.

* Enabled features (`icinga2 feature list`):

icinga01:~ # icinga2 feature list Disabled features: command compatlog debuglog elasticsearch gelf graphite influxdb opentsdb perfdata statusdata syslog Enabled features: api checker ido-mysql livestatus mainlog notification

* Icinga Web 2 version and modules (System - About):

Icinga Web 2 Version 2.5.3 Git commit ca7e886b820f0145999fdf7377f5c4132301eada Git commit date 2018-04-27 Copyright © 2013-2018 The Icinga Project

director master monitoring 2.5.3 nagvis 1.1.1

* Config validation (`icinga2 daemon -C`):

icinga01:~ # icinga2 daemon -C information/cli: Icinga application loader (version: r2.8.4-1) information/cli: Loading configuration file(s). information/ConfigItem: Committing config item(s). information/ApiListener: My API identity: icinga01.company.dmz warning/ApplyRule: Apply rule 'mail-icingaadmin' (in /etc/icinga2/conf.d/notifications.conf: 11:1-11:45) for type 'Notification' does not match anywhere! warning/ApplyRule: Apply rule 'mail-icingaadmin' (in /etc/icinga2/conf.d/notifications.conf: 23:1-23:48) for type 'Notification' does not match anywhere! warning/ApplyRule: Apply rule 'Switch Interface Check' (in /var/lib/icinga2/api/packages/director/icinga01-1527235359-3/zones.d/director-global/service_apply.conf: 1:0-1:75) for type 'Service' does not match anywhere! information/ConfigItem: Instantiated 1 ApiListener. information/ConfigItem: Instantiated 3 Zones. information/ConfigItem: Instantiated 1 Endpoint. information/ConfigItem: Instantiated 1 FileLogger. information/ConfigItem: Instantiated 3 ApiUsers. information/ConfigItem: Instantiated 1 UserGroup. information/ConfigItem: Instantiated 2 NotificationCommands. information/ConfigItem: Instantiated 219 CheckCommands. information/ConfigItem: Instantiated 1 IcingaApplication. information/ConfigItem: Instantiated 848 Hosts. information/ConfigItem: Instantiated 24 HostGroups. information/ConfigItem: Instantiated 1 Downtime. information/ConfigItem: Instantiated 3 TimePeriods. information/ConfigItem: Instantiated 1 User. information/ConfigItem: Instantiated 3 Comments. information/ConfigItem: Instantiated 22 ServiceGroups. information/ConfigItem: Instantiated 4977 Services. information/ConfigItem: Instantiated 1 ScheduledDowntime. information/ConfigItem: Instantiated 1 CheckerComponent. information/ConfigItem: Instantiated 1 IdoMysqlConnection. information/ConfigItem: Instantiated 1 LivestatusListener. information/ConfigItem: Instantiated 1 NotificationComponent. information/ScriptGlobal: Dumping variables to file '/var/cache/icinga2/icinga2.vars' information/cli: Finished validating the configuration file(s).


* If you run multiple Icinga 2 instances, the `zones.conf` file (or `icinga2 object list --type Endpoint` and `icinga2 object list --type Zone`) from all affected nodes.
dnsmichi commented 6 years ago

f0dbcabf70 added a default value into the CheckCommand but it hasn't been documented at all. If we remove it, this likely breaks setups. Not sure where to head here.

Mikesch-mp commented 6 years ago

Lazy as i was, i just copied the text from the plugin. But i will send PR soon, have allready an idea how to do it and not break existing setups. Just have to test it.