簡體   English   中英

使用Icinga2 Web2的IDO DB中沒有歷史數據

[英]No Historical Data in IDO DB with Icinga2 Web2

上下文

我工作的供應Icinga2 Web2IDO PostgreSQLIDO MySQL使用AnsibleCentOS 7

我的工作基於出色的https://github.com/Icinga/icinga2-ansible角色。 我已將項目(mickael-ange / icinga2-ansible)分叉,以添加更多的自動化和支持,例如IDO PostgreSQL。 我正在使用PostgreSQL服務器9.4。

好吧,我最終得到了一個icinga2-ansible-web2-ui角色版本, icinga2-ansible-web2-ui角色無需向導即可自動將Icinga2 Web2與IDO PostgreSQL或IDO MySQL一起安裝。

我的問題

服務器似乎可以正常工作,但我無法弄清楚如何在Icinga2 Web2界面中獲取數據,例如:

  • Overview菜單中的CommentsDowntimes
  • History菜單中的Event GridEvent OverviewNotificationsTimeline

我可以創建CommentsSchedule Downtimes ,但是它們不會在用戶界面中列出。 停機時間得到正確處理。

我可以發送Notifications但它們也不會在用戶界面中列出。 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權限設置為SELECTINSERTUPDATEDELETE
  • 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用戶僅對SEQUENCE具有USAGE權限。

比較PostgreSQL和MySQL后端的調試日志

因此,當我創建注釋時,我最后將比較Icinga調試日志(MySQL IDO和PostgreSQL IDO)。 我可以看到,只有使用MySQL后端時,我才需要尋找SQL語句,這些語句icinga_externalcommands數據插入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服務器,9.4.5-1PGDG.rhel7.x86_64

如何重現此問題

對於那些有能力重現問題的人,您可以克隆mickael-ange/icinga2-ansible Github存儲庫(分支:Icinga2-Web2-and-DB中的Issue-No-Historical-Data-in-Issue),並按照icinga2-we2的說明進行操作-vagrant.md 如果還不是,則需要安裝必需的工具。 然后使用庫管理員可安裝角色依賴性。 最后,我寫了一個小節(#ido-no-historical-data-in-icinga2-web2-and-db)來重現該問題。

預先感謝您抽出寶貴的時間閱讀本文! 邁克爾

最后,我弄清楚了為什么未將歷史數據插入數據庫,所以我在這里回應自己。

文檔中所述:

類別可選 應該寫入數據庫的信息類型。

因此,當我從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"
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM