[英]No Historical Data in IDO DB with Icinga2 Web2
我工作的供應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
角色版本, icinga2-ansible-web2-ui
角色無需向導即可自動將Icinga2 Web2與IDO PostgreSQL或IDO MySQL一起安裝。
服務器似乎可以正常工作,但我無法弄清楚如何在Icinga2 Web2界面中獲取數據,例如:
Overview
菜單中的Comments
和Downtimes
History
菜單中的Event Grid
, Event Overview
, Notifications
, Timeline
我可以創建Comments
和Schedule 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
}
我已經在Icinga2項目和論壇的大部分文檔中進行了搜索,但找不到雪茄。 令人驚訝的是,沒有人之前遇到過這個問題,所以這可能是我這方面的問題。
在Icinga IRC頻道上聊天並進行了更多測試之后, 我發現我的問題僅發生在PostgreSQL后端 。 它可以與MySQL后端一起正常工作。
我收集了有關環境的更多信息/日志。
我檢查了icinga用戶的PostgreSQL權限:
TABLE
權限設置為SELECT
, INSERT
, UPDATE
, DELETE
SEQUENCE
權限設置為USAGE
我什至嘗試將postgres
配置為用戶以訪問后端( icinga_ido
和icingaweb_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
權限。
因此,當我創建注釋時,我最后將比較Icinga調試日志(MySQL IDO和PostgreSQL IDO)。 我可以看到,只有使用MySQL后端時,我才需要尋找SQL語句,這些語句icinga_externalcommands
數據插入icinga_externalcommands
, icinga_comments
和icinga_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')
套餐版本
對於那些有能力重現問題的人,您可以克隆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,然后按預期將數據寫入數據庫。 Comments
, Downtimes
,以及我想要的所有內容都已在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.