summaryrefslogtreecommitdiffstats
path: root/contrib/check_pfstate
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/check_pfstate')
-rw-r--r--contrib/check_pfstate75
1 files changed, 0 insertions, 75 deletions
diff --git a/contrib/check_pfstate b/contrib/check_pfstate
deleted file mode 100644
index 57dde3f..0000000
--- a/contrib/check_pfstate
+++ /dev/null
@@ -1,75 +0,0 @@
1#!/usr/bin/perl
2
3use strict;
4use Getopt::Long;
5use vars qw($opt_V $opt_h $opt_P $opt_H $opt_w $opt_c $PROGNAME);
6use lib "/usr/local/nagios/libexec" ;
7use utils qw(%ERRORS &print_revision &support &usage);
8
9my $remote_user = "root";
10my $path_to_ssh = "/usr/bin/ssh";
11my $path_to_grep = "/usr/bin/grep";
12my $path_to_awk = "/usr/bin/awk";
13my $warn = 50000;
14my $crit = 60000;
15
16$PROGNAME = "check_pfstate";
17$ENV{'PATH'}='';
18$ENV{'BASH_ENV'}='';
19$ENV{'ENV'}='';
20
21Getopt::Long::Configure('bundling');
22GetOptions
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);
28
29if ($opt_V) {
30 print_revision($PROGNAME,'$Revision: 1112 $');
31 exit $ERRORS{'OK'};
32}
33if ($opt_h) {
34 print_help();
35 exit $ERRORS{'OK'};
36}
37if ($opt_w) {
38 if ($opt_w =~ /(\d+)/) {
39 $warn = $1;
40 } else {
41 usage("Invalid values: $opt_w\n");
42 exit $ERRORS{'OK'};
43 }
44}
45if ($opt_c) {
46 if ($opt_c =~ /(\d+)/) {
47 $crit = $1;
48 } else {
49 usage("Invalid values: $opt_c\n");
50 exit $ERRORS{'OK'};
51 }
52}
53($opt_H) || usage("Host name/address not specified\n");
54my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/);
55($host) || usage("Invalid host: $opt_H\n");
56
57my $result = `$path_to_ssh -l $remote_user $host '/sbin/pfctl -s info' | $path_to_grep entries`;
58chomp $result;
59$result =~ /(\d+)/;
60$result = $1;
61
62print "$result PF state entries\n";
63
64exit $ERRORS{'CRITICAL'} if ($result >= $crit);
65exit $ERRORS{'WARNING'} if ($result >= $warn);
66exit $ERRORS{'OK'};
67
68
69sub print_help {
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";
73 support();
74}
75