diff options
author | Andreas Baumann <abaumann@yahoo.com> | 2013-04-15 18:14:00 +0200 |
---|---|---|
committer | Andreas Baumann <abaumann@yahoo.com> | 2013-04-15 18:14:00 +0200 |
commit | 75d12c2bd82cccec8847703e95ceec4fef9588f2 (patch) | |
tree | 4dd74f809a99f5c6292d4f86925296c4551889dc | |
parent | 30b23afb5fca43110f09201897742c378eccb285 (diff) | |
download | pgfuse-75d12c2bd82cccec8847703e95ceec4fef9588f2.tar.gz pgfuse-75d12c2bd82cccec8847703e95ceec4fef9588f2.tar.bz2 |
added CONTRIBUTORS file
forgot to add the function.sql file
-rw-r--r-- | CONTRIBUTORS | 3 | ||||
-rw-r--r-- | function.sql | 21 |
2 files changed, 24 insertions, 0 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 0000000..c1493c7 --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1,3 @@ +Роман Бородин <maxxinpos@gmail.com> + contributed a first version of statfs total, used and free space, + adapted to drop the plperlu dependency. Changed some calculations. diff --git a/function.sql b/function.sql new file mode 100644 index 0000000..59746a1 --- /dev/null +++ b/function.sql @@ -0,0 +1,21 @@ +CREATE LANGUAGE plperlu; +CREATE OR REPLACE FUNCTION db_disk_free() + RETURNS bigint AS +$BODY$ +# Get size of data_directory partition +# this uses UNIX df(1) command + +# reported by df(1) +my $df=`df -B1 -a -P \$(psql -c "show data_directory;" -t)`; +my @df=split(/[\n\r]+/,$df); +shift @df; +for my $l (@df) { + my @a=split(/\s+/,$l); + return $a[3]; +} + +return undef; +$BODY$ + LANGUAGE 'plperlu' VOLATILE + COST 1000; +COMMENT ON FUNCTION db_disk_free() IS 'Get free disck space of data_directory partition'; |