Code

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 cab7543f0e844d32b1c60861bd19ce893d180f97..d3e5ccf81b4e1bbbb221841a68ce2b07abcf24ee 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'],
     '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',
     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 40f5027e5be6dcf7daefe094f1f873801f5f39d1..1e71badb02712d4bc83d7d56063e253cf195025e 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.
 
 
 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
 =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",
 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
 
 
 =back
 
index 135a8270fde16a8ba71fcaf871319bf28198e536..f326a2342192a6c2c3de69126aaf0025eaaae8e0 100644 (file)
@@ -128,7 +128,8 @@ static char *def_queries[] = {
        "queries",
        "query_plans",
        "table_states",
        "queries",
        "query_plans",
        "table_states",
-       "disk_io"
+       "disk_io",
+       "disk_usage"
 };
 static int def_queries_num = STATIC_ARRAY_SIZE (def_queries);
 
 };
 static int def_queries_num = STATIC_ARRAY_SIZE (def_queries);
 
index 93a29b6ae6ac0fd08ad0da35d593b163073415a9..9d21217cecbdc5db1110775024a6558992ad28c4 100644 (file)
        Column pg_blks tidx_hit
 </Query>
 
        Column pg_blks tidx_hit
 </Query>
 
+<Query disk_usage>
+       Query "SELECT pg_database_size($1);"
+
+       Param database
+
+       Column pg_db_size
+</Query>
+
index fabae12471cd6448d36ed83b19951e3e6a9e1cd3..a31809dc2e4b6a2969301a891ccd129d72fca2d5 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
 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
 pg_n_tup_c             value:COUNTER:0:U
 pg_n_tup_g             value:GAUGE:0:U
 pg_numbackends         value:GAUGE:0:U