zabbix-tools / libzbxpgsql

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

Replace zabbix_log() macro provided by Zabbix #142

Closed i-ky closed 2 years ago

i-ky commented 5 years ago

Our own macro will ensure log level check across all versions of Zabbix.

Some background story. zabbix_log() has always been a wrapper macro for __zbx_zabbix_log() function. It takes the severity level of a log message, format string and variable number of arguments. Depending on the severity of the log message and logging level currently in action, log message may or may not end up in the actual Zabbix log. In older versions of Zabbix, log level check was performed by the __zbx_zabbix_log() function, but after ZBX-10889 the situation has changed. Depending on how Zabbix was compiled, the check will be performed by the __zbx_zabbix_log() function like before or by the zabbix_log() macro itself. What this effectively means is that loadable module compiled with older zabbix_log() macro definition and loaded into newer Zabbix binary may end up with no log level check whatsoever when calling __zbx_zabbix_log() function.

In order to provide a guarantee that module can be compiled with any version of Zabbix headers and then used with any other version of Zabbix, I decided to implement an independent zabbix_log() macro which will check log level on its own. Again, runtime linking is used to get access to current log level settings, because API has changed in ZBX-10889. Before runtime linking is complete zabbix_log() cannot be used, therefore I've replaced it with printf() and fprintf(stderr, ...). Zabbix redirects stdout and stderr to the log file anyway.

For a test, I've compiled the module with good old 3.2 and latest trunk and then successfully loaded it into oldish 3.4 and trunk in all possible combinations. However, I'm not using this module or PostgreSQL in my everyday life, so some more in-depth testing may be required.

Hopefully, this will be enough to craft a single binary package compatible with all more or less current versions of Zabbix (despite binary compatibility not being officially supported).

biertie commented 5 years ago

Hello,

Can someone check and approve this patch? :-) We are waiting for it. Sadly enough, not enough C experience here.

Bert

i-ky commented 5 years ago

@biertie, you don't need to be an experienced C programmer. If you are using this module and can test this branch with various versions of Zabbix, you can provide quite useful feedback.

OrangeDog commented 4 years ago

@cavaliercoder can this be merged? And then ideally can you sort out being able to release it?

dodok1 commented 4 years ago

I had to merge this PR, because after using compiled master with ZBX 4.4.4, I'd end up with very verbose module filling log partition quickly.

i-ky commented 3 years ago

There is another ABI break on the horizon: https://github.com/cavaliercoder/zabbix-module-sockets/issues/7#issuecomment-881687852

Is anyone interested in me updating this pull request?

OrangeDog commented 3 years ago

@i-ky I'd be interested. Even better if you can sort out the release build and either get control from @cavaliercoder or fork it. I tried a while ago, but what's in this repo is not what produced the last releases.

i-ky commented 3 years ago

I've not seen @cavaliercoder responding to mentions on GitHub for some time now. Can someone contact him on Twitter or LinkedIn? I use neither of them.

I don't think I'm the best person to "get control", because I don't use Zabbix myself.

i-ky commented 3 years ago

And by the way, if you haven't already, please consider voting for ZBXNEXT-5189.

cavaliercoder commented 3 years ago

Hey friends. I apologise for not maintaining this project. It's one of things where I intend to give it a few days of focus every now and then, but life keeps getting in the way. I haven't worked with Zabbix in years, so the relevance for me has long faded. I get so much email about my OSS projects, it's hard to pay attention to and sometimes pings like this get missed.

I will gladly hand over control to someone. The beauty of open source is, you can just take it. Please feel free to fork this, publish it around the place, etc. with the appropriate license attribution.

i-ky commented 3 years ago

@cavaliercoder, happy to hear you!

Forking is not ideal in my opinion. I bet there are lots of links to this repo all over the Internet and it will take forever to update them all. Forks will cause confusion.

I am a Collaborator in a couple of repos and it is sufficient most of the time, but I still have to ask repository's owner to intervene if repo's settings need adjustment (for CI and whatnot).

I have not used this feature, but maybe creating an Organization and transferring all of your Zabbix legacy (in a good sense!) there will be the best way for you to let it go.

OrangeDog commented 3 years ago

I'll happily hold some keys in the absence of anyone else, but I'm probably not of much use at the moment. At least I do actually use this project.

i-ky commented 3 years ago

@cavaliercoder, can you make @OrangeDog a collaborator?

i-ky commented 2 years ago

@OrangeDog, as I can see, you are a collaborator now. Can you merge this PR?