Monitor pg_xlog size via SQL with postgres 9.4 - Mailing list pgsql-general

From Sylvain Marechal
Subject Monitor pg_xlog size via SQL with postgres 9.4
Date
Msg-id CAJu=pHRQUCcw2UEwZa6-guem2NmH=coav+XyTu8wMTd2sRZMBQ@mail.gmail.com
Whole thread Raw
Responses Re: Monitor pg_xlog size via SQL with postgres 9.4  (Jehan-Guillaume de Rorthais <ioguix@free.fr>)
Re: Monitor pg_xlog size via SQL with postgres 9.4  (Francisco Olarte <folarte@peoplecall.com>)
Re: Monitor pg_xlog size via SQL with postgres 9.4  (hubert depesz lubaczewski <depesz@depesz.com>)
List 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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Unstable C Function
Next
From: Jehan-Guillaume de Rorthais
Date:
Subject: Re: Monitor pg_xlog size via SQL with postgres 9.4