Closed whotopia closed 2 years ago
I noted updated change to line in pgsql.pm from
$sth = $dbh->prepare("SELECT SUM(pg_database_size(datid)) AS total_size FROM pg_stat_database");
to
$sth = $dbh->prepare("SELECT SUM(pg_database_size(datid)) AS total_size FROM pg_stat_database WHERE datid>0");
This fixed the problem for me.
Yes, you're right, this was a bug and has been already addressed in #384. You might want to apply the small patch to fix this problem.
Thanks for your feedback!
I have tested the new pgsql module. It works great when using postgres admin user. However, I created a postgres user with limited access specifically for monitoring.
CREATE USER aos_monitor WITH PASSWORD 'XXXX' INHERIT; GRANT pg_monitor TO aos_monitor;
With this user, the tsize operation fails during SELECT SUM(pg_database_size(datid)) AS total_size FROM pg_stat_database;
as postgres user, this returns valid data. However as a user with only pg_monitor access the SQL query returns
ERROR: database with OID 0 does not exist
Reviewing all of the $dbh-prepare() calls in /usr/lib/monitorix/pgsql.pm, it looks to me like the pg_monitor constraint should be sufficient in postgres to get all the data Monitorix needs.
So, either, I guess I'm either reporting a bug here, or requesting that someone share what the minimal permissions are that need to be assigned to postgres pgsql monitorix user for all query operations in pgsql.pm to work?
Thanks!