1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!perl
## Test the "disk_space" action
use strict;
use warnings;
use Data::Dumper;
use DBI;
use Test::More qw(no_plan);
END { diag "Don't forget to make a plan!" }
use lib 't','.';
use CP_Testing;
use vars qw/$dbh $result $t $host $dbname/;
my $cp = CP_Testing->new( {default_action => 'disk_space'} );
$dbh = $cp->test_database_handle();
$dbh->{AutoCommit} = 1;
$dbname = $cp->get_dbname;
$host = $cp->get_host();
my $label = q{POSTGRES_DISK_SPACE};
my $S = q{Action 'disk_space'};
$t = qq{$S identifies self};
$result = $cp->run('-w 999z');
like($result, qr{$label}, $t);
$t = qq{$S identifies host};
like ($result, qr{host:$host}, $t);
$t = qq{$S reports file system};
like ($result, qr{FS /.*? mounted on /.*? is using }, $t);
$t = qq{$S reports usage};
like ($result, qr{ is using \d*\.\d+ [A-Z]B of \d*\.\d+ [A-Z]B}, $t);
$t = qq{$S notes plenty of available space};
like ($result, qr{$label OK}, $t);
$t = qq{$S flags insufficient space};
like ($cp->run('-w 1b'), qr{$label WARNING:}, $t);
$t = qq{$S reports MRTG output};
like ($cp->run('--output=mrtg'), qr{\A\d+\n0\n\n/.*\n}, $t);
|