Re: Monitoring disk space from within the server

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Christoph Moench-Tegeder <cmt(at)burggraben(dot)net>
Cc: Julien Rouhaud <rjuju123(at)gmail(dot)com>, Christoph Berg <myon(at)debian(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Monitoring disk space from within the server
Date: 2019-11-12 01:46:41
Message-ID: 20191112014641.GC1549@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Nov 09, 2019 at 02:33:49PM +0100, Christoph Moench-Tegeder wrote:
> "The statfs() system call first appeared in 4.4BSD." (from the statfs(2)
> manpage on FreeBSD). struct statfs differs between Linux and BSD, but
> is "close enough" for this, the fields from the original patch are
> present in both implementations.
> Solaris does not have statfs() anymore. Instead, it has a statvfs()
> which is "more or less equivalent" to the Linux statvfs(). On FreeBSD,
> using statvfs() (it's available) is rather not recommended, from the
> man page:
> The statvfs() and fstatvfs() functions fill the structure pointed
> to by buf with garbage. This garbage will occasionally bear resemblance
> to file system statistics, but portable applications must not depend on
> this.
> That's funny, as statvfs() is in our beloved POSIX.1 since at least
> 2001 - current specs:
> https://pubs.opengroup.org/onlinepubs/9699919799/functions/fstatvfs.html

Thanks for looking at that. The point of FreeBSD is interesting to
know. So this basically would leave us with the following hierarchy
to grab the data:
1) statfs()
2) statvfs()
3) Windows-specific implementation
4) Complain if nothing is present

For the free space, then we just need (f_bsize * f_bfree), and the
total is (f_blocks * f_bsize).

Any opinions?
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-11-12 01:47:44 Re: Monitoring disk space from within the server
Previous Message Mark Dilger 2019-11-12 01:42:45 Re: Missing dependency tracking for TableFunc nodes