I got no entry for the JSON export. This is the output:
For SQL I get a long query, but it seems to be nothing interesting.
QUERY
SELECT so.name1 AS host_name, h.display_name COLLATE latin1_general_ci AS
host_display_name, CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked
IS NULL THEN 99 ELSE hs.current_state END AS host_state, so.name2 AS
service_description, s.display_name COLLATE latin1_general_ci AS
service_display_name, CASE WHEN ss.has_been_checked = 0 OR
ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END AS
service_state, CASE WHEN (ss.scheduled_downtime_depth = 0 OR
ss.scheduled_downtime_depth IS NULL) THEN 0 ELSE 1 END AS
service_in_downtime, ss.problem_has_been_acknowledged AS
service_acknowledged, CASE WHEN (ss.problem_has_been_acknowledged +
ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0 THEN 1
ELSE 0 END AS service_handled, ss.output AS service_output, ss.perfdata AS
service_perfdata, ss.current_check_attempt || ‘/’ || ss.max_check_attempts
AS service_attempt, UNIX_TIMESTAMP(ss.last_state_change) AS
service_last_state_change, s.icon_image AS service_icon_image,
s.icon_image_alt AS service_icon_image_alt, ss.is_flapping AS
service_is_flapping, ss.state_type AS service_state_type, CASE WHEN
ss.current_state = 0 THEN CASE WHEN ss.has_been_checked = 0 OR
ss.has_been_checked IS NULL THEN 16 ELSE 0 END + CASE WHEN
ss.problem_has_been_acknowledged = 1 THEN 2 ELSE CASE WHEN
ss.scheduled_downtime_depth > 0 THEN 1 ELSE 4 END END ELSE CASE WHEN
ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 16 WHEN
ss.current_state = 1 THEN 32 WHEN ss.current_state = 2 THEN 128 WHEN
ss.current_state = 3 THEN 64 ELSE 256 END + CASE WHEN hs.current_state > 0
THEN 1024 ELSE CASE WHEN ss.problem_has_been_acknowledged = 1 THEN 512 ELSE
CASE WHEN ss.scheduled_downtime_depth > 0 THEN 256 ELSE 2048 END END END
END AS service_severity, ss.notifications_enabled AS
service_notifications_enabled, ss.active_checks_enabled AS
service_active_checks_enabled, ss.passive_checks_enabled AS
service_passive_checks_enabled, ss.check_command AS service_check_command,
CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN CASE
ss.should_be_scheduled WHEN 1 THEN UNIX_TIMESTAMP(ss.next_check) +
(ss.normal_check_interval * 60) ELSE NULL END ELSE
Unfortunately I 'cant post more it’s get stuck in the loading progress. Let me know if it’s something interesting then I will try to post the rest of the SQL.
So, I found out that the DB is connected to the secondary master and somehow the secondary master doesn’t write any configs to the DB. But in the debug log on master2 there are IdoMysql Connections entries.
I think somehow the second master doesn’t get any configuration from the master1. Do you know what could be wrong? Do I need to set the accept_config attribute in /etc/icinga2/feature-enabled/api.conf to true on the master2, that it can receive config from master1?
When I shutdown the master2 the failover of the db connection to master 1 works fine, and it shows the hosts in the GUI, so master1 can successfully write the config to the db.
I actually thought that the secondary master only connects to the db if the primary fails, or am I wrong? Do I need to set a specific attribute on the primary master?
This is my ido-mysql.conf on both masters.
master1:
object IdoMysqlConnection “ido-mysql” {
user = “icinga”
password = “PASSWORD”
host = “192.168.122.35”
port = 3306
database = “icinga”
master2:
object IdoMysqlConnection “ido-mysql” {
user = “icinga”
password = “PASSWORD”
host = “192.168.122.35”
port = 3306
database = “icinga”
Do I need to enable_ha on both master oder just the primary one?
And what about the api.conf on the secondary master, set the accept_config to true or false ?
Note : The DB IDO HA feature can be disabled by setting the enable_ha attribute to false for the IdoMysqlConnection or IdoPgsqlConnection object on all nodes in the same zone.
accpet_config:
Note
Cluster nodes must accept configuration for creating, modifying and deleting objects. Ensure that accept_config is set to true in the ApiListener object on each node.
Thanks this helped.
Now I can see the host entries even though the icingaweb2 is connected to the secondary master.
Do you know how I can configure that the primary master will be chosen for the icingaweb2 connection, so that the secondary master works as a fallback?
If you have your icingaweb2 DB on the same DB-server it should work. You only have to sync the dashboard.ini files from each user to the second master. Because if one user creates his own dashboard it is not saved in the db, it is saved in that .ini-files in /etc/icingaweb2/dashboards. We are doing this task with a cron job and scp.