Hi all, There is currently no in-core function to query the amount of available and free space in a path of PGDATA, with something like that for example: SELECT * FROM pg_get_diskspace_info('pg_xlog'); total_space | free_space -------------+------------ 4812 MB | 3925 MB (1 row)
This would be definitely useful for monitoring purposes to have a look at the disk space bloat in PGDATA, pg_xlog, or even pg_log which are usually located on different partitions. Some of my customers have requested such a thing for a couple of times, and even if you can already do it with for example plpython/os.statvfs or plperl by parsing the output of df, I am getting the feeling that we should have something in-core not directly relying on an PL language. genfile.c has also what is needed to restrict the path used, by blocking absolute paths that are not part of log_directory or PGDATA. statvfs is part of the POSIX spec and is "normally" present on modern platforms (BSD, OSX, Linux and Solaris have it as far as I saw, still there may be some strange platform without it). Windows does not have it, though we could use GetDiskFreeSpaceEx to retrieve this information (and actually this is the reason why I am only proposing to get the available/free space from a path): https://msdn.microsoft.com/en-us/library/windows/desktop/aa364937%28v=vs.85%29.aspx Another minor issue is that fsblkcnt_t is an unsigned long, and the return values should be bigint for both the free and the available space, so we could have incorrect results once we have values higher than 2^63 - 1, or disk space values higher than 8.39EB = 8.39e6TB if your prefer, but it's not like we're at this scale yet :) Thoughts? -- Michael -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers