使用Icinga2 Web2在IDO DB中没有历史数据

时间:2016-01-19 11:09:24

标签: mysql postgresql ansible ido icinga

上下文

我正致力于Icinga2 Web2 IDO PostgreSQLIDO MySQL使用Ansible CentOS 7配置icinga2-ansible-web2-ui Comments

我的工作基于伟大的https://github.com/Icinga/icinga2-ansible角色。我已经分配了项目(mickael-ange / icinga2-ansible)以增加更多自动化和支持,例如IDO PostgreSQL。我正在使用PostgreSQL服务器9.4。

好吧,我最终得到一个Downtimes角色版本,可以自动安装带有IDO PostgreSQL或IDO MySQL的Icinga2 Web2 无需向导

我的问题

服务器似乎正常工作,除了我无法弄清楚如何在Icinga2 Web2界面中获取数据,例如:

    来自Overview菜单的
  • Event GridEvent Overview 来自Notifications菜单的
  • TimelineHistoryCommentsSchedule Downtimes

我可以创建Notifications/etc/icinga2/features-enabled/ido-pgsql.conf,但它们不会在UI中列出。正确处理停机时间。

我可以发送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 } 但它们也不会在用户界面中列出。当SELinux处于许可模式时,会发出通知。

我的问题是:是否有任何IDO或Icinga2 Web2配置来填充数据库,注释,停机时间等。?

我的TABLE

SELECT

注释

注1

我已经搜索过Icinga2项目和论坛的大部分文档,但我没有找到雪茄。我很惊讶之前没有人遇到这个问题,所以这可能是我身边的一个问题。

注2

在Icinga IRC频道聊天并做更多测试后,我发现我的问题只发生在PostgreSQL后端。它与MySQL后端一样正常工作。

调试会话

调试会话1

我收集了更多关于我的环境的信息/日志。

PostgreSQL权限

我检查了icinga用户的PostgreSQL权限:

  • INSERT权限设置为UPDATEDELETESEQUENCEUSAGE
  • postgres权限设置为icinga_ido

我甚至尝试将icingaweb_ido配置为用户来访问后端(Comments\dp资源),但我仍未在UI中列出任何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命令列出的PosgreSQL权限:

SEQUENCE

此外,当来自Icinga UI的creatinh pgAdmin时,我在PostgreSQL日志中没有错误(例如/var/lib/pgsql/9.4/data/pg_log/postgresql-Thu.log)。

但是,我发现尝试使用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用户只有icinga_externalcommands的{​​{1}}权限。

比较PostgreSQL和MySQL后端的调试日志

所以当我创建评论时,我最终会比较双方的Icinga调试日志(MySQL IDO和PostgreSQL IDO)。我可以看到只有MySQL后端有我正在寻找的SQL语句,他们在icinga_commentsicinga_commenthistoryComment表中插入数据。

我没有足够的声誉提供超过2个链接(例如pastebin)。所以这是日志。

在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

# 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')

使用PostgreSQL和MySQL后端重新启动Icinga2

当使用PostgreSQL和MySQL后端重新启动Icinga2时,我有几乎相同的日志听起来不错!

mickael-ange/icinga2-ansible

包版本

  • 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 - 服务器 - 9.4.5-1PGDG.rhel7.x86_64

如何重现此问题

对于那些有能力重现问题的人,您可以克隆{{1}} Github repo(分支:问题 - 无 - 历史 - 数据 - 在Icinga2-Web2和DB中)并遵循{{ 3}}。如果不是这种情况,则需要安装所需的工具。然后使用librarian-ansible安装角色依赖项。最后,我写了一个部分(#ido-no-historical-data-in-icinga2-web2-and-db)来重现这个问题。

提前感谢您花时间阅读此处! 迈克尔

1 个答案:

答案 0 :(得分:0)

最后,我弄清楚为什么历史数据没有插入到数据库中,所以我在这里回复自己。

正如documentation

中所述
  

类别可选。应写入数据库的信息类型。

因此,当我从ido-pgsql.conf配置中删除类别时。我重新启动Icinga2然后按预期将数据写入数据库。 CommentsDowntimes,我想要的一切现在都列在了用户界面。

我也删除了cleanup部分,因为它可能不是我想要的。

最终的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"
}