summaryrefslogtreecommitdiffstats
path: root/contrib/check_frontpage
diff options
context:
space:
mode:
authorStanley Hopcroft <stanleyhopcroft@users.sourceforge.net>2005-01-27 04:46:08 (GMT)
committerStanley Hopcroft <stanleyhopcroft@users.sourceforge.net>2005-01-27 04:46:08 (GMT)
commitfce1f09f770fc5bbc6d323865af709ff515c803c (patch)
tree1e997a0bc1ace6217cc0dab87b65de52bca8be20 /contrib/check_frontpage
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_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 0000000..ee958d3
--- /dev/null
+++ b/contrib/check_frontpage
@@ -0,0 +1,151 @@
1#! /usr/bin/perl -w
2#
3# $Id$
4#
5# Check that FrontPage extensions appear to be working on a specified host.
6# Currently only checks that the hit counter is not returning an error.
7#
8# Probably not a good idea to use this on a host that someone's counting
9# the hits on, so create a separate vhost for frontpage extensions testing,
10# or just install the extensions on the default/root host for your server, and
11# point it against that hostname, running it against all vhosts on a server is
12# probably rather wasteful.
13#
14# Kev Green, oRe Net (http://www.orenet.co.uk/).
15
16
17use strict;
18use lib "/usr/lib/nagios/plugins";
19use utils qw($TIMEOUT %ERRORS &print_revision &support);
20use vars qw($PROGNAME);
21use Getopt::Long;
22use LWP;
23use vars qw($opt_V $opt_h $verbose $opt_w $opt_c $opt_H);
24my ($tt,$url,$response,$stime, $etime,$warning,$critical,$mimetype,$failtype,$temp,$message);
25my $rt = 0;
26
27$PROGNAME = "check_frontpage";
28sub print_help ();
29sub print_usage ();
30
31$ENV{'PATH'}='';
32$ENV{'BASH_ENV'}='';
33$ENV{'ENV'}='';
34
35Getopt::Long::Configure('bundling');
36GetOptions
37 ("V" => \$opt_V, "version" => \$opt_V,
38 "h" => \$opt_h, "help" => \$opt_h,
39 "v" => \$verbose, "verbose" => \$verbose,
40 "w=s" => \$opt_w, "warning=s" => \$opt_w,
41 "c=s" => \$opt_c, "critical=s" => \$opt_c,
42 "H=s" => \$opt_H, "hostname=s" => \$opt_H);
43
44if ($opt_V) {
45 print_revision($PROGNAME,'$Revision$'); #'
46 exit $ERRORS{'OK'};
47}
48
49if ($opt_h) {
50 print_help();
51 exit $ERRORS{'OK'};
52}
53
54$opt_H = shift unless ($opt_H);
55print_usage() unless $opt_H;
56my $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]+)*)$/);
57print_usage() unless $host;
58
59($opt_c) || ($opt_c = shift) || ($opt_c = 120);
60if ($opt_c =~ /([0-9]+)/) {
61 $critical = $1;
62} else {
63 $critical = 10;
64}
65
66($opt_w) || ($opt_w = shift) || ($opt_w = 60);
67if ($opt_w =~ /([0-9]+)/) {
68 $warning = $1;
69} else {
70 $warning = 5;
71}
72
73# Guts go here, once we're through argument parsing and have warning and
74# critical thresholds.
75my $browser = LWP::UserAgent->new;
76
77my @urls = (
78 # This is the "Hit Counter", which continues to work if frontpage extensions
79 # are 'uninstall'ed from the site, but not when they are 'fulluninstall'ed.
80 {
81 url => "_vti_bin/fpcount.exe?Page=_borders/right.htm|Image=4",
82 mimetype => "image/gif",
83 message => "None, or broken frontpage extensions on server, or virtual site 'fulluninstall'ed?",
84 failtype => "CRITICAL"
85 },
86 # This is the "FrontPage Configuration Information" file, which is removed
87 # when you 'uninstall' the extensions from a site.
88 {
89 url => "_vti_inf.html",
90 mimetype => "text/html",
91 message => "Someone 'uninstall'ed extensions on virtual site?",
92 failtype => "WARNING"
93 }
94);
95
96print "FRONTPAGE: ";
97
98foreach $temp (@urls) {
99 $url = $temp->{'url'};
100 $mimetype = $temp->{'mimetype'};
101 $failtype = $temp->{'failtype'};
102 $message = $temp->{'message'};
103 $stime = time();
104 $response=$browser->get("http://".$host."/".$url);
105 $etime = time();
106 $tt = $etime - $stime;
107
108# If we got a server error, or unknown output type, report back as critical.
109 if ($response->status_line !~ "^200") {
110 print $message." (".$response->status_line.")\r\n";
111 exit $ERRORS{$failtype};
112 } elsif ($response->content_type !~ $mimetype) {
113 print $message." (Wrong Content-type: ".$response->content_type.")\r\n";
114 exit $ERRORS{$failtype};
115 } else {
116 # Because we're dealing with multiple URL's
117 $rt += $tt;
118 }
119
120# Decide if the response time was critical or not.
121#
122 if ($rt > $critical) {
123 print "Response time ".$rt." over critical threshold ".$critical."\r\n";
124 exit($ERRORS{'CRITICAL'});
125 } elsif ($rt > $warning) {
126 print "Response time ".$rt." over warning threshold ".$warning."\r\n";
127 exit($ERRORS{'WARNING'});
128 }
129}
130printf(" %s - %s second response time, ",$response->status_line, $rt);
131
132# If all the required URL's give the right responses quick enough, then we
133# should be okay.
134exit($ERRORS{'OK'});
135
136sub print_usage () {
137 print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>]\n";
138 exit;
139}
140
141sub print_help () {
142 print_revision($PROGNAME,'$Revision$');
143 print "Copyright (c) 2003 Kev Green\n";
144 print "\n";
145 print "FrontPage remains a copyright/trademark of Microsoft Corporation.\n";
146 print_usage();
147 print "\n";
148 print "<warn> = Unknown.\n";
149 print "<crit> = Server error from FrontPage extensions.\n\n";
150 support();
151}