/[svn]/nagios/tags/jaxtr.com/libexec/check_webapp_jaxtr.pl
ViewVC logotype

Contents of /nagios/tags/jaxtr.com/libexec/check_webapp_jaxtr.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2138 - (show annotations)
Sat Apr 25 18:01:17 2009 UTC (10 years, 7 months ago) by evoltech
File MIME type: text/plain
File size: 3281 byte(s)
Error occurred while calculating annotation data.
This directory must have gotten lost from the repo when frenzy did the rm -rf, adding it again
1 #!/usr/bin/perl -w
2 use warnings;
3 use strict;
4 use lib '/usr/lib/nagios/plugins';
5 use utils qw($TIMEOUT %ERRORS);
6 use Getopt::Long;
7 Getopt::Long::Configure('bundling');
8 use WWW::Mechanize;
9
10 my $version=0.01;
11
12 #defined in utils.pm
13 #my %ERRORS = ('UNKNOWN' , '-1',
14 # 'OK' , '0',
15 # 'WARNING', '1',
16 # 'CRITICAL', '2');
17 our ($opt_V, $opt_h, $opt_H, $opt_p, $verbose);
18 GetOptions
19 ("V" => \$opt_V, "version" => \$opt_V,
20 "h" => \$opt_h, "help" => \$opt_h,
21 "H=s" => \$opt_H, "host=s" => \$opt_H,
22 "p=i" => \$opt_p, "port=i" => \$opt_p,
23 "v" => \$verbose, "verbose" => \$verbose);
24 #
25 # handle the verbose stuff first
26 #
27 if ($opt_V) {
28 print "\n";
29 print "check_webapp_jaxtr nagios plugin version $version\n";
30 print "\n";
31 print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n";
32 print "copies of the plugins under the terms of the GNU General Public License.\n";
33 print "For more information about these matters, see the file named COPYING.\n";
34 print "\n";
35 print "Copyright (c) 2006 Dennison Williams\n";
36 print "\n";
37 print "\n";
38 exit $ERRORS{'UNKNOWN'};
39 }
40
41 if ($opt_h) {
42 print_help();
43 exit $ERRORS{'UNKNOWN'};
44 }
45
46 #
47 # ok, now we are almost through
48 # These last subroutines do the things for those that do not
49 # read source code.
50 #
51 sub print_usage () {
52 print "Usage: $0 [-vhV]\n"; }
53
54 $SIG{'ALRM'} = sub {
55 print ("ERROR: plugin did not respond in time (alarm)\n");
56 exit $ERRORS{"UNKNOWN"};
57 };
58 alarm($TIMEOUT);
59
60 my $host = defined($opt_H) ? $opt_H : 'localhost';
61 my $port = defined($opt_p) ? $opt_p : 80;
62 my $jid = int(rand(100000));
63 my $hcurl = "http://$host:$port/user/impctl?act=checkjid&jid=$jid";
64 my $mech = new WWW::Mechanize;
65 $mech->get($hcurl);
66
67 print $mech->content() if $verbose;
68 if ($mech->success()) {
69 print "OK: $host:$port jaxtr webapp\n";
70 exit $ERRORS{"OK"};
71 }
72 else {
73 print "NOT OK: $host:$port jaxtr webapp\n";
74 exit $ERRORS{"CRITICAL"};
75 }
76
77 sub print_help {
78 print "\n";
79 print "\n";
80 print "check_webapp_jaxtr nagios plugin version $version\n";
81 print "\n";
82 print "The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute\n";
83 print "copies of the plugins under the terms of the GNU General Public License.\n";
84 print "For more information about these matters, see the file named COPYING.\n";
85 print "\n";
86 print "Copyright (c) 2006 Dennison Williams\n";
87 print "\n";
88 print "\n";
89 print "This plugin checks to see if the jaxtr web app is running on the specified \n";
90 print "host and port (default localhost:80). See the internal variable \$hcurl for \n";
91 print "the health check url used.\n";
92 print "\n";
93 print "\n";
94 print_usage();
95 print "\n";
96 print "Options:\n";
97 print " -h, --help\n";
98 print " print detailed help screen.\n";
99 print " -V, --version\n";
100 print " print version information.\n";
101 print "\n";
102 print "\n";
103 }
104 #
105 # the end
106 #

Properties

Name Value
svn:executable

dennison.williams@gmail.com
ViewVC Help
Powered by ViewVC 1.1.5