postgresql plugin: Added "disk_usage" query.
authorSebastian Harl <sh@tokkee.org>
Sat, 16 Aug 2008 17:40:09 +0000 (19:40 +0200)
committerFlorian Forster <octo@huhu.verplant.org>
Tue, 19 Aug 2008 08:12:00 +0000 (10:12 +0200)
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 <sh@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
contrib/collection.cgi
src/collectd.conf.pod
src/postgresql.c
src/postgresql_default.conf
src/types.db

index cab7543..d3e5ccf 100755 (executable)
@@ -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',
index 40f5027..1e71bad 100644 (file)
@@ -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<disk_usage>
+
+This query collects the on-disk size of the database in bytes.
+
 =back
 
 The B<Database> block defines one PostgreSQL database for which to collect
@@ -1201,7 +1205,8 @@ B<PostgreSQL Documentation> for details.
 Specify a I<query> 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
 
index 135a827..f326a23 100644 (file)
@@ -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);
 
index 93a29b6..9d21217 100644 (file)
        Column pg_blks tidx_hit
 </Query>
 
+<Query disk_usage>
+       Query "SELECT pg_database_size($1);"
+
+       Param database
+
+       Column pg_db_size
+</Query>
+
index fabae12..a31809d 100644 (file)
@@ -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