[collectd] [PATCH] postgresql plugin: Added "disk_usage" query.
Sebastian Harl
sh at tokkee.org
Sat Aug 16 19:40:09 CEST 2008
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 at tokkee.org>
---
contrib/collection.cgi | 10 ++++++++++
src/collectd.conf.pod | 7 ++++++-
src/postgresql.c | 3 ++-
src/postgresql_default.conf | 8 ++++++++
src/types.db | 1 +
5 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/contrib/collection.cgi b/contrib/collection.cgi
index cab7543..d3e5ccf 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 40f5027..1e71bad 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<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
diff --git a/src/postgresql.c b/src/postgresql.c
index 135a827..f326a23 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 93a29b6..9d21217 100644
--- a/src/postgresql_default.conf
+++ b/src/postgresql_default.conf
@@ -68,3 +68,11 @@
Column pg_blks tidx_hit
</Query>
+<Query disk_usage>
+ Query "SELECT pg_database_size($1);"
+
+ Param database
+
+ Column pg_db_size
+</Query>
+
diff --git a/src/types.db b/src/types.db
index fabae12..a31809d 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
--
1.6.0.rc2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20080816/565711c7/attachment-0001.pgp
More information about the collectd
mailing list