7 my %result_names = (OK => 0, WARNING => 1, CRITICAL => 2, UNKNOWN => 3);
10 my ($result_name, $msg) = @_;
12 my $code = $result_names{$result_name};
14 printf("ASTSPOOL %s - %s\n", $result_name, $msg);
19 # command-line options:
20 # c is for count. more than this number of files
21 # in the directory means a critical status. less is ok. there is no warning.
26 "d" => "/var/spool/asterisk/outgoing"
29 getopts("c:d:", \%opts);
31 opendir DIR, $opts{d} or result("UNKNOWN", "$opts{d}: $!");
32 my $count = grep { $_ ne '.' && $_ ne '..' } (readdir DIR);
35 if ($count > $opts{c}) {
36 result("CRITICAL", "$count file(s) in $opts{d}");
38 result("OK", "$count file(s) in $opts{d}");