【问题标题】:No Historical Data in IDO DB with Icinga2 Web2使用 Icinga2 Web2 在 IDO DB 中没有历史数据
【发布时间】:2016-01-19 11:09:24
【问题描述】:

上下文

我正在使用Ansible 上的CentOS 7 配置Icinga2 Web2IDO PostgreSQLIDO MySQL

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

好吧,我最终得到了一个 icinga2-ansible-web2-ui 角色版本,它自动无需向导安装 Icinga2 Web2 和 IDO PostgreSQL 或 IDO MySQL。

我的问题

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

  • CommentsDowntimes 来自 Overview 菜单
  • Event Grid, Event Overview, Notifications, Timeline 来自 History 菜单

我可以创建 CommentsSchedule 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_idoicingaweb_ido 资源),但我仍然没有在 UI 中列出任何Comments(在创建评论之后)。

以下是\dp 命令列出的 PosgreSQL 权限:

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>

此外,当从 Icinga UI 创建 Comment 时,我在 PostgreSQL 日志(例如 /var/lib/pgsql/9.4/data/pg_log/postgresql-Thu.log)中没有错误。

但是,我发现尝试使用icinga 用户从pgAdmin UI 浏览SEQUENCE 时出现错误(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 用户只有USAGESEQUENCE 的权限。

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

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

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

使用 PostgreSQL 后端添加 Comment

[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

使用 MySQL 后端添加 Comment

[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 repo(分支:Issue-No-Historical-Data-in-Icinga2-Web2-and-DB)并按照icinga2-we2-vagrant.md 的说明进行操作。如果尚未安装,则需要安装所需的工具。然后使用 librarian-ansible 安装角色依赖项。最后,我写了一段(#ido-no-historical-data-in-icinga2-web2-and-db)来重现这个问题。

提前感谢您抽出宝贵的时间阅读到这里! 迈克尔

【问题讨论】:

    标签: mysql postgresql ansible ido icinga


    【解决方案1】:

    终于搞清楚了为什么历史数据没有插入到数据库中,所以我在这里回应自己。

    documentation中所述:

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

    所以当我从ido-pgsql.conf 配置中删除类别时。我重新启动 Icinga2 然后数据按预期写入数据库。 CommentsDowntimes,好吧,我想要的一切现在都在 UI 中列出。

    我还删除了 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"
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-05
      • 1970-01-01
      • 1970-01-01
      • 2016-12-07
      • 2018-05-13
      相关资源
      最近更新 更多