gpt4 book ai didi

mysql - 使用Icinga2 Web2的IDO DB中没有历史数据

转载 作者:行者123 更新时间:2023-11-29 13:54:32 24 4
gpt4 key购买 nike

上下文
我正在使用Icinga2Web2设置IDO PostgreSQLIDO MySQL
我的工作是以伟大的角色为基础的。我已经将项目(mickael ange/icinga2 ansible)扩展为添加更多的自动化和支持,如IDO PostgreSQL。我正在使用PostgreSQL server 9.4。
好吧,我最终得到了一个Ansiblerole版本,它在没有向导的情况下自动安装带有IDO PostgreSQL或IDO MySQL的Icinga2 Web2。
我的问题
服务器似乎工作正常,但出现了一个例外,即我无法找出如何在Icinga2 Web2接口中获取数据,例如:
CentOS 7icinga2-ansible-web2-uiComments菜单
DowntimesOverviewEvent GridEvent Overview菜单
我可以创建NotificationsTimeline,但它们不会在UI中列出。停机时间处理正确。
我可以发送History,但它们也不会在UI中列出。当SELinux处于许可模式时,会发出通知。
我的问题是:是否有IDO或Icinga2 Web2配置来让数据库填充注释、停机时间等。。?
我的Comments

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权限:
Schedule Downtimes权限设置为 Notifications/etc/icinga2/features-enabled/ido-pgsql.confTABLESELECT
INSERT权限设置为 UPDATE
我甚至尝试将 DELETE配置为用户来访问后端( SEQUENCEUSAGE资源),但仍然没有在UI中列出任何 postgres(在创建注释之后)。
以下是 icinga_ido命令列出的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创建 icingaweb_ido时,PostgreSQL日志(例如/var/lib/pgsql/9.4/data/pg_log/PostgreSQL Thu.log)中没有错误。
但是,我发现当尝试使用 Comments用户从 \dpUI浏览 Comment时存在错误(对于 SEQUENCE用户没有错误):
< 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

但我不确定这是否有意义,因为 pgAdmin用户对 icinga只有 postgres权限。
比较PostgreSQL和MySQL后端的调试日志
因此,当我创建一个注释时,我将比较两边(MySQL IDO和postgresqlido)的Icinga调试日志。我可以看到,只有MySQL后端才有我要查找的SQL语句,它们在 icingaUSAGESEQUENCE表中插入数据。
我没有足够的声誉来提供2个以上的链接(例如pastebin)。这是原木。
在PostgreSQL后端添加 icinga_externalcommands
[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后端添加 icinga_comments
[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
如何再现这个问题
对于那些有精力重现问题的人,您可以克隆 icinga_commenthistoryGithub repo(branch:Issue-No-Historical-Data-in-Icinga2-Web2-and-DB),并按照 https://github.com/Icinga/icinga2-ansible中的说明进行操作。如果还没有安装所需的工具,则需要安装。然后与图书管理员ansible安装角色依赖关系。最后,我写了一个部分(#ido-no-historical-data-in-icinga2-web2-and-db)来重现这个问题。
提前感谢您抽空阅读到这里!
米克尔

最佳答案

最后,我找到了为什么历史数据没有被插入数据库,所以我在这里回应自己。
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"
}

关于mysql - 使用Icinga2 Web2的IDO DB中没有历史数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34875214/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com