@@ -19,6 +19,7 @@ my $t0; # use to avoid two check_pga calls within the same second.
1919 # See comment before first call of usleep.
2020
2121$node -> init;
22+ $node -> append_conf(' postgresql.conf' , ' work_mem=64kB' );
2223$node -> start;
2324
2425# ## Beginning of tests ###
@@ -56,7 +57,7 @@ SKIP: {
5657 0,
5758 [ qr / ^Service *: POSTGRES_TEMP_FILES$ / m ,
5859 qr / ^Returns *: 0 \( OK\) $ / m ,
59- qr / ^Message *: [2-3 ] tablespace\( s\)\/ database\( s\) checked$ / m ,
60+ qr / ^Message *: [2-4 ] tablespace\( s\)\/ database\( s\) checked$ / m ,
6061 ],
6162 [ qr / ^$ / ],
6263 ' basic check'
@@ -65,8 +66,8 @@ SKIP: {
6566 $t0 = [gettimeofday];
6667
6768 # unit test based on the file count => Returns OK
68- # The query generates between 17.5MB (9.4) and 11,7MB (14) of WAL
69- $node -> psql(' postgres' , ' SELECT count(*) FROM (SELECT random() * x FROM generate_series(1,1000000) AS F(x) ORDER BY 1) q ;' );
69+ # Generate one temp file of 140000 bytes
70+ $node -> psql(' postgres' , ' SELECT count(*) FROM generate_series(1,10000) ;' );
7071
7172 # The added sleep ensures that two tests are not executed within the same
7273 # seconds.
@@ -92,10 +93,10 @@ SKIP: {
9293 qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*Bpm$ / m ,
9394 qr / ^Perfdata *: postgres=[1-9][0-9]*Files warn=3 crit=4$ / m ,
9495 qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*B$ / m ,
95- qr / ^Perfdata *: template1=0Fpm $ / m ,
96- qr / ^Perfdata *: template1=0Bpm $ / m ,
97- qr / ^Perfdata *: template1=0Files warn=3 crit=4$ / m ,
98- qr / ^Perfdata *: template1=0B $ / m ,
96+ qr / ^Perfdata *: template1=[1-9][.0-9]*Fpm $ / m ,
97+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*Bpm $ / m ,
98+ qr / ^Perfdata *: template1=[1-9][0-9]*Files warn=3 crit=4$ / m ,
99+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*B $ / m ,
99100 ],
100101 [ qr / ^$ / ],
101102 ' test file count OK'
@@ -104,15 +105,15 @@ SKIP: {
104105 $t0 = [gettimeofday];
105106
106107 # unit test based on the file count => Returns WARN
107- $node -> psql(' postgres' , ' SELECT count(*) FROM (SELECT random() * x FROM generate_series(1,1000000) AS F(x) ORDER BY 1) q ;' );
108+ $node -> psql(' postgres' , ' SELECT count(*) FROM generate_series(1,10000) ;' );
108109
109110 usleep(100_000) while tv_interval($t0 ) < 1.01;
110111 $node -> command_checks_all( [
111112 ' ./check_pgactivity' , ' --service' => ' temp_files' ,
112113 ' --username' => $ENV {' USER' } || ' postgres' ,
113114 ' --format' => ' human' ,
114115 ' --dbname' => ' template1' ,
115- ' --warning' => ' 1 ' ,
116+ ' --warning' => ' 0 ' ,
116117 ' --critical' => ' 3'
117118 ],
118119 1,
@@ -121,12 +122,12 @@ SKIP: {
121122 qr / ^Message *: postgres \( .* file\( s\)\/ .*\) $ / m ,
122123 qr / ^Perfdata *: postgres=[1-9][.0-9]*Fpm$ / m ,
123124 qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*Bpm$ / m ,
124- qr / ^Perfdata *: postgres=[1-9][0-9]*Files warn=1 crit=3$ / m ,
125+ qr / ^Perfdata *: postgres=[1-9][0-9]*Files warn=0 crit=3$ / m ,
125126 qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*B$ / m ,
126- qr / ^Perfdata *: template1=0Fpm $ / m ,
127- qr / ^Perfdata *: template1=0Bpm $ / m ,
128- qr / ^Perfdata *: template1=0Files warn=1 crit=3$ / m ,
129- qr / ^Perfdata *: template1=0B $ / m ,
127+ qr / ^Perfdata *: template1=[1-9][.0-9]*Fpm $ / m ,
128+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*Bpm $ / m ,
129+ qr / ^Perfdata *: template1=[1-9][0-9]*Files warn=0 crit=3$ / m ,
130+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*B $ / m ,
130131 ],
131132 [ qr / ^$ / ],
132133 ' test file count WARN'
@@ -135,7 +136,7 @@ SKIP: {
135136 $t0 = [gettimeofday];
136137
137138 # unit test based on the file count => Returns CRIT
138- $node -> psql(' postgres' , ' SELECT count(*) FROM (SELECT random() * x FROM generate_series(1,1000000) AS F(x) ORDER BY 1) q ;' );
139+ $node -> psql(' postgres' , ' SELECT count(*) FROM generate_series(1,10000) ;' );
139140
140141 usleep(100_000) while tv_interval($t0 ) < 1.01;
141142 $node -> command_checks_all( [
@@ -144,20 +145,20 @@ SKIP: {
144145 ' --format' => ' human' ,
145146 ' --dbname' => ' template1' ,
146147 ' --warning' => ' 0' ,
147- ' --critical' => ' 1 '
148+ ' --critical' => ' 0 '
148149 ],
149150 2,
150151 [ qr / ^Service *: POSTGRES_TEMP_FILES$ / m ,
151152 qr / ^Returns *: 2 \( CRITICAL\) $ / m ,
152153 qr / ^Message *: postgres \( .* file\( s\)\/ .*\) $ / m ,
153154 qr / ^Perfdata *: postgres=[1-9][.0-9]*Fpm$ / m ,
154155 qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*Bpm$ / m ,
155- qr / ^Perfdata *: postgres=[1-9][0-9]*Files warn=0 crit=1 $ / m ,
156+ qr / ^Perfdata *: postgres=[1-9][0-9]*Files warn=0 crit=0 $ / m ,
156157 qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*B$ / m ,
157- qr / ^Perfdata *: template1=0Fpm $ / m ,
158- qr / ^Perfdata *: template1=0Bpm $ / m ,
159- qr / ^Perfdata *: template1=0Files warn=0 crit=1 $ / m ,
160- qr / ^Perfdata *: template1=0B $ / m ,
158+ qr / ^Perfdata *: template1=[1-9][.0-9]*Fpm $ / m ,
159+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*Bpm $ / m ,
160+ qr / ^Perfdata *: template1=[1-9][0-9]*Files warn=0 crit=0 $ / m ,
161+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*B $ / m ,
161162 ],
162163 [ qr / ^$ / ],
163164 ' test file count CRIT'
@@ -166,16 +167,16 @@ SKIP: {
166167 $t0 = [gettimeofday];
167168
168169 # unit test based on the file size => Returns OK
169- $node -> psql(' postgres' , ' SELECT count(*) FROM (SELECT random() * x FROM generate_series(1,1000000) AS F(x) ORDER BY 1) q ;' );
170+ $node -> psql(' postgres' , ' SELECT count(*) FROM generate_series(1,10000) ;' );
170171
171172 usleep(100_000) while tv_interval($t0 ) < 1.01;
172173 $node -> command_checks_all( [
173174 ' ./check_pgactivity' , ' --service' => ' temp_files' ,
174175 ' --username' => $ENV {' USER' } || ' postgres' ,
175176 ' --format' => ' human' ,
176177 ' --dbname' => ' template1' ,
177- ' --warning' => ' 40MB ' ,
178- ' --critical' => ' 50MB '
178+ ' --warning' => ' 200kB ' ,
179+ ' --critical' => ' 300kB '
179180 ],
180181 0,
181182 [ qr / ^Service *: POSTGRES_TEMP_FILES$ / m ,
@@ -184,11 +185,11 @@ SKIP: {
184185 qr / ^Perfdata *: postgres=[1-9][.0-9]*Fpm$ / m ,
185186 qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*Bpm$ / m ,
186187 qr / ^Perfdata *: postgres=[1-9][0-9]*Files$ / m ,
187- qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*B warn=40MB crit=50MB $ / m ,
188- qr / ^Perfdata *: template1=0Fpm $ / m ,
189- qr / ^Perfdata *: template1=0Bpm $ / m ,
190- qr / ^Perfdata *: template1=0Files $ / m ,
191- qr / ^Perfdata *: template1=0B warn=40MB crit=50MB $ / m ,
188+ qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*B warn=200kB crit=300kB $ / m ,
189+ qr / ^Perfdata *: template1=[1-9][.0-9]*Fpm $ / m ,
190+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*Bpm $ / m ,
191+ qr / ^Perfdata *: template1=[1-9][0-9]*Files $ / m ,
192+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*B warn=200kB crit=300kB $ / m ,
192193 ],
193194 [ qr / ^$ / ],
194195 ' test file size OK'
@@ -197,16 +198,16 @@ SKIP: {
197198 $t0 = [gettimeofday];
198199
199200 # unit test based on the file size => Returns WARN
200- $node -> psql(' postgres' , ' SELECT count(*) FROM (SELECT random() * x FROM generate_series(1,1000000) AS F(x) ORDER BY 1) q ;' );
201+ $node -> psql(' postgres' , ' SELECT count(*) FROM generate_series(1,10000) ;' );
201202
202203 usleep(100_000) while tv_interval($t0 ) < 1.01;
203204 $node -> command_checks_all( [
204205 ' ./check_pgactivity' , ' --service' => ' temp_files' ,
205206 ' --username' => $ENV {' USER' } || ' postgres' ,
206207 ' --format' => ' human' ,
207208 ' --dbname' => ' template1' ,
208- ' --warning' => ' 4MB ' ,
209- ' --critical' => ' 40MB '
209+ ' --warning' => ' 100kB ' ,
210+ ' --critical' => ' 200kB '
210211 ],
211212 1,
212213 [ qr / ^Service *: POSTGRES_TEMP_FILES$ / m ,
@@ -215,11 +216,11 @@ SKIP: {
215216 qr / ^Perfdata *: postgres=[1-9][.0-9]*Fpm$ / m ,
216217 qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*Bpm$ / m ,
217218 qr / ^Perfdata *: postgres=[1-9][0-9]*Files$ / m ,
218- qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*B warn=4MB crit=40MB $ / m ,
219- qr / ^Perfdata *: template1=0Fpm $ / m ,
220- qr / ^Perfdata *: template1=0Bpm $ / m ,
221- qr / ^Perfdata *: template1=0Files $ / m ,
222- qr / ^Perfdata *: template1=0B warn=4MB crit=40MB $ / m ,
219+ qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*B warn=100kB crit=200kB $ / m ,
220+ qr / ^Perfdata *: template1=[1-9][.0-9]*Fpm $ / m ,
221+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*Bpm $ / m ,
222+ qr / ^Perfdata *: template1=[1-9][0-9]*Files $ / m ,
223+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*B warn=100kB crit=200kB $ / m ,
223224 ],
224225 [ qr / ^$ / ],
225226 ' test file size WARN'
@@ -228,16 +229,16 @@ SKIP: {
228229 $t0 = [gettimeofday];
229230
230231 # unit test based on the file size => Returns CRIT
231- $node -> psql(' postgres' , ' SELECT count(*) FROM (SELECT random() * x FROM generate_series(1,1000000) AS F(x) ORDER BY 1) q ;' );
232+ $node -> psql(' postgres' , ' SELECT count(*) FROM generate_series(1,10000) ;' );
232233
233234 usleep(100_000) while tv_interval($t0 ) < 1.01;
234235 $node -> command_checks_all( [
235236 ' ./check_pgactivity' , ' --service' => ' temp_files' ,
236237 ' --username' => $ENV {' USER' } || ' postgres' ,
237238 ' --format' => ' human' ,
238239 ' --dbname' => ' template1' ,
239- ' --warning' => ' 4MB ' ,
240- ' --critical' => ' 5MB '
240+ ' --warning' => ' 50kB ' ,
241+ ' --critical' => ' 100kB '
241242 ],
242243 2,
243244 [ qr / ^Service *: POSTGRES_TEMP_FILES$ / m ,
@@ -246,11 +247,11 @@ SKIP: {
246247 qr / ^Perfdata *: postgres=[1-9][.0-9]*Fpm$ / m ,
247248 qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*Bpm$ / m ,
248249 qr / ^Perfdata *: postgres=[1-9][0-9]*Files$ / m ,
249- qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*B warn=4MB crit=5MB $ / m ,
250- qr / ^Perfdata *: template1=0Fpm $ / m ,
251- qr / ^Perfdata *: template1=0Bpm $ / m ,
252- qr / ^Perfdata *: template1=0Files $ / m ,
253- qr / ^Perfdata *: template1=0B warn=4MB crit=5MB $ / m ,
250+ qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*B warn=50kB crit=100kB $ / m ,
251+ qr / ^Perfdata *: template1=[1-9][.0-9]*Fpm $ / m ,
252+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*Bpm $ / m ,
253+ qr / ^Perfdata *: template1=[1-9][0-9]*Files $ / m ,
254+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*B warn=50kB crit=100kB $ / m ,
254255 ],
255256 [ qr / ^$ / ],
256257 ' test file count CRIT'
@@ -259,7 +260,7 @@ SKIP: {
259260 $t0 = [gettimeofday];
260261
261262 # unit test based on the file size and count => Returns OK
262- $node -> psql(' postgres' , ' SELECT count(*) FROM (SELECT random() * x FROM generate_series(1,1000000) AS F(x) ORDER BY 1) q ;' );
263+ $node -> psql(' postgres' , ' SELECT count(*) FROM generate_series(1,10000) ;' );
263264
264265 usleep(100_000) while tv_interval($t0 ) < 1.01;
265266 $node -> command_checks_all( [
@@ -278,10 +279,10 @@ SKIP: {
278279 qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*Bpm$ / m ,
279280 qr / ^Perfdata *: postgres=[1-9][0-9]*Files warn=3 crit=4$ / m ,
280281 qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*B warn=48.102MB crit=64.102MB$ / m ,
281- qr / ^Perfdata *: template1=0Fpm $ / m ,
282- qr / ^Perfdata *: template1=0Bpm $ / m ,
283- qr / ^Perfdata *: template1=0Files warn=3 crit=4$ / m ,
284- qr / ^Perfdata *: template1=0B warn=48.102MB crit=64.102MB$ / m ,
282+ qr / ^Perfdata *: template1=[1-9][.0-9]*Fpm $ / m ,
283+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*Bpm $ / m ,
284+ qr / ^Perfdata *: template1=[1-9][0-9]*Files warn=3 crit=4$ / m ,
285+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*B warn=48.102MB crit=64.102MB$ / m ,
285286 ],
286287 [ qr / ^$ / ],
287288 ' test file size and count OK '
@@ -290,16 +291,16 @@ SKIP: {
290291 $t0 = [gettimeofday];
291292
292293 # unit test based on the file size and count => Returns WARN
293- $node -> psql(' postgres' , ' SELECT count(*) FROM (SELECT random() * x FROM generate_series(1,1000000) AS F(x) ORDER BY 1) q ;' );
294+ $node -> psql(' postgres' , ' SELECT count(*) FROM generate_series(1,10000) ;' );
294295
295296 usleep(100_000) while tv_interval($t0 ) < 1.01;
296297 $node -> command_checks_all( [
297298 ' ./check_pgactivity' , ' --service' => ' temp_files' ,
298299 ' --username' => $ENV {' USER' } || ' postgres' ,
299300 ' --format' => ' human' ,
300301 ' --dbname' => ' template1' ,
301- ' --warning' => ' 1,16486kB ' ,
302- ' --critical' => ' 3,49254kB '
302+ ' --warning' => ' 1,100kB ' ,
303+ ' --critical' => ' 3,200kB '
303304 ],
304305 1,
305306 [ qr / ^Service *: POSTGRES_TEMP_FILES$ / m ,
@@ -308,11 +309,11 @@ SKIP: {
308309 qr / ^Perfdata *: postgres=[1-9][.0-9]*Fpm$ / m ,
309310 qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*Bpm$ / m ,
310311 qr / ^Perfdata *: postgres=[1-9][0-9]*Files warn=1 crit=3$ / m ,
311- qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*B warn=16.102MB crit=48.102MB $ / m ,
312- qr / ^Perfdata *: template1=0Fpm $ / m ,
313- qr / ^Perfdata *: template1=0Bpm $ / m ,
314- qr / ^Perfdata *: template1=0Files warn=1 crit=3$ / m ,
315- qr / ^Perfdata *: template1=0B warn=16.102MB crit=48.102MB $ / m ,
312+ qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*B warn=100kB crit=200kB $ / m ,
313+ qr / ^Perfdata *: template1=[1-9][.0-9]*Fpm $ / m ,
314+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*Bpm $ / m ,
315+ qr / ^Perfdata *: template1=[1-9][0-9]*Files warn=1 crit=3$ / m ,
316+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*B warn=100kB crit=200kB $ / m ,
316317 ],
317318 [ qr / ^$ / ],
318319 ' test file size and count WARN'
@@ -321,16 +322,16 @@ SKIP: {
321322 $t0 = [gettimeofday];
322323
323324 # unit test based on the file size and count => Returns CRIT
324- $node -> psql(' postgres' , ' SELECT count(*) FROM (SELECT random() * x FROM generate_series(1,1000000) AS F(x) ORDER BY 1) q ;' );
325+ $node -> psql(' postgres' , ' SELECT count(*) FROM generate_series(1,10000) ;' );
325326
326327 usleep(100_000) while tv_interval($t0 ) < 1.01;
327328 $node -> command_checks_all( [
328329 ' ./check_pgactivity' , ' --service' => ' temp_files' ,
329330 ' --username' => $ENV {' USER' } || ' postgres' ,
330331 ' --format' => ' human' ,
331332 ' --dbname' => ' template1' ,
332- ' --warning' => ' 0,0MB ' ,
333- ' --critical' => ' 1,4MB '
333+ ' --warning' => ' 0,50kB ' ,
334+ ' --critical' => ' 1,100kB '
334335 ],
335336 2,
336337 [ qr / ^Service *: POSTGRES_TEMP_FILES$ / m ,
@@ -339,11 +340,11 @@ SKIP: {
339340 qr / ^Perfdata *: postgres=[1-9][.0-9]*Fpm$ / m ,
340341 qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*Bpm$ / m ,
341342 qr / ^Perfdata *: postgres=[1-9][0-9]*Files warn=0 crit=1$ / m ,
342- qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*B warn=0B crit=4MB $ / m ,
343- qr / ^Perfdata *: template1=0Fpm $ / m ,
344- qr / ^Perfdata *: template1=0Bpm $ / m ,
345- qr / ^Perfdata *: template1=0Files warn=0 crit=1$ / m ,
346- qr / ^Perfdata *: template1=0B warn=0B crit=4MB $ / m ,
343+ qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*B warn=50kB crit=100kB $ / m ,
344+ qr / ^Perfdata *: template1=[1-9][.0-9]*Fpm $ / m ,
345+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*Bpm $ / m ,
346+ qr / ^Perfdata *: template1=[1-9][0-9]*Files warn=0 crit=1$ / m ,
347+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*B warn=50kB crit=100kB $ / m ,
347348 ],
348349 [ qr / ^$ / ],
349350 ' test file size and count CRIT'
@@ -384,7 +385,7 @@ SKIP: {
384385
385386 $node -> psql(' postgres' , q{
386387 SET temp_tablespaces TO myts2;
387- SELECT count(*) FROM (SELECT random() * x FROM generate_series(1,1000000) AS F(x) ORDER BY 1) q ;
388+ SELECT count(*) FROM generate_series(1,10000) ;
388389 } );
389390
390391 ok(-f " $tbsp2_tmp /pgsql_tmp1.1" , " temp file pgsql_tmp1.1 exists in tablespace myts2" );
@@ -409,10 +410,10 @@ SKIP: {
409410 qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*Bpm$ / m ,
410411 qr / ^Perfdata *: postgres=[1-9][0-9]*Files$ / m ,
411412 qr / ^Perfdata *: postgres=[1-9][.0-9]*[kMGTPE]*B$ / m ,
412- qr / ^Perfdata *: template1=0Fpm $ / m ,
413- qr / ^Perfdata *: template1=0Bpm $ / m ,
414- qr / ^Perfdata *: template1=0Files $ / m ,
415- qr / ^Perfdata *: template1=0B $ / m ,
413+ qr / ^Perfdata *: template1=[1-9][.0-9]*Fpm $ / m ,
414+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*Bpm $ / m ,
415+ qr / ^Perfdata *: template1=[1-9][0-9]*Files $ / m ,
416+ qr / ^Perfdata *: template1=[1-9][.0-9]*[kMGTPE]*B $ / m ,
416417 ],
417418 [ qr / ^$ / ],
418419 ' test with a tablespace'
0 commit comments