aboutsummaryrefslogtreecommitdiff
path: root/contrib/check_frontpage
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/check_frontpage')
-rw-r--r--contrib/check_frontpage151
1 files changed, 151 insertions, 0 deletions
diff --git a/contrib/check_frontpage b/contrib/check_frontpage
new file mode 100644
index 00000000..ee958d30
--- /dev/null
+++ b/contrib/check_frontpage
@@ -0,0 +1,151 @@
+#! /usr/bin/perl -w
+#
+# $Id$
+#
+# Check that FrontPage extensions appear to be working on a specified host.
+# Currently only checks that the hit counter is not returning an error.
+#
+# Probably not a good idea to use this on a host that someone's counting
+# the hits on, so create a separate vhost for frontpage extensions testing,
+# or just install the extensions on the default/root host for your server, and
+# point it against that hostname, running it against all vhosts on a server is
+# probably rather wasteful.
+#
+# Kev Green, oRe Net (http://www.orenet.co.uk/).
+
+
+use strict;
+use lib "/usr/lib/nagios/plugins";
+use utils qw($TIMEOUT %ERRORS &print_revision &support);
+use vars qw($PROGNAME);
+use Getopt::Long;
+use LWP;
+use vars qw($opt_V $opt_h $verbose $opt_w $opt_c $opt_H);
+my ($tt,$url,$response,$stime, $etime,$warning,$critical,$mimetype,$failtype,$temp,$message);
+my $rt = 0;
+
+$PROGNAME = "check_frontpage";
+sub print_help ();
+sub print_usage ();
+
+$ENV{'PATH'}='';
+$ENV{'BASH_ENV'}='';
+$ENV{'ENV'}='';
+
+Getopt::Long::Configure('bundling');
+GetOptions
+ ("V" => \$opt_V, "version" => \$opt_V,
+ "h" => \$opt_h, "help" => \$opt_h,
+ "v" => \$verbose, "verbose" => \$verbose,
+ "w=s" => \$opt_w, "warning=s" => \$opt_w,
+ "c=s" => \$opt_c, "critical=s" => \$opt_c,
+ "H=s" => \$opt_H, "hostname=s" => \$opt_H);
+
+if ($opt_V) {
+ print_revision($PROGNAME,'$Revision$'); #'
+ exit $ERRORS{'OK'};
+}
+
+if ($opt_h) {
+ print_help();
+ exit $ERRORS{'OK'};
+}
+
+$opt_H = shift unless ($opt_H);
+print_usage() unless $opt_H;
+my $host = $1 if ($opt_H =~ m/^([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|[a-zA-Z][-a-zA-Z0-9]+(\.[a-zA-Z0-9][-a-zA-Z0-9]+)*)$/);
+print_usage() unless $host;
+
+($opt_c) || ($opt_c = shift) || ($opt_c = 120);
+if ($opt_c =~ /([0-9]+)/) {
+ $critical = $1;
+} else {
+ $critical = 10;
+}
+
+($opt_w) || ($opt_w = shift) || ($opt_w = 60);
+if ($opt_w =~ /([0-9]+)/) {
+ $warning = $1;
+} else {
+ $warning = 5;
+}
+
+# Guts go here, once we're through argument parsing and have warning and
+# critical thresholds.
+my $browser = LWP::UserAgent->new;
+
+my @urls = (
+ # This is the "Hit Counter", which continues to work if frontpage extensions
+ # are 'uninstall'ed from the site, but not when they are 'fulluninstall'ed.
+ {
+ url => "_vti_bin/fpcount.exe?Page=_borders/right.htm|Image=4",
+ mimetype => "image/gif",
+ message => "None, or broken frontpage extensions on server, or virtual site 'fulluninstall'ed?",
+ failtype => "CRITICAL"
+ },
+ # This is the "FrontPage Configuration Information" file, which is removed
+ # when you 'uninstall' the extensions from a site.
+ {
+ url => "_vti_inf.html",
+ mimetype => "text/html",
+ message => "Someone 'uninstall'ed extensions on virtual site?",
+ failtype => "WARNING"
+ }
+);
+
+print "FRONTPAGE: ";
+
+foreach $temp (@urls) {
+ $url = $temp->{'url'};
+ $mimetype = $temp->{'mimetype'};
+ $failtype = $temp->{'failtype'};
+ $message = $temp->{'message'};
+ $stime = time();
+ $response=$browser->get("http://".$host."/".$url);
+ $etime = time();
+ $tt = $etime - $stime;
+
+# If we got a server error, or unknown output type, report back as critical.
+ if ($response->status_line !~ "^200") {
+ print $message." (".$response->status_line.")\r\n";
+ exit $ERRORS{$failtype};
+ } elsif ($response->content_type !~ $mimetype) {
+ print $message." (Wrong Content-type: ".$response->content_type.")\r\n";
+ exit $ERRORS{$failtype};
+ } else {
+ # Because we're dealing with multiple URL's
+ $rt += $tt;
+ }
+
+# Decide if the response time was critical or not.
+#
+ if ($rt > $critical) {
+ print "Response time ".$rt." over critical threshold ".$critical."\r\n";
+ exit($ERRORS{'CRITICAL'});
+ } elsif ($rt > $warning) {
+ print "Response time ".$rt." over warning threshold ".$warning."\r\n";
+ exit($ERRORS{'WARNING'});
+ }
+}
+printf(" %s - %s second response time, ",$response->status_line, $rt);
+
+# If all the required URL's give the right responses quick enough, then we
+# should be okay.
+exit($ERRORS{'OK'});
+
+sub print_usage () {
+ print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>]\n";
+ exit;
+}
+
+sub print_help () {
+ print_revision($PROGNAME,'$Revision$');
+ print "Copyright (c) 2003 Kev Green\n";
+ print "\n";
+ print "FrontPage remains a copyright/trademark of Microsoft Corporation.\n";
+ print_usage();
+ print "\n";
+ print "<warn> = Unknown.\n";
+ print "<crit> = Server error from FrontPage extensions.\n\n";
+ support();
+}