语境
我正在使用on进行配置Icinga2
Web2
和使用。IDO PostgreSQL
IDO MySQL
Ansible
CentOS 7
我的工作基于出色的https://github.com/Icinga/icinga2-ansible角色。我已经分叉了这个项目 (mickael-ange/icinga2-ansible) 以增加更多的自动化和支持,例如 IDO PostgreSQL。我正在使用 PostgreSQL 服务器 9.4。
好吧,我最终得到了一个icinga2-ansible-web2-ui
角色版本,它使用 IDO PostgreSQL 或 IDO MySQL 自动安装 Icinga2 Web2而无需向导。
我的问题
服务器似乎可以正常工作,但我无法弄清楚如何在 Icinga2 Web2 界面中获取数据,例如:
Comments
并Downtimes
从Overview
菜单Event Grid
,Event Overview
,Notifications
,Timeline
从History
菜单
我可以创建Comments
and Schedule Downtimes
,但它们不会在 UI 中列出。正确处理停机时间。
我可以发送Notifications
,但它们也不会在 UI 中列出。当 SELinux 处于许可模式时会发出通知。
我的问题是:是否有任何 IDO 或 Icinga2 Web2 配置来让数据库填充评论、停机时间等。
我的/etc/icinga2/features-enabled/ido-pgsql.conf
library "db_ido_pgsql"
object IdoPgsqlConnection "ido-pgsql" {
user = "icinga"
password = "icinga"
host = "localhost"
database = "icinga"
table_prefix = "icinga_"
instance_name = "icinga2"
instance_description = "icinga2 instance"
cleanup = {
downtimehistory_age = 48h
logentries_age = 31d
}
categories = DbCatConfig | DbCatState
}
笔记
注1
我已经搜索了 Icinga2 项目和论坛的大部分文档,但没有找到雪茄。我很惊讶以前没有人遇到过这个问题,所以这可能是我这边的问题。
笔记2
在 Icinga IRC 频道上聊天并进行更多测试后,我发现我的问题只发生在 PostgreSQL 后端。它与 MySQL 后端按预期工作。
调试会话
调试会话 1
我收集了更多关于我的环境的信息/日志。
PostgreSQL 权限
我检查了 icinga 用户的 PostgreSQL 权限:
TABLE
权限设置为SELECT
,INSERT
,UPDATE
,DELETE
SEQUENCE
权限设置为USAGE
我什至尝试配置postgres
为用户以访问后端(icinga_ido
和icingaweb_ido
资源),但我仍然没有Comments
在 UI 中列出任何内容(在创建评论之后)。
以下是命令列出的 PosgreSQL 权限\dp
:
icinga=> \dp
Access privileges
Schema | Name | Type | Access privileges | Column access privileges
--------+-----------------------------------------------------------------+----------+---------------------------+--------------------------
public | icinga_acknowledgements | table | postgres=arwdDxt/postgres+|
| | | icinga=arwd/postgres |
public | icinga_acknowledgements_acknowledgement_id_seq | sequence | postgres=rwU/postgres +|
| | | icinga=U/postgres |
public | icinga_commands | table | postgres=arwdDxt/postgres+|
| | | icinga=arwd/postgres |
public | icinga_commands_command_id_seq | sequence | postgres=rwU/postgres +|
| | | icinga=U/postgres |
public | icinga_commenthistory | table | postgres=arwdDxt/postgres+|
| | | icinga=arwd/postgres |
public | icinga_commenthistory_commenthistory_id_seq | sequence | postgres=rwU/postgres +|
| | | icinga=U/postgres |
<truncated>
Comment
此外,当从 Icinga UI创建时,我在 PostgreSQL 日志(例如 /var/lib/pgsql/9.4/data/pg_log/postgresql-Thu.log)中没有错误。
但是,我发现尝试使用用户SEQUENCE
从pgAdmin
UI浏览时出现错误icinga
(用户没有错误postgres
):
< 2016-01-21 03:55:52.436 GMT >STATEMENT: SELECT last_value, min_value, max_value, cache_value, is_cycled, increment_by, is_called
FROM icinga_acknowledgements_acknowledgement_id_seq
但我不确定这是否有意义,因为用户icinga
只有.USAGE
SEQUENCE
比较 PostgreSQL 和 MySQL 后端的调试日志
因此,当我创建评论时,我最终比较了双方的 Icinga 调试日志(MySQL IDO 和 PostgreSQL IDO)。我可以看到,只有 MySQL 后端才有我正在寻找的 SQL 语句,它们在icinga_externalcommands
、icinga_comments
和icinga_commenthistory
表中插入数据。
我没有足够的声誉来提供超过 2 个链接(例如 pastebin)。所以这里是日志。
添加一个Comment
带有 PostgreSQL 的后端:
[2016-01-21 04:14:00 +0000] information/ExternalCommandListener: Executing external command: [1453349640] ADD_HOST_COMMENT;icinga2-web2-postgres;1;icingaadmin;dededewdwwewdew
[2016-01-21 04:14:00 +0000] debug/DbEvents: add external command history
[2016-01-21 04:14:00 +0000] notice/ExternalCommandProcessor: Creating comment for host icinga2-web2-postgres
[2016-01-21 04:14:00 +0000] information/ConfigCompiler: Compiling config file: /var/lib/icinga2/api/packages/_api/icinga2-web2-postgres-1453347670-1/conf.d/comments/icinga2-web2-postgres!icinga2-web2-postgres-1453349640-1.conf
[2016-01-21 04:14:00 +0000] information/ConfigItem: Committing config items
[2016-01-21 04:14:00 +0000] warning/ApplyRule: Apply rule 'satellite-host' (in /etc/icinga2/conf.d/satellite.conf: 29:1-29:41) for type 'Dependency' does not match anywhere!
[2016-01-21 04:14:00 +0000] warning/ApplyRule: Apply rule '' (in /etc/icinga2/conf.d/services.conf: 57:1-57:65) for type 'Service' does not match anywhere!
[2016-01-21 04:14:00 +0000] warning/ApplyRule: Apply rule '' (in /etc/icinga2/conf.d/services.conf: 65:1-65:53) for type 'Service' does not match anywhere!
[2016-01-21 04:14:00 +0000] information/ConfigItem: Instantiated 1 Comment.
[2016-01-21 04:14:00 +0000] information/ConfigItem: Triggering Start signal for config items
[2016-01-21 04:14:00 +0000] information/ConfigItem: Activated all objects.
[2016-01-21 04:14:00 +0000] notice/Comment: Added comment 'icinga2-web2-postgres!icinga2-web2-postgres-1453349640-1'.
[2016-01-21 04:14:01 +0000] debug/IdoPgsqlConnection: Query: COMMIT
[2016-01-21 04:14:01 +0000] debug/IdoPgsqlConnection: Query: BEGIN
添加一个Comment
MySQL 后端:
[2016-01-21 04:12:49 +0000] information/ExternalCommandListener: Executing external command: [1453349569] ADD_HOST_COMMENT;icinga2-web2-mysql;1;icingaadmin;yggygyyj
[2016-01-21 04:12:49 +0000] debug/DbEvents: add external command history
[2016-01-21 04:12:49 +0000] notice/ExternalCommandProcessor: Creating comment for host icinga2-web2-mysql
[2016-01-21 04:12:49 +0000] information/ConfigCompiler: Compiling config file: /var/lib/icinga2/api/packages/_api/icinga2-web2-mysql-1453347256-1/conf.d/comments/icinga2-web2-mysql!icinga2-web2-mysql-1453349569-0.conf
[2016-01-21 04:12:49 +0000] information/ConfigItem: Committing config items
[2016-01-21 04:12:49 +0000] warning/ApplyRule: Apply rule 'satellite-host' (in /etc/icinga2/conf.d/satellite.conf: 29:1-29:41) for type 'Dependency' does not match anywhere!
[2016-01-21 04:12:49 +0000] warning/ApplyRule: Apply rule '' (in /etc/icinga2/conf.d/services.conf: 57:1-57:65) for type 'Service' does not match anywhere!
[2016-01-21 04:12:49 +0000] warning/ApplyRule: Apply rule '' (in /etc/icinga2/conf.d/services.conf: 65:1-65:53) for type 'Service' does not match anywhere!
[2016-01-21 04:12:49 +0000] information/ConfigItem: Instantiated 1 Comment.
[2016-01-21 04:12:49 +0000] information/ConfigItem: Triggering Start signal for config items
[2016-01-21 04:12:49 +0000] information/ConfigItem: Activated all objects.
[2016-01-21 04:12:49 +0000] notice/Comment: Added comment 'icinga2-web2-mysql!icinga2-web2-mysql-1453349569-0'.
[2016-01-21 04:12:50 +0000] debug/IdoMysqlConnection: Query: INSERT INTO icinga_externalcommands (command_args, command_name, command_type, endpoint_object_id, entry_time, instance_id) VALUES ('icinga2-web2-mysql;1;icingaadmin;yggygyyj', 'ADD_HOST_COMMENT', '1', 1, FROM_UNIXTIME(1453349569), 1)
[2016-01-21 04:12:50 +0000] debug/IdoMysqlConnection: Query: INSERT INTO icinga_comments (author_name, comment_data, comment_source, comment_time, comment_type, endpoint_object_id, entry_time, entry_time_usec, entry_type, expires, instance_id, internal_comment_id, is_persistent, name, object_id) VALUES ('icingaadmin', 'yggygyyj', '1', FROM_UNIXTIME(1453349569), '2', 1, FROM_UNIXTIME(1453349569), '947563', '1', '0', 1, '1', '1', 'icinga2-web2-mysql!icinga2-web2-mysql-1453349569-0', 68)
[2016-01-21 04:12:50 +0000] debug/IdoMysqlConnection: Query: INSERT INTO icinga_commenthistory (author_name, comment_data, comment_source, comment_time, comment_type, endpoint_object_id, entry_time, entry_time_usec, entry_type, expires, instance_id, internal_comment_id, is_persistent, name, object_id) VALUES ('icingaadmin', 'yggygyyj', '1', FROM_UNIXTIME(1453349569), '2', 1, FROM_UNIXTIME(1453349569), '947563', '1', '0', 1, '1', '1', 'icinga2-web2-mysql!icinga2-web2-mysql-1453349569-0', 68)
[2016-01-21 04:12:50 +0000] debug/IdoMysqlConnection: Query: COMMIT
[2016-01-21 04:12:50 +0000] debug/IdoMysqlConnection: Query: BEGIN
使用 PostgreSQL 和 MySQL 后端重新启动 Icinga2
当使用 PostgreSQL 和 MySQL 后端重新启动 Icinga2 时,我有几乎相同的日志,这听起来不错!
# Icinga2 restart with PostgreSQL
[2016-01-21 05:02:11 +0000] information/Application: Received request to shut down.
[2016-01-21 05:02:11 +0000] information/Application: Shutting down...
[2016-01-21 05:02:11 +0000] information/CheckerComponent: Checker stopped.
[2016-01-21 05:02:11 +0000] information/DbConnection: Resuming IDO connection: ido-pgsql
[2016-01-21 05:02:11 +0000] information/ConfigItem: Activated all objects.
[2016-01-21 05:02:11 +0000] information/ConfigCompiler: Compiling config file: /var/lib/icinga2/modified-attributes.conf
[2016-01-21 05:02:11 +0000] information/IdoPgsqlConnection: pgSQL IDO instance id: 1 (schema version: '1.14.0')
# Icinga2 restart with MySQL
[2016-01-21 05:03:20 +0000] information/Application: Received request to shut down.
[2016-01-21 05:03:20 +0000] information/Application: Shutting down...
[2016-01-21 05:03:20 +0000] information/CheckerComponent: Checker stopped.
[2016-01-21 05:03:20 +0000] information/DbConnection: Resuming IDO connection: ido-mysql
[2016-01-21 05:03:20 +0000] information/ConfigItem: Activated all objects.
[2016-01-21 05:03:20 +0000] information/ConfigCompiler: Compiling config file: /var/lib/icinga2/modified-attributes.conf
[2016-01-21 05:03:20 +0000] information/IdoMysqlConnection: MySQL IDO instance id: 1 (schema version: '1.14.0')
包版本
- icinga2-2.4.1-1.el7.centos.x86_64
- icinga2-ido-pgsql-2.4.1-1.el7.centos.x86_64
- postgresql94-9.4.5-1PGDG.rhel7.x86_64
- postgresql94-server-9.4.5-1PGDG.rhel7.x86_64
如何重现此问题
对于那些有能力重现问题的人,您可以克隆mickael-ange/icinga2-ansible
Github 存储库(分支:Issue-No-Historical-Data-in-Icinga2-Web2-and-DB)并按照icinga2-we2-vagrant.md上的说明进行操作。如果尚未安装,则需要安装所需的工具。然后使用 librarian-ansible 安装角色依赖项。最后,我写了一段(#ido-no-historical-data-in-icinga2-web2-and-db)来重现这个问题。
提前感谢您抽出宝贵的时间阅读到这里!迈克尔