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

Plugin(database::postgres::plugin) - mode(backends): Add an option to take into account the sum of connections from all databasess. #5350

Open
MickaelTheCat opened this issue Dec 13, 2024 · 1 comment

Comments

@MickaelTheCat
Copy link

MickaelTheCat commented Dec 13, 2024

Hello

I dont understand this mode.

It calculates a percentage per database while max_connections is defined for all databases.

An option should be added to take into account the sum of connections from all databasess.

Regards

@lucie-dubrunfaut lucie-dubrunfaut changed the title centreon/centreon-plugins database::postgres::plugin --mode=backends Plugin(database::postgres::plugin) - mode(backends): Add an option to take into account the sum of connections from all databasess. Dec 23, 2024
@lucie-dubrunfaut
Copy link
Contributor

Hello :)

If I understand correctly what is returned by the query of this plugin, we should have an extract of this form? (I don't have a dataset on which to check the query)

current mc datname
5 100 app_db
10 100 other_db

If so, I have a plugin return looking like this with --verboseflag:

OK: All client database connections are ok | 'app_db#database.clients.connected.count'=5;;;0;100'other_db#database.clients.connected.count'=10;;;0;100
Database 'app_db': 5.00% client connections limit reached (5 of max. 100)
Database 'other_db': 10.00% client connections limit reached (10 of max. 100)

So if all this is correct, I'm not sure I understand what you mean by "It calculates a percentage per database while max_connections is defined for all databases."?
Is this related to the nature of the query being made or the format of the data?
This is the query made:

SELECT
    COUNT(datid) AS current,
    (SELECT setting AS mc FROM pg_settings WHERE name = 'max_connections') AS mc,
    d.datname
FROM pg_database d
LEFT JOIN pg_stat_activity s ON (s.datid = d.oid $noidle)
GROUP BY d.datname
ORDER BY d.datname

And for the enhancement suggestion "An option should be added to take into account the sum of connections from all databasess." Do you mean something that would give a "total connections" in this style of return?

OK: All client database connections are ok | 'database.client.total.count'=15;;;0;100 'app_db#database.clients.connected.count'=5;;;0;100'other_db#database.clients.connected.count'=10;;;0;100
Database 'app_db': 5.00% client connections limit reached (5 of max. 100)
Database 'other_db': 10.00% client connections limit reached (10 of max. 100)

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

No branches or pull requests

2 participants