Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redirect or disable log #145

Closed
shayani opened this issue Jun 7, 2019 · 29 comments
Closed

Redirect or disable log #145

shayani opened this issue Jun 7, 2019 · 29 comments

Comments

@shayani
Copy link

shayani commented Jun 7, 2019

How to change the log level for libzbxpgsql, or redirect them to another file? My zabbix_server.log is too chatty and I cannot read others important log warnings.

Thanks

@shayani
Copy link
Author

shayani commented Jun 7, 2019

Really sorry. Wrong forum. I was looking to solve Apache logs on Zabbix.

@shayani shayani closed this as completed Jun 7, 2019
@shayani
Copy link
Author

shayani commented Jun 24, 2019

I'm reopening this. Also libzbxpgsql log files generated on zabbix_agentd.log are too extensive. Is there a way to redirect this to another file?

@shayani shayani reopened this Jun 24, 2019
@i-ky
Copy link
Contributor

i-ky commented Jun 24, 2019

Sounds related to #139 and #141.

@shayani
Copy link
Author

shayani commented Jun 25, 2019

I read those threads but no solution is there :(

@i-ky
Copy link
Contributor

i-ky commented Jun 25, 2019

Please provide some context. Which Zabbix version do you use? Did you compile module yourself or installed from packages?

@shayani
Copy link
Author

shayani commented Jun 25, 2019

I'm using Zabbix 4.2.3 from packages from repo.zabbix.com. I'm using Ubuntu 18.04.
libzbxpgsql I compiled myself from source codes.

Everything runs fine. Just the zabbix log file is huge. Follows example of text in log file:

...
618:20190625:070319.551 In pg_get_result(pg.starttime)
618:20190625:070319.551 In pg_scalar
618:20190625:070319.551 In pg_connect()
618:20190625:070319.551 Connecting to PostgreSQL with: dbname=postgres
618:20190625:070319.554 End of pg_connect()
618:20190625:070319.554 Executing query with 0 parameters: SELECT pg_postmaster_start_time();
618:20190625:070319.555 End of pg_scalar
618:20190625:070319.555 End of pg_get_result(pg.starttime)
618:20190625:070319.555 End of PG_STARTTIME()
618:20190625:070320.555 In PG_STAT_BGWRITER()
618:20190625:070320.555 In pg_get_result(pg.stats_reset)
618:20190625:070320.555 In pg_scalar
618:20190625:070320.555 In pg_connect()
618:20190625:070320.555 Connecting to PostgreSQL with: dbname=postgres
618:20190625:070320.560 End of pg_connect()
618:20190625:070320.560 Executing query with 0 parameters: SELECT stats_reset FROM pg_stat_bgwriter;
618:20190625:070320.572 End of pg_scalar
618:20190625:070320.572 End of pg_get_result(pg.stats_reset)
618:20190625:070320.572 End of PG_STAT_BGWRITER()
618:20190625:070320.572 In PG_UPTIME()
618:20190625:070320.572 In pg_get_result(pg.uptime)
618:20190625:070320.572 In pg_scalar
618:20190625:070320.572 In pg_connect()
618:20190625:070320.572 Connecting to PostgreSQL with: dbname=postgres
618:20190625:070320.577 End of pg_connect()
618:20190625:070320.577 Executing query with 0 parameters: SELECT EXTRACT(EPOCH FROM NOW()) - EXTRACT(EPOCH FROM pg_postmaster_start_time());
618:20190625:070320.578 End of pg_scalar
618:20190625:070320.578 End of pg_get_result(pg.uptime)
618:20190625:070320.578 End of PG_UPTIME()
...

and much more

@i-ky
Copy link
Contributor

i-ky commented Jun 25, 2019

libzbxpgsql I compiled myself from source codes.

Which version of Zabbix did you use to compile the module? I think it may help if you take Zabbix 4.2.3 sources and recompile the module.

@shayani
Copy link
Author

shayani commented Jun 25, 2019

Which version of Zabbix did you use to compile the module? I think it may help if you take Zabbix 4.2.3 sources and recompile it.

I did that. I compiled the module using the source code of Zabbix 4.2.3.

@i-ky
Copy link
Contributor

i-ky commented Jun 25, 2019

Hm, have you restarted Zabbix agents after that?

@shayani
Copy link
Author

shayani commented Jun 25, 2019

Hm, have you restarted Zabbix agents after that?

Yes. Still no good

@i-ky
Copy link
Contributor

i-ky commented Jun 25, 2019

If you have nothing to loose, you can try out #142.

@cavaliercoder
Copy link
Collaborator

The log messages you posted should only be visible in DEBUG level logging right? I agree these are too noisy as they follow the old Zabbix standard of logging stack calls which can simply be observed with a debugger. I will remove this in a future version.

@i-ky
Copy link
Contributor

i-ky commented Jun 26, 2019

@cavaliercoder, as I understand, @shayani is seeing these messages without raising log level to DEBUG. I suppose it is the same problem as reported here and reportedly fixed by just recompiling the module.

@shayani
Copy link
Author

shayani commented Jun 28, 2019

The Zabbix loglevel is on WARN and even after recompiling the module, I'm still seeing the extensive DEBUG-like info.

@i-ky
Copy link
Contributor

i-ky commented Jun 28, 2019

I can't believe this. Please double-check everything. When Zabbix agent starts it prints its version in the log. Module also prints its version and the version of Zabbix it was compiled for. You can also get the latter from the binary:

$ strings ~/libzbxpgsql.so | grep '^[[:digit:]].[[:digit:]].[[:digit:]]$'

Make sure Zabbix loads the correct binary of the module.

@shayani
Copy link
Author

shayani commented Jun 28, 2019

When I start zabbix_agentd, it shows the versions:

12995:20190628:081826.185 Starting Zabbix Agent. Zabbix 4.2.3 (revision 3685611ba5).
12995:20190628:081826.185 **** Enabled features ****
12995:20190628:081826.185 IPv6 support:          YES
12995:20190628:081826.185 TLS support:           YES
12995:20190628:081826.185 **************************
12995:20190628:081826.185 using configuration file: /etc/zabbix/zabbix_agentd.conf
12995:20190628:081826.191 starting agent module libzbxpgsql 1.1.0
12995:20190628:081826.191 using module configuration file: /etc/zabbix/libzbxpgsql.conf
12995:20190628:081826.192 loaded modules: libzbxpgsql.so

When I run the strings commands:

$ /var/lib/zabbix/modules/libzbxpgsql.so | grep '^[[:digit:]].[[:digit:]].[[:digit:]]$'
4.2.3

The file /etc/zabbix/libzbxpgsql.conf is empty.

@i-ky
Copy link
Contributor

i-ky commented Jun 28, 2019

What will pg.modver return?

@shayani
Copy link
Author

shayani commented Jun 28, 2019

libzbxpgsql 1.1.0, compiled for Zabbix 4.2.3

@i-ky
Copy link
Contributor

i-ky commented Jun 28, 2019

Could you please check this?

$ grep HAVE___VA_ARGS__ /path/to/zabbix_source_dir/include/config.h

@shayani
Copy link
Author

shayani commented Jun 28, 2019

$ grep HAVE___VA_ARGS__ /root/zabbix-4.2.3/include/config.h.in
#undef HAVE___VA_ARGS__

@i-ky
Copy link
Contributor

i-ky commented Jun 28, 2019

config.h, not config.h.in

@shayani
Copy link
Author

shayani commented Jun 28, 2019

ls: cannot access 'config.h': No such file or directory

@i-ky
Copy link
Contributor

i-ky commented Jun 28, 2019

Wait, this file is required to compile the module... It is generated automatically when you run ./configure script.

@i-ky
Copy link
Contributor

i-ky commented Jun 28, 2019

Oh, I see. This module uses Autotools too and has its own config.h which is probably included into Zabbix sources when they need it.

Try to run ./configure in Zabbix source directory, recompile the module and restart the agent. I think you will be fine after that.

@shayani
Copy link
Author

shayani commented Jun 28, 2019

I ran ./configure in zabbix-4.2.3 directory.
After that, I stoped the agent, deleted the libzbxpgsql.so file that the agent uses and recompiled the module with

./configure --with-zabbix=/root/zabbix-4.2.3
make
make install

Finally, restarted the agent. The moduled loaded fine, but still looks lots of info on the log file.

@i-ky
Copy link
Contributor

i-ky commented Jun 28, 2019

Hm... Can you check this again?

$ grep HAVE___VA_ARGS__ /root/zabbix-4.2.3/include/config.h

@shayani
Copy link
Author

shayani commented Jun 28, 2019

$ grep HAVE___VA_ARGS__ /root/zabbix-4.2.3/include/config.h                                                                                                                   
#define HAVE___VA_ARGS__ 1

@i-ky
Copy link
Contributor

i-ky commented Jun 28, 2019

OK, this is good. This is how it should be, I guess. But I can't understand why module recompilation did not pick up this change. Have you just removed .so file? Have you done make clean?

As a last resort, you can put

#define HAVE___VA_ARGS__ 1

on top of src/libzbxpgsql.h file.

@shayani
Copy link
Author

shayani commented Jun 28, 2019

Oh, I did not execute make clean.

I did it now and recompiled the module.

Now it's working fine! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants