summaryrefslogtreecommitdiffstats
path: root/contrib/check_pfstate
diff options
context:
space:
mode:
authorStanley Hopcroft <stanleyhopcroft@users.sourceforge.net>2005-01-27 04:46:08 +0000
committerStanley Hopcroft <stanleyhopcroft@users.sourceforge.net>2005-01-27 04:46:08 +0000
commitfce1f09f770fc5bbc6d323865af709ff515c803c (patch)
tree1e997a0bc1ace6217cc0dab87b65de52bca8be20 /contrib/check_pfstate
parentccf789e017547e1f71b5945b2e1d85ce5b9cb8e4 (diff)
downloadmonitoring-plugins-fce1f09f770fc5bbc6d323865af709ff515c803c.tar.gz
New /contrib plugin
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1112 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'contrib/check_pfstate')
-rw-r--r--contrib/check_pfstate75
1 files changed, 75 insertions, 0 deletions
diff --git a/contrib/check_pfstate b/contrib/check_pfstate
new file mode 100644
index 00000000..6fe0d9b0
--- /dev/null
+++ b/contrib/check_pfstate
@@ -0,0 +1,75 @@
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$');
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$');
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