From: Sebastian Harl Date: Sat, 16 Aug 2008 17:40:09 +0000 (+0200) Subject: postgresql plugin: Added "disk_usage" query. X-Git-Tag: collectd-4.5.0~70 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=ed365605bab34d082123289127e9d5002b4d7bc5;p=collectd.git postgresql plugin: Added "disk_usage" query. This is a new default query which collects the on-disk size of a database in bytes. A new type "pg_db_size" has been added to types.db for this purpose. The documentation in collectd.conf(5) and collection.cgi have been updated to reflect this change. Signed-off-by: Sebastian Harl Signed-off-by: Florian Forster --- diff --git a/contrib/collection.cgi b/contrib/collection.cgi index cab7543f..d3e5ccf8 100755 --- a/contrib/collection.cgi +++ b/contrib/collection.cgi @@ -1963,6 +1963,16 @@ sub load_graph_definitions 'GPRINT:pg_blks_avg:AVERAGE:%4.1lf%s Avg,', 'GPRINT:pg_blks_max:MAX:%4.1lf%s Max,', 'GPRINT:pg_blks_avg:LAST:%4.1lf%s Last'], + pg_db_size => ['DEF:pg_db_size_avg={file}:value:AVERAGE', + 'DEF:pg_db_size_min={file}:value:MIN', + 'DEF:pg_db_size_max={file}:value:MAX', + "AREA:pg_db_size_max#$HalfBlue", + "AREA:pg_db_size_min#$Canvas", + "LINE1:pg_db_size_avg#$FullBlue:Bytes", + 'GPRINT:pg_db_size_min:MIN:%4.1lf%s Min,', + 'GPRINT:pg_db_size_avg:AVERAGE:%4.1lf%s Avg,', + 'GPRINT:pg_db_size_max:MAX:%4.1lf%s Max,', + 'GPRINT:pg_db_size_avg:LAST:%4.1lf%s Last'], pg_n_tup_c => ['DEF:pg_n_tup_avg={file}:value:AVERAGE', 'DEF:pg_n_tup_min={file}:value:MIN', 'DEF:pg_n_tup_max={file}:value:MAX', diff --git a/src/collectd.conf.pod b/src/collectd.conf.pod index 40f5027e..1e71badb 100644 --- a/src/collectd.conf.pod +++ b/src/collectd.conf.pod @@ -1121,6 +1121,10 @@ This query collects the numbers of live and dead rows in the user tables. This query collects disk block access counts for user tables. +=item B + +This query collects the on-disk size of the database in bytes. + =back The B block defines one PostgreSQL database for which to collect @@ -1201,7 +1205,8 @@ B for details. Specify a I which should be executed for the database connection. This may be any of the predefined or user-defined queries. If no such option is given, it defaults to "backends", "transactions", "queries", "query_plans", -"table_states", "disk_io". Else, the specified queries are used only. +"table_states", "disk_io" and "disk_usage". Else, the specified queries are +used only. =back diff --git a/src/postgresql.c b/src/postgresql.c index 135a8270..f326a234 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -128,7 +128,8 @@ static char *def_queries[] = { "queries", "query_plans", "table_states", - "disk_io" + "disk_io", + "disk_usage" }; static int def_queries_num = STATIC_ARRAY_SIZE (def_queries); diff --git a/src/postgresql_default.conf b/src/postgresql_default.conf index 93a29b6a..9d21217c 100644 --- a/src/postgresql_default.conf +++ b/src/postgresql_default.conf @@ -68,3 +68,11 @@ Column pg_blks tidx_hit + + Query "SELECT pg_database_size($1);" + + Param database + + Column pg_db_size + + diff --git a/src/types.db b/src/types.db index fabae124..a31809dc 100644 --- a/src/types.db +++ b/src/types.db @@ -64,6 +64,7 @@ nginx_connections value:GAUGE:0:U nginx_requests value:COUNTER:0:134217728 percent percent:GAUGE:0:100.1 pg_blks value:COUNTER:0:U +pg_db_size value:GAUGE:0:U pg_n_tup_c value:COUNTER:0:U pg_n_tup_g value:GAUGE:0:U pg_numbackends value:GAUGE:0:U