zabbix-tools / libzbxpgsql

Monitor PostgreSQL with Zabbix
http://cavaliercoder.com/libzbxpgsql/
Other
157 stars 64 forks source link

Support logging from zabbix 6.4 #162

Closed rfyodorov closed 11 months ago

rfyodorov commented 11 months ago

In new versions zabbix_agent > 6.4.3 i got message: failed to find both zabbix_check_log_level() and zbx_log_level, be aware that module may spam with log messages

At result I see huge messages in zabbix_agent.log

130560:20231102:105926.175 Starting Zabbix Agent [linux]. Zabbix 6.4.8 (revision ecda9311a92).
130560:20231102:105926.175 **** Enabled features ****
130560:20231102:105926.175 IPv6 support:           NO
130560:20231102:105926.175 TLS support:            NO
130560:20231102:105926.175 **************************
130560:20231102:105926.175 using configuration file: /etc/zabbix/zabbix_agentd.conf
failed to find both zabbix_check_log_level() and zbx_log_level, be aware that module may spam with log messages130560:20231102:105926.185 using module configurat
ion file: /etc/zabbix/libzbxpgsql.conf
130560:20231102:105926.186 agent #0 started [main process]
starting agent module Zabbix 6.4.8130561:20231102:105926.187 agent #1 started [collector]
130562:20231102:105926.187 agent #2 started [listener #1]
130563:20231102:105926.188 agent #3 started [listener #2]
130564:20231102:105926.188 agent #4 started [listener #3]
130565:20231102:105926.188 agent #5 started [active checks #1]
130565:20231102:105926.204 In PG_BACKENDS_COUNT()
130565:20231102:105926.204 In pg_version
130565:20231102:105926.204 In pg_scalar
130565:20231102:105926.205 In pg_connect()
130565:20231102:105926.205 Connecting to PostgreSQL with: host=localhost port=5432 user=admin connect_timeout=10 dbname=postgres
130565:20231102:105926.217 End of pg_connect()
130565:20231102:105926.217 Executing query with 0 parameters: SELECT setting FROM pg_settings WHERE name='server_version_num'
130565:20231102:105926.221 End of pg_scalar

May be somebody can fix it?

rfyodorov commented 11 months ago

In oldes version 6.4.2 everything normal.

I tried put #define HAVE___VA_ARGS__ 1 in src/libzbxpgsql.h it doen't help.

i-ky commented 11 months ago

@rfyodorov, could you please give https://github.com/i-ky/libzbxpgsql/tree/fix-for-ZBX-22336 a try?

OrangeDog commented 11 months ago

If you're using 6.4 then you should consider migrating to zabbix_agent2 and its PostreSQL plugin. https://www.zabbix.com/documentation/current/en/manual/appendix/config/zabbix_agent2_plugins/postgresql_plugin

rfyodorov commented 11 months ago

@rfyodorov, could you please give https://github.com/i-ky/libzbxpgsql/tree/fix-for-ZBX-22336 a try?

Thank you very much @i-ky Your patch helped me.

Now looks good: 249945:20231102:143147.260 Starting Zabbix Agent [linux]. Zabbix 6.4.8 (revision ecda9311a92). 249945:20231102:143147.261 **** Enabled features **** 249945:20231102:143147.261 IPv6 support: YES 249945:20231102:143147.261 TLS support: YES 249945:20231102:143147.261 ************************** 249945:20231102:143147.261 using configuration file: /etc/zabbix/zabbix_agentd.conf 249945:20231102:143147.264 using module configuration file: /etc/zabbix/libzbxpgsql.conf 249945:20231102:143147.265 agent #0 started [main process] starting agent module Zabbix 6.4.8249946:20231102:143147.266 agent #1 started [collector] 249947:20231102:143147.266 agent #2 started [listener #1] 249948:20231102:143147.267 agent #3 started [listener #2] 249949:20231102:143147.267 agent #4 started [listener #3] 249950:20231102:143147.268 agent #5 started [active checks #1]

zabbix_agentd -t pg.modver zabbix_agentd [259285]: using module configuration file: /etc/zabbix/libzbxpgsql.conf starting agent module Zabbix 6.4.8pg.modver [s|Zabbix 6.4.8, compiled for Zabbix 6.4.8]

I had some problems with the build (used source zabbix-6.4.8): 1) It was necessary to replace the names of libraries src/libzbxpgsql.h

- #include <sysinc.h>
+ #include <zbxsysinc.h>

- #include <common.h>
+ #include <zbxcommon.h>

2) Also I added the folder "common" in variable ZABBIX_HEADERS in m4/ax_lib_zabbix.m4

            if test -f "$ZABBIX_HEADERS/include/module.h"; then
-                ZABBIX_HEADERS="$ZABBIX_HEADERS/include"
+              ZABBIX_HEADERS="$ZABBIX_HEADERS/include -I$ZABBIX_HEADERS/include/common"
i-ky commented 11 months ago

@OrangeDog, would you be interested in a PR with my fix?

OrangeDog commented 11 months ago

@i-ky I'm happy to merge most things. As I mentioned, the use-case for this project is rapidly dwindling anyway.