Monitor pg_xlog size via SQL with postgres 9.4

From: Sylvain Marechal <marechal(dot)sylvain2(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Monitor pg_xlog size via SQL with postgres 9.4
Date: 2016-09-22 12:23:20
Message-ID: CAJu=pHRQUCcw2UEwZa6-guem2NmH=coav+XyTu8wMTd2sRZMBQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello all,

is there a way to monitor the size of the pg_xlog directory in SQL? The
goal is to monitor the pg_xlog file without ressorting to a 'du' like
solution that needs a direct access to the machine.

I know I can get the retained size for existing replication slots segment
in case there are some with the following query :
<<<
SELECT slot_name, database, active,
pg_xlog_location_diff(pg_current_xlog_insert_location(), restart_lsn) AS
retained_bytes FROM pg_replication_slots ;
>>>

but how could I monitor the real size of the pg_xlog directory and detect
it is growing (may be because the archive_command is becomed faulty)

I was thinking of using the last_archived_wal field of the pg_stat_archiver
table, but I am not sure it is accurate, and I do not find any postgres
stored procedure that converts the file name into an LSN (ie, a function
that does the opposite of pg_xlogfile_name())

Thanks and regards,
Sylvain

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jehan-Guillaume de Rorthais 2016-09-22 12:48:25 Re: Monitor pg_xlog size via SQL with postgres 9.4
Previous Message Tom Lane 2016-09-22 11:25:53 Re: Unstable C Function