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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2610 - (show annotations) (download)
Thu Mar 14 16:03:50 2013 UTC (8 years, 10 months ago) by ronalds
File size: 2144 byte(s)
0.3.33: Fixed condor path for use with UMD-2 WMS and added probe to plot number of WMS jobs
1 #!/usr/bin/perl -w
2
3 # Nagios probe to check running and idle jobs in condor queue
4
5 use strict;
6 use Getopt::Long;
7
8 my $verbose=0;
9 my $help;
10 my $hostname;
11 my $metric;
12 my $state;
13 my $debug;
14 my $warning_level=-1;
15 my $critical_level=-1;
16
17
18 my $TIMEOUT = 15;
19
20 GetOptions("help" => \$help,
21 "host:s" => \$hostname,
22 "metric:s" => \$metric,
23 "state:s" => \$state,
24 "warning|w:i" => \$warning_level,
25 "critical|c:i" => \$critical_level,
26 "timeout:i" => \$TIMEOUT,
27 "debug" => \$debug,
28 "verbose" => \$verbose );
29
30 my %ERRORS=(OK=>0,
31 WARNING=>1,
32 CRITICAL=>2,
33 UNKNOWN=>3,
34 DEPENDENT=>4);
35
36
37 my $message = '';
38 my $result = $ERRORS{"UNKNOWN"};
39
40 # Just in case of problems, let's not hang Nagios
41 $SIG{'ALRM'} = sub {
42 print ("ERROR: No response from $hostname (alarm timeout)\n");
43 exit $ERRORS{"UNKNOWN"};
44 };
45
46 alarm($TIMEOUT);
47
48 ##############################################################################
49
50 my $condor_path = '/usr/bin/condor_q';
51 my %count = ( running => 0, idle => 0 );
52
53 if ( ! -x "$condor_path" ) {
54 $result = $ERRORS{"UNKNOWN"};
55 $message = "Cannot execute $condor_path: $!";
56 }
57 else {
58 open CONDOR, "$condor_path |";
59 if ( $? ) {
60 $result = $ERRORS{"CRITICAL"};
61 $message = "Error reading from $condor_path: $!";
62 }
63 else {
64 while ( <CONDOR> ) {
65 / I / and $count{idle}++;
66 / R / and $count{running}++;
67 }
68 close CONDOR;
69 }
70 if ( $count{idle} < $critical_level ||
71 $count{running} < $critical_level) {
72 $result = $ERRORS{"CRITICAL"};
73 $message = "ERROR: ";
74 }
75 elsif ( $count{idle} < $warning_level ||
76 $count{running} < $warning_level ) {
77 $result = $ERRORS{"WARNING"};
78 $message = "WARNING: ";
79 }
80 else {
81 $result = $ERRORS{"OK"};
82 $message = "OK: ";
83 }
84 $message .= "running=$count{running}, idle=$count{idle}";
85 }
86
87
88
89 ##############################################################################
90 alarm(0);
91
92 print "$message\n";
93 exit($result);

Properties

Name Value
svn:executable *
svn:keywords id

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