1 # Pre-defined queries of collectd's postgresql plugin.
2 #
3 # Do not edit this file. If you want to change any of the query definitions,
4 # overwrite them in collectd.conf instead.
5 #
6 # This file is distributed under the same terms as collectd itself.
8 <Query backends>
9 Statement "SELECT count(*) AS count \
10 FROM pg_stat_activity \
11 WHERE datname = $1;"
13 Param database
15 <Result>
16 Type "pg_numbackends"
17 ValuesFrom "count"
18 </Result>
19 </Query>
21 <Query transactions>
22 Statement "SELECT xact_commit, xact_rollback \
23 FROM pg_stat_database \
24 WHERE datname = $1;"
26 Param database
28 <Result>
29 Type "pg_xact"
30 InstancePrefix "commit"
31 ValuesFrom "xact_commit"
32 </Result>
33 <Result>
34 Type "pg_xact"
35 InstancePrefix "rollback"
36 ValuesFrom "xact_rollback"
37 </Result>
38 </Query>
40 <Query queries>
41 Statement "SELECT sum(n_tup_ins) AS ins, \
42 sum(n_tup_upd) AS upd, \
43 sum(n_tup_del) AS del \
44 FROM pg_stat_user_tables;"
46 <Result>
47 Type "pg_n_tup_c"
48 InstancePrefix "ins"
49 ValuesFrom "ins"
50 </Result>
51 <Result>
52 Type "pg_n_tup_c"
53 InstancePrefix "upd"
54 ValuesFrom "upd"
55 </Result>
56 <Result>
57 Type "pg_n_tup_c"
58 InstancePrefix "del"
59 ValuesFrom "del"
60 </Result>
62 MaxVersion 80299
63 </Query>
65 <Query queries>
66 Statement "SELECT sum(n_tup_ins) AS ins, \
67 sum(n_tup_upd) AS upd, \
68 sum(n_tup_del) AS del, \
69 sum(n_tup_hot_upd) AS hot_upd \
70 FROM pg_stat_user_tables;"
72 <Result>
73 Type "pg_n_tup_c"
74 InstancePrefix "ins"
75 ValuesFrom "ins"
76 </Result>
77 <Result>
78 Type "pg_n_tup_c"
79 InstancePrefix "upd"
80 ValuesFrom "upd"
81 </Result>
82 <Result>
83 Type "pg_n_tup_c"
84 InstancePrefix "del"
85 ValuesFrom "del"
86 </Result>
87 <Result>
88 Type "pg_n_tup_c"
89 InstancePrefix "hot_upd"
90 ValuesFrom "hot_upd"
91 </Result>
93 MinVersion 80300
94 </Query>
96 <Query query_plans>
97 Statement "SELECT sum(seq_scan) AS seq, \
98 sum(seq_tup_read) AS seq_tup_read, \
99 sum(idx_scan) AS idx, \
100 sum(idx_tup_fetch) AS idx_tup_fetch \
101 FROM pg_stat_user_tables;"
103 <Result>
104 Type "pg_scan"
105 InstancePrefix "seq"
106 ValuesFrom "seq"
107 </Result>
108 <Result>
109 Type "pg_scan"
110 InstancePrefix "seq_tup_read"
111 ValuesFrom "seq_tup_read"
112 </Result>
113 <Result>
114 Type "pg_scan"
115 InstancePrefix "idx"
116 ValuesFrom "idx"
117 </Result>
118 <Result>
119 Type "pg_scan"
120 InstancePrefix "idx_tup_fetch"
121 ValuesFrom "idx_tup_fetch"
122 </Result>
123 </Query>
125 <Query table_states>
126 Statement "SELECT sum(n_live_tup) AS live, sum(n_dead_tup) AS dead \
127 FROM pg_stat_user_tables;"
129 <Result>
130 Type "pg_n_tup_g"
131 InstancePrefix "live"
132 ValuesFrom "live"
133 </Result>
134 <Result>
135 Type "pg_n_tup_g"
136 InstancePrefix "dead"
137 ValuesFrom "dead"
138 </Result>
140 MinVersion 80300
141 </Query>
143 <Query disk_io>
144 Statement "SELECT coalesce(sum(heap_blks_read), 0) AS heap_read, \
145 coalesce(sum(heap_blks_hit), 0) AS heap_hit, \
146 coalesce(sum(idx_blks_read), 0) AS idx_read, \
147 coalesce(sum(idx_blks_hit), 0) AS idx_hit, \
148 coalesce(sum(toast_blks_read), 0) AS toast_read, \
149 coalesce(sum(toast_blks_hit), 0) AS toast_hit, \
150 coalesce(sum(tidx_blks_read), 0) AS tidx_read, \
151 coalesce(sum(tidx_blks_hit), 0) AS tidx_hit \
152 FROM pg_statio_user_tables;"
154 <Result>
155 Type "pg_blks"
156 InstancePrefix "heap_read"
157 ValuesFrom "heap_read"
158 </Result>
159 <Result>
160 Type "pg_blks"
161 InstancePrefix "heap_hit"
162 ValuesFrom "heap_hit"
163 </Result>
164 <Result>
165 Type "pg_blks"
166 InstancePrefix "idx_read"
167 ValuesFrom "idx_read"
168 </Result>
169 <Result>
170 Type "pg_blks"
171 InstancePrefix "idx_hit"
172 ValuesFrom "idx_hit"
173 </Result>
174 <Result>
175 Type "pg_blks"
176 InstancePrefix "toast_read"
177 ValuesFrom "toast_read"
178 </Result>
179 <Result>
180 Type "pg_blks"
181 InstancePrefix "toast_hit"
182 ValuesFrom "toast_hit"
183 </Result>
184 <Result>
185 Type "pg_blks"
186 InstancePrefix "tidx_read"
187 ValuesFrom "tidx_read"
188 </Result>
189 <Result>
190 Type "pg_blks"
191 InstancePrefix "tidx_hit"
192 ValuesFrom "tidx_hit"
193 </Result>
194 </Query>
196 <Query disk_usage>
197 Statement "SELECT pg_database_size($1) AS size;"
199 Param database
201 <Result>
202 Type pg_db_size
203 ValuesFrom "size"
204 </Result>
205 </Query>
207 # vim: set ft=config :