diff options
| author | Stanley Hopcroft <stanleyhopcroft@users.sourceforge.net> | 2005-01-27 04:46:08 +0000 |
|---|---|---|
| committer | Stanley Hopcroft <stanleyhopcroft@users.sourceforge.net> | 2005-01-27 04:46:08 +0000 |
| commit | fce1f09f770fc5bbc6d323865af709ff515c803c (patch) | |
| tree | 1e997a0bc1ace6217cc0dab87b65de52bca8be20 /contrib/check_pfstate | |
| parent | ccf789e017547e1f71b5945b2e1d85ce5b9cb8e4 (diff) | |
| download | monitoring-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_pfstate | 75 |
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 | |||
| 3 | use strict; | ||
| 4 | use Getopt::Long; | ||
| 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); | ||
| 8 | |||
| 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"; | ||
| 13 | my $warn = 50000; | ||
| 14 | my $crit = 60000; | ||
| 15 | |||
| 16 | $PROGNAME = "check_pfstate"; | ||
| 17 | $ENV{'PATH'}=''; | ||
| 18 | $ENV{'BASH_ENV'}=''; | ||
| 19 | $ENV{'ENV'}=''; | ||
| 20 | |||
| 21 | Getopt::Long::Configure('bundling'); | ||
| 22 | GetOptions | ||
| 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 | |||
| 29 | if ($opt_V) { | ||
| 30 | print_revision($PROGNAME,'$Revision$'); | ||
| 31 | exit $ERRORS{'OK'}; | ||
| 32 | } | ||
| 33 | if ($opt_h) { | ||
| 34 | print_help(); | ||
| 35 | exit $ERRORS{'OK'}; | ||
| 36 | } | ||
| 37 | if ($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 | } | ||
| 45 | if ($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"); | ||
| 54 | my $host = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/); | ||
| 55 | ($host) || usage("Invalid host: $opt_H\n"); | ||
| 56 | |||
| 57 | my $result = `$path_to_ssh -l $remote_user $host '/sbin/pfctl -s info' | $path_to_grep entries`; | ||
| 58 | chomp $result; | ||
| 59 | $result =~ /(\d+)/; | ||
| 60 | $result = $1; | ||
| 61 | |||
| 62 | print "$result PF state entries\n"; | ||
| 63 | |||
| 64 | exit $ERRORS{'CRITICAL'} if ($result >= $crit); | ||
| 65 | exit $ERRORS{'WARNING'} if ($result >= $warn); | ||
| 66 | exit $ERRORS{'OK'}; | ||
| 67 | |||
| 68 | |||
| 69 | sub 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 | |||
