5 use vars
qw($opt_V $opt_h $opt_P $opt_H $opt_w $opt_c $PROGNAME);
6 use lib "/usr/local/nagios/libexec" ;
7 use utils qw(%ERRORS &print_revision &support &usage);
9 my $remote_user = "root";
10 my $path_to_ssh = "/usr/bin/ssh";
11 my $path_to_grep = "/usr/bin/grep";
12 my $path_to_awk = "/usr/bin/awk";
16 $PROGNAME = "check_pfstate";
21 Getopt::Long::Configure('bundling');
23 ("V" => \$opt_V, "version" => \$opt_V,
24 "h" => \$opt_h, "help" => \$opt_h,
25 "H=s" => \$opt_H, "hostname=s" => \$opt_H,
26 "w=s" => \$opt_w, "warning=s" => \$opt_w,
27 "c=s" => \$opt_c, "critical=s" => \$opt_c);
30 print_revision($PROGNAME,'$Revision: 1112 $');
38 if ($opt_w =~ /(\d+)/) {
41 usage("Invalid values: $opt_w\n");
46 if ($opt_c =~ /(\d+)/) {
49 usage("Invalid values: $opt_c\n");
53 ($opt_H) || usage("Host name/address not specified\n");
54 my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);
55 ($host) || usage("Invalid host: $opt_H\n");
57 my $result = `$path_to_ssh -l $remote_user $host '/sbin/pfctl -s info' | $path_to_grep entries`;
62 print "$result PF state entries\n";
64 exit $ERRORS{'CRITICAL'} if ($result >= $crit);
65 exit $ERRORS{'WARNING'} if ($result >= $warn);
70 print_revision($PROGNAME,'$Revision: 1112 $');
71 print "Copyright (c) 2002 Jason Dixon\n\nThis plugin checks the number of state table entries on a PF-enabled OpenBSD system.\n\n";
72 print "Usage:\t-H, --hostname=<HOST> [-w, --warning=<WARNING>] [-c, --critical=<CRITICAL>]\n\n\tDefault warning is 50000 and critical is 60000.\n\n";