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 579 forks source link

In mysql database, hostname is overwritten by display_name #7095

Closed graemekay7 closed 5 years ago

graemekay7 commented 5 years ago

Expected Behavior

When Hostname and Display_name are both used, display_name does not overwrite the hostname

Current Behavior

If only hostname is used, the alias field contains the hostname. If the display_name is filled in, this overwrites the hostname. We have another, production, instance on 2.8.1-1 which works as expected.

The configuration below links to the mysql entry, both copied out below.

Host configuration:

object Host "e96e0650db7b030044c5f9b41d9619d4" { import "___generic_host" display_name = "VIJU-UK-EDIN-EDI1-MX700-01" address = "10.x.x.x" vars.model = "MX700" vars.pwd = "something" vars.username = "something" }

MySQL Entry under icinga.icinga_hosts:

| host_id | instance_id | config_type | host_object_id | alias | display_name | address | address6 | check_command_object_id | check_command_args | eventhandler_command_object_id | eventhandler_command_args | notification_timeperiod_object_id | check_timeperiod_object_id | failure_prediction_options | check_interval | retry_interval | max_check_attempts | first_notification_delay | notification_interval | notify_on_down | notify_on_unreachable | notify_on_recovery | notify_on_flapping | notify_on_downtime | stalk_on_up | stalk_on_down | stalk_on_unreachable | flap_detection_enabled | flap_detection_on_up | flap_detection_on_down | flap_detection_on_unreachable | low_flap_threshold | high_flap_threshold | process_performance_data | freshness_checks_enabled | freshness_threshold | passive_checks_enabled | event_handler_enabled | active_checks_enabled | retain_status_information | retain_nonstatus_information | notifications_enabled | obsess_over_host | failure_prediction_enabled | notes | notes_url | action_url | icon_image | icon_image_alt | vrml_image | statusmap_image | have_2d_coords | x_2d | y_2d | have_3d_coords | x_3d | y_3d | z_3d | config_hash
| 348 | 1 | 1 | 2860 | VIJU-UK-EDIN-EDI1-MX700-01 | VIJU-UK-EDIN-EDI1-MX700-01 | 10.x.x.x | | 28 | NULL | 2795 | NULL | 0 | 0 | | 5 | 1 | 3 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 25 | 25 | 1 | 1 | 300 | 1 | 1 | 1 | 0 | 0 | 1 | 0 | 0 | | | | | | NULL | NULL | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3a3e53ee7b8a1fa202817d642507bd04f2f248b90d867ff19e2a21b653c711d9 |

Possible Solution

Do not overwrite hostname

Steps to Reproduce (for bugs)

  1. Create a host without a display name, in mysql table it should only contain an alias
  2. Update the host to include a display_name, it will now overwrite the hostname also (alias and display_name fields the same)

Context

We currently assign a GUID via our ITSM to the hostname and pull this in for our event commands and reporting (reporting uses the GUID to pull location / model information)

Display name is used for a friendly, recognizable name for our service desk staff when using Icingaweb2.

Your Environment

Object 'lab-sat-01' of type 'Zone': % declared in '/etc/icinga2/zones.conf', lines 27:1-27:24

Object 'viju-uk-lab' of type 'Zone': % declared in '/etc/icinga2/zones.conf', lines 39:1-39:25

Object 'director-global' of type 'Zone': % declared in '/etc/icinga2/zones.conf', lines 17:1-17:29

Object 'global-templates' of type 'Zone': % declared in '/etc/icinga2/zones.conf', lines 13:1-13:30

dnsmichi commented 5 years ago

The host name is stored in the icinga_objects table as name1 column, so you'll need to modify your query to join this table as well. alias is just an old column which is updated for compatibility reasons - either it takes the hostname, or the display_name if set.

select oh.name1 as hostname, h.display_name from icinga_objects oh join icinga_hosts h on oh.object_id=h.host_object_id;
graemekay7 commented 5 years ago

Thank you @dnsmichi

We are reviewing now, but see it as you described so will close this down.

Many thanks, GK