sensu-plugins / sensu-plugins-postgres

This plugin provides native PostgreSQL instrumentation for monitoring and metrics collection, including: service health, database connectivity, database locks, replication status, database size, `pg_stat_bgwriter` metrics, and more.
http://sensu-plugins.io
MIT License
16 stars 43 forks source link

Update Ubuntu plugin to use newer version of libpq libraries - release to Bonsai #179

Open mgibson323 opened 3 years ago

mgibson323 commented 3 years ago

To help improve compatibility with latest versions of Postgres on Ubuntu the plugin should be updated with libpq 10+.

Once updated, please release to Bonsai.

(Follow up to #157)

lrosenman commented 3 years ago

Also look into having a non-nil default for -T / --timeout in all the scripts. libpq12+ breaks the scripts on libpq 12.

lrosenman commented 3 years ago

Note also, libpq is always able to talk to lower releases. I.E. this should be built with the latest libpq from the latest release from PGDG.

jspaleta commented 3 years ago

Note 1: There is no ubuntu asset. there is at best a debian platform_family asset

Note 2: ongoing work to refactor is here: https://github.com/sensu-plugins/sensu-plugins-postgres/tree/js/update-asset-libpq12

Dockerfiles controlling the asset build are found in the directory asset_build_scripts/ Debian platform_family asset build is controlled by Dockerfile.debian file and is making use of the upstream repository: http://apt.postgresql.org/pub/repos/apt/

Which I thought was best practice and would provide latest libpq.

I guess the question is.. why is the upstream repository not offering the latest libpq12? I'm not a debian user, so I may be getting the packaging commands wrong. Input from a debian user on how to ensure that the most recent libpq packages from the upstream repository are being pulled would be appreciated.

lrosenman commented 3 years ago

Debian's packages are generally behind PGDG's releases.

I personally pull from the apt repo referenced here: https://wiki.postgresql.org/wiki/Apt

lrosenman commented 3 years ago

PostgreSQL 13 is the latest release, and 14 is starting the release process, for what it's worth.

jspaleta commented 3 years ago

I didnt say debian's packages I said postgresl.org's packages FOR debian

jspaleta commented 3 years ago

This is the file in question. Please review the packaging commands being used to setup the posgresql.org apt repository and then install libpq-dev package: https://github.com/sensu-plugins/sensu-plugins-postgres/blob/js/update-asset-libpq12/asset_build_scripts/Dockerfile.debian

I have no idea why using the best practice postgresl.org repository isn't pulling a recent enough libpq version. My understanding is this is the correct source to use.

lrosenman commented 3 years ago

you want the libpq5 package:

postgres@postgresql-slave-000:/usr/lib/x86_64-linux-gnu$ dpkg-query -S pwd/libpq.so.5.13 libpq5:amd64: /usr/lib/x86_64-linux-gnu/libpq.so.5.13 postgres@postgresql-slave-000:/usr/lib/x86_64-linux-gnu$

lrosenman commented 3 years ago

sorry for not reading clearly :)

jspaleta commented 3 years ago

thanks I'll update the file and rebuild the test debian family asset in the testing bucket.

lrosenman commented 3 years ago

Can you also look into the -T / --timeout thing with nil, which breaks with the later libpq's?

jspaleta commented 3 years ago

If you can suggest I reasonable default to replace nil to test I can change it.

lrosenman commented 3 years ago

I'd say 10-30 seconds. If PostgreSQL doesn't respond in that time, there's something wrong, IMO.

jspaleta commented 3 years ago

I'll open a separate branch with that change. In the meantime can you test and see if explicit use of the --timeout option as an argument works with the next test asset?

lrosenman commented 3 years ago

using -T 10 works with the current test asset, that's how I got around it yesterday.

lrosenman commented 3 years ago

the Alpha @mgibson323 gave me is the test asset I'm using.

lrosenman commented 3 years ago

you'll have to teach me how to get my SensuGo to pull the test asset(s). Thanks in advance.

jspaleta commented 3 years ago

Okay this should have an updated asset definition that points to the new alpha.2 debian build. I've also correct the definition so that it uses platform_family filter so it should work on ubuntu without modification. https://cre-testing.s3.us-west-2.amazonaws.com/sensu-plugins-postgres/sensu-plugins-postgres.yaml

You'll want to review it first, maybe change the asset name as needed for your test, but this should load with sensuctl create -f

lrosenman commented 3 years ago

Looks good. Worked just fine.

jspaleta commented 3 years ago

okay let's get that timeout default fixed up now.
I wonder does timeout 0 disable timeout?

lrosenman commented 3 years ago

not sure. I do know that it doesn't like "" :)

lrosenman commented 3 years ago
connect_timeout
Maximum time to wait while connecting, in seconds (write as a decimal integer, e.g., 10). Zero, negative, or not specified means wait indefinitely. The minimum allowed timeout is 2 seconds, therefore a value of 1 is interpreted as 2. This timeout applies separately to each host name or IP address. For example, if you specify two hosts and connect_timeout is 5, each host will time out if no connection is made within 5 seconds, so the total time spent waiting for a connection might be up to 10 seconds.

from: https://www.postgresql.org/docs/13/libpq-connect.html

jspaleta commented 3 years ago

next test build will have 10 second timeout default for all included check executables and should error if argument to timeout is not understandable as an integer. One of the checks already had 2 default defined instead of nil and was ensuring processing of argument as integer.

lrosenman commented 3 years ago

Great! let me know when it's ready, and I'll put it in, and remove my -T 10's.

jspaleta commented 3 years ago

Okay repull that s3 bucket url and it will have an updated asset definition pointing to alpha.3 test build

lrosenman commented 3 years ago

Looks Good! removed my -T 10's and pointed to Alpha.3, and we're golden. Thanks!

lrosenman commented 3 years ago

can you let me know when it's pushed to Bonsai? -- Thanks!

jspaleta commented 3 years ago

Well pushed to bonsai is gonna be a bit longer as these changes will need review from someone else as per normal merge/release rules.

I'll keep this issue open and close it when we have a release approved through normal channels. Until then you can use the test asset. Once the official asset is releases, we'll empty out the test bucket after you confirm the swtich.

lrosenman commented 3 years ago

Thanks a ton!