跳转到主要内容

pg_statvfs

通过 statvfs 查询服务器文件系统容量与 inode 统计

pg_statvfs · 通过 statvfs 查询服务器文件系统容量与 inode 统计

概览

ID扩展软件包版本类别许可证编程语言
6470pg_statvfspg_statvfs1.0STATPostgreSQLC
属性可执行文件动态库需要预加载需要建扩展可迁移可信
--s-d-r否是否是是否
Superuser-only; checks server paths under data/log-directory rules. No preload. PostgreSQL 14-18 verified in PGSTY builds; upstream declares no major-version matrix.

软件包

类型仓库版本兼容的 PostgreSQL 大版本包名模式依赖
EXTPIGSTY1.019 18 17 16 15pg_statvfs-
RPMPIGSTY1.019 18 17 16 15pg_statvfs_$v-
DEBPIGSTY1.019 18 17 16 15postgresql-$v-pg-statvfs-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el8.aarch64N/APIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el9.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el9.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el10.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
el10.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d12.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d12.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d13.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
d13.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u22.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u22.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u24.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u24.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u26.x86_64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
u26.aarch64PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0PIGSTY 1.0
软件包版本平台仓库大小下载
pg_statvfs_191.0el9.x86_64pigsty20.5 KiBpg_statvfs_19-1.0-1PGSTY.el9.x86_64.rpm
pg_statvfs_191.0el9.aarch64pigsty20.4 KiBpg_statvfs_19-1.0-1PGSTY.el9.aarch64.rpm
pg_statvfs_191.0el10.x86_64pigsty20.7 KiBpg_statvfs_19-1.0-1PGSTY.el10.x86_64.rpm
pg_statvfs_191.0el10.aarch64pigsty20.8 KiBpg_statvfs_19-1.0-1PGSTY.el10.aarch64.rpm
postgresql-19-pg-statvfs1.0d12.x86_64pigsty12.0 KiBpostgresql-19-pg-statvfs_1.0-1PGSTY~bookworm_amd64.deb
postgresql-19-pg-statvfs1.0d12.aarch64pigsty11.8 KiBpostgresql-19-pg-statvfs_1.0-1PGSTY~bookworm_arm64.deb
postgresql-19-pg-statvfs1.0d13.x86_64pigsty11.9 KiBpostgresql-19-pg-statvfs_1.0-1PGSTY~trixie_amd64.deb
postgresql-19-pg-statvfs1.0d13.aarch64pigsty11.9 KiBpostgresql-19-pg-statvfs_1.0-1PGSTY~trixie_arm64.deb
postgresql-19-pg-statvfs1.0u22.x86_64pigsty12.4 KiBpostgresql-19-pg-statvfs_1.0-1PGSTY~jammy_amd64.deb
postgresql-19-pg-statvfs1.0u22.aarch64pigsty12.2 KiBpostgresql-19-pg-statvfs_1.0-1PGSTY~jammy_arm64.deb
postgresql-19-pg-statvfs1.0u24.x86_64pigsty12.5 KiBpostgresql-19-pg-statvfs_1.0-1PGSTY~noble_amd64.deb
postgresql-19-pg-statvfs1.0u24.aarch64pigsty12.3 KiBpostgresql-19-pg-statvfs_1.0-1PGSTY~noble_arm64.deb
postgresql-19-pg-statvfs1.0u26.x86_64pigsty12.4 KiBpostgresql-19-pg-statvfs_1.0-1PGSTY~resolute_amd64.deb
postgresql-19-pg-statvfs1.0u26.aarch64pigsty12.4 KiBpostgresql-19-pg-statvfs_1.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
pg_statvfs_181.0el8.x86_64pigsty20.2 KiBpg_statvfs_18-1.0-1PGSTY.el8.x86_64.rpm
pg_statvfs_181.0el8.aarch64pigsty20.2 KiBpg_statvfs_18-1.0-1PGSTY.el8.aarch64.rpm
pg_statvfs_181.0el9.x86_64pigsty20.5 KiBpg_statvfs_18-1.0-1PGSTY.el9.x86_64.rpm
pg_statvfs_181.0el9.aarch64pigsty20.4 KiBpg_statvfs_18-1.0-1PGSTY.el9.aarch64.rpm
pg_statvfs_181.0el10.x86_64pigsty20.7 KiBpg_statvfs_18-1.0-1PGSTY.el10.x86_64.rpm
pg_statvfs_181.0el10.aarch64pigsty20.8 KiBpg_statvfs_18-1.0-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-statvfs1.0d12.x86_64pigsty11.9 KiBpostgresql-18-pg-statvfs_1.0-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-statvfs1.0d12.aarch64pigsty11.8 KiBpostgresql-18-pg-statvfs_1.0-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-statvfs1.0d13.x86_64pigsty11.9 KiBpostgresql-18-pg-statvfs_1.0-1PGSTY~trixie_amd64.deb
postgresql-18-pg-statvfs1.0d13.aarch64pigsty11.9 KiBpostgresql-18-pg-statvfs_1.0-1PGSTY~trixie_arm64.deb
postgresql-18-pg-statvfs1.0u22.x86_64pigsty12.3 KiBpostgresql-18-pg-statvfs_1.0-1PGSTY~jammy_amd64.deb
postgresql-18-pg-statvfs1.0u22.aarch64pigsty12.2 KiBpostgresql-18-pg-statvfs_1.0-1PGSTY~jammy_arm64.deb
postgresql-18-pg-statvfs1.0u24.x86_64pigsty12.5 KiBpostgresql-18-pg-statvfs_1.0-1PGSTY~noble_amd64.deb
postgresql-18-pg-statvfs1.0u24.aarch64pigsty12.3 KiBpostgresql-18-pg-statvfs_1.0-1PGSTY~noble_arm64.deb
postgresql-18-pg-statvfs1.0u26.x86_64pigsty12.4 KiBpostgresql-18-pg-statvfs_1.0-1PGSTY~resolute_amd64.deb
postgresql-18-pg-statvfs1.0u26.aarch64pigsty12.4 KiBpostgresql-18-pg-statvfs_1.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
pg_statvfs_171.0el8.x86_64pigsty20.2 KiBpg_statvfs_17-1.0-1PGSTY.el8.x86_64.rpm
pg_statvfs_171.0el8.aarch64pigsty20.1 KiBpg_statvfs_17-1.0-1PGSTY.el8.aarch64.rpm
pg_statvfs_171.0el9.x86_64pigsty20.5 KiBpg_statvfs_17-1.0-1PGSTY.el9.x86_64.rpm
pg_statvfs_171.0el9.aarch64pigsty20.4 KiBpg_statvfs_17-1.0-1PGSTY.el9.aarch64.rpm
pg_statvfs_171.0el10.x86_64pigsty20.6 KiBpg_statvfs_17-1.0-1PGSTY.el10.x86_64.rpm
pg_statvfs_171.0el10.aarch64pigsty20.8 KiBpg_statvfs_17-1.0-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-statvfs1.0d12.x86_64pigsty11.9 KiBpostgresql-17-pg-statvfs_1.0-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-statvfs1.0d12.aarch64pigsty11.8 KiBpostgresql-17-pg-statvfs_1.0-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-statvfs1.0d13.x86_64pigsty11.9 KiBpostgresql-17-pg-statvfs_1.0-1PGSTY~trixie_amd64.deb
postgresql-17-pg-statvfs1.0d13.aarch64pigsty11.8 KiBpostgresql-17-pg-statvfs_1.0-1PGSTY~trixie_arm64.deb
postgresql-17-pg-statvfs1.0u22.x86_64pigsty13.0 KiBpostgresql-17-pg-statvfs_1.0-1PGSTY~jammy_amd64.deb
postgresql-17-pg-statvfs1.0u22.aarch64pigsty12.9 KiBpostgresql-17-pg-statvfs_1.0-1PGSTY~jammy_arm64.deb
postgresql-17-pg-statvfs1.0u24.x86_64pigsty12.5 KiBpostgresql-17-pg-statvfs_1.0-1PGSTY~noble_amd64.deb
postgresql-17-pg-statvfs1.0u24.aarch64pigsty12.2 KiBpostgresql-17-pg-statvfs_1.0-1PGSTY~noble_arm64.deb
postgresql-17-pg-statvfs1.0u26.x86_64pigsty12.4 KiBpostgresql-17-pg-statvfs_1.0-1PGSTY~resolute_amd64.deb
postgresql-17-pg-statvfs1.0u26.aarch64pigsty12.4 KiBpostgresql-17-pg-statvfs_1.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
pg_statvfs_161.0el8.x86_64pigsty20.2 KiBpg_statvfs_16-1.0-1PGSTY.el8.x86_64.rpm
pg_statvfs_161.0el8.aarch64pigsty20.1 KiBpg_statvfs_16-1.0-1PGSTY.el8.aarch64.rpm
pg_statvfs_161.0el9.x86_64pigsty20.4 KiBpg_statvfs_16-1.0-1PGSTY.el9.x86_64.rpm
pg_statvfs_161.0el9.aarch64pigsty20.5 KiBpg_statvfs_16-1.0-1PGSTY.el9.aarch64.rpm
pg_statvfs_161.0el10.x86_64pigsty20.6 KiBpg_statvfs_16-1.0-1PGSTY.el10.x86_64.rpm
pg_statvfs_161.0el10.aarch64pigsty20.7 KiBpg_statvfs_16-1.0-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-statvfs1.0d12.x86_64pigsty11.9 KiBpostgresql-16-pg-statvfs_1.0-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-statvfs1.0d12.aarch64pigsty11.8 KiBpostgresql-16-pg-statvfs_1.0-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-statvfs1.0d13.x86_64pigsty11.9 KiBpostgresql-16-pg-statvfs_1.0-1PGSTY~trixie_amd64.deb
postgresql-16-pg-statvfs1.0d13.aarch64pigsty11.8 KiBpostgresql-16-pg-statvfs_1.0-1PGSTY~trixie_arm64.deb
postgresql-16-pg-statvfs1.0u22.x86_64pigsty13.0 KiBpostgresql-16-pg-statvfs_1.0-1PGSTY~jammy_amd64.deb
postgresql-16-pg-statvfs1.0u22.aarch64pigsty12.9 KiBpostgresql-16-pg-statvfs_1.0-1PGSTY~jammy_arm64.deb
postgresql-16-pg-statvfs1.0u24.x86_64pigsty12.5 KiBpostgresql-16-pg-statvfs_1.0-1PGSTY~noble_amd64.deb
postgresql-16-pg-statvfs1.0u24.aarch64pigsty12.2 KiBpostgresql-16-pg-statvfs_1.0-1PGSTY~noble_arm64.deb
postgresql-16-pg-statvfs1.0u26.x86_64pigsty12.4 KiBpostgresql-16-pg-statvfs_1.0-1PGSTY~resolute_amd64.deb
postgresql-16-pg-statvfs1.0u26.aarch64pigsty12.4 KiBpostgresql-16-pg-statvfs_1.0-1PGSTY~resolute_arm64.deb
软件包版本平台仓库大小下载
pg_statvfs_151.0el8.x86_64pigsty20.2 KiBpg_statvfs_15-1.0-1PGSTY.el8.x86_64.rpm
pg_statvfs_151.0el8.aarch64pigsty20.1 KiBpg_statvfs_15-1.0-1PGSTY.el8.aarch64.rpm
pg_statvfs_151.0el9.x86_64pigsty20.5 KiBpg_statvfs_15-1.0-1PGSTY.el9.x86_64.rpm
pg_statvfs_151.0el9.aarch64pigsty20.4 KiBpg_statvfs_15-1.0-1PGSTY.el9.aarch64.rpm
pg_statvfs_151.0el10.x86_64pigsty20.6 KiBpg_statvfs_15-1.0-1PGSTY.el10.x86_64.rpm
pg_statvfs_151.0el10.aarch64pigsty20.8 KiBpg_statvfs_15-1.0-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-statvfs1.0d12.x86_64pigsty11.9 KiBpostgresql-15-pg-statvfs_1.0-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-statvfs1.0d12.aarch64pigsty11.8 KiBpostgresql-15-pg-statvfs_1.0-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-statvfs1.0d13.x86_64pigsty11.9 KiBpostgresql-15-pg-statvfs_1.0-1PGSTY~trixie_amd64.deb
postgresql-15-pg-statvfs1.0d13.aarch64pigsty11.8 KiBpostgresql-15-pg-statvfs_1.0-1PGSTY~trixie_arm64.deb
postgresql-15-pg-statvfs1.0u22.x86_64pigsty13.0 KiBpostgresql-15-pg-statvfs_1.0-1PGSTY~jammy_amd64.deb
postgresql-15-pg-statvfs1.0u22.aarch64pigsty12.9 KiBpostgresql-15-pg-statvfs_1.0-1PGSTY~jammy_arm64.deb
postgresql-15-pg-statvfs1.0u24.x86_64pigsty12.5 KiBpostgresql-15-pg-statvfs_1.0-1PGSTY~noble_amd64.deb
postgresql-15-pg-statvfs1.0u24.aarch64pigsty12.2 KiBpostgresql-15-pg-statvfs_1.0-1PGSTY~noble_arm64.deb
postgresql-15-pg-statvfs1.0u26.x86_64pigsty12.4 KiBpostgresql-15-pg-statvfs_1.0-1PGSTY~resolute_amd64.deb
postgresql-15-pg-statvfs1.0u26.aarch64pigsty12.4 KiBpostgresql-15-pg-statvfs_1.0-1PGSTY~resolute_arm64.deb

源码

github.com/michaelpq/pg_plugins/tree/ae57c1f3df697fb942f4576f873a655187193ace/pg_statvfs

pig build pkg pg_statvfs;		# build rpm/deb

安装

启用 PGDG 和 PIGSTY 仓库并更新缓存。

pig repo add pgsql -u   # add both repo and update cache

使用 pig 安装扩展。

pig install pg_statvfs;		# install by package name

pig install pg_statvfs -v 19;   # install for PG 19
pig install pg_statvfs -v 18;   # install for PG 18
pig install pg_statvfs -v 17;   # install for PG 17
pig install pg_statvfs -v 16;   # install for PG 16
pig install pg_statvfs -v 15;   # install for PG 15

在数据库中创建扩展。

CREATE EXTENSION pg_statvfs;

用法

来源:

pg_statvfs 1.0 通过服务器的 statvfs 调用提供文件系统容量、inode 可用量和挂载标志。查询对象是服务器路径所在的文件系统,不是客户端目录,也不是单个关系的大小。

核心流程

安装扩展文件后,使用超级用户会话:

CREATE EXTENSION pg_statvfs;
SELECT * FROM pg_statvfs(current_setting('data_directory'));
SELECT f_frsize * f_blocks AS total_bytes,
       f_frsize * f_bavail AS available_bytes
FROM pg_statvfs(current_setting('data_directory'));

返回结果与权限

pg_statvfs(path text) 返回一条记录。f_bsize 是首选块大小,f_frsize 是块计数的单位;f_blocks、f_bfree 和 f_bavail 分别表示总块数、空闲块数及非特权用户可用块数。f_files、f_ffree 和 f_favail 描述 inode 数量;f_fsid、f_namemax 和 flags 提供文件系统标识、名称长度限制及支持的挂载标志。

C 函数显式要求超级用户权限,并在请求操作系统前检查路径。路径不存在或不可访问时会报错。扩展自身不需要预加载或重启;控制文件允许迁移模式,但未声明为受信任扩展。上游子目录没有给出完整的 PostgreSQL 主版本兼容矩阵,操作系统支持和可返回的挂载标志也存在差异。

表格阅读器