/[pdpsoft]/trunk/nl.nikhef.ndpf.tools/nagios-ndpf-sensors/scripts/check_creamce_enabled
ViewVC logotype

Contents of /trunk/nl.nikhef.ndpf.tools/nagios-ndpf-sensors/scripts/check_creamce_enabled

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1854 - (show annotations) (download)
Thu Jul 15 11:29:56 2010 UTC (11 years, 6 months ago) by ronalds
File size: 2727 byte(s)
0.3.4 - Added check_creamce_enabled
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Getopt::Long;
5
6 my $verbose=0;
7 my $help;
8 my $endpoint;
9 my $proxy;
10
11 my $TIMEOUT = 10; # 10 seconds to respond
12
13 GetOptions("help" => \$help,
14 "proxy|x:s" => \$proxy,
15 "verbose|v+" => \$verbose );
16
17 my %ERRORS=(OK=>0,
18 WARNING=>1,
19 CRITICAL=>2,
20 UNKNOWN=>3,
21 DEPENDENT=>4);
22
23 # verify format of mandatory argument endpoint (<fqdn>:<port>)
24 $endpoint = $ARGV[0];
25 if ( "$endpoint" eq "" ) {
26 print "Endpoint not specified\n";
27 exit $ERRORS{"UNKNOWN"};
28 }
29 else {
30 # verify that format looks like FQDN or IPv4 address followed by port number
31 if ( $endpoint !~ /^[\w\.-]+[:]\d+$/ ) {
32 # invalid format
33 print "UNKOWN: Invalid format of endpoint\n";
34 exit $ERRORS{"UNKNOWN"};
35 }
36 }
37
38 # defined executable locations
39 my $GLITE = $ENV{GLITE_LOCATION} || '/opt/glite';
40 my $EXE = $GLITE . "/bin/glite-ce-allowed-submission";
41 my $PX_VALID = $GLITE . "/bin/voms-proxy-info";
42
43 # ... and verify that executables exist
44 unless ( -x $EXE ) {
45 print "$EXE: $!";
46 exit $ERRORS{"UNKNOWN"};
47 }
48 unless ( -x $PX_VALID ) {
49 print "$PX_VALID: $!";
50 exit $ERRORS{"UNKNOWN"};
51 }
52
53 # Just in case of problems, let's not hang Nagios
54 $SIG{'ALRM'} = sub {
55 print ("ERROR: No response from $endpoint (alarm timeout)\n");
56 exit $ERRORS{"CRITICAL"};
57 };
58
59 alarm($TIMEOUT);
60
61 # if a proxy location was specified, make sure it is a readable file
62 if ( defined( $proxy ) ) {
63 if ( -f $proxy && -r $proxy ) {
64 $ENV{X509_USER_PROXY} = $proxy;
65 }
66 else {
67 print "ERROR: Cannot find proxy file $proxy\n";
68 exit $ERRORS{"UNKNOWN"};
69 }
70 }
71
72 # check validity of proxy
73 my @lines = `$PX_VALID -exists 2>/dev/null`;
74 if ( $? != 0 ) {
75 print "ERROR: Proxy file $ENV{X509_USER_PROXY} is not valid\n";
76 exit $ERRORS{"UNKNOWN"};
77 }
78
79
80 ##############################################################################
81 # output of glite-ce-allowed-submission
82 #
83 my ( $result, $message );
84
85 my $cmd = "$EXE -n $endpoint";
86 my @output = `$cmd`;
87 my $ret = $?;
88
89 my $perfdata = ""; # currently unused, now kept as a place holder
90
91 if ( $ret == 0 ) {
92 chomp $output[0];
93 if ( $output[0] =~ /enabled$/ ) {
94 $message = "OK: $output[0]";
95 $result = $ERRORS{"OK"};
96 }
97 elsif ( $output[0] =~ /disabled$/ ) {
98 $message = "WARNING: $output[0]";
99 $result = $ERRORS{"WARNING"};
100 }
101 else {
102 $message = "UNKNOWN: $output[0]";
103 $result = $ERRORS{"UNKNOWN"};
104 }
105 }
106 else {
107 $message = "ERROR: " . join( "\n", @output );
108 $result = $ERRORS{"CRITICAL"};
109 }
110
111 alarm(0);
112
113
114 # Write output and return exit code;
115 print "$message|$perfdata\n";
116 exit($result);
117

Properties

Name Value
svn:executable *
svn:keywords id

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28