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

Contents of /trunk/nl.nikhef.ndpf.tools/nagios-ndpf-sensors/scripts/wms-active-jobs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2610 - (show annotations) (download)
Thu Mar 14 16:03:50 2013 UTC (9 years, 2 months ago) by ronalds
File size: 1389 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 use strict;
4 use Getopt::Long;
5
6 my $verbose=0;
7 my $help;
8
9
10 my $TIMEOUT = 10;
11
12 GetOptions("help" => \$help,
13 "verbose|v+" => \$verbose );
14
15 my %ERRORS=(OK=>0,
16 WARNING=>1,
17 CRITICAL=>2,
18 UNKNOWN=>3,
19 DEPENDENT=>4);
20
21 my $QUERY_DB = "/usr/bin/queryDb";
22 if ( ! -x $QUERY_DB ) {
23 print "ERROR: cannot execute $QUERY_DB: $!\n";
24 exit $ERRORS{"UNKNOWN"};
25 }
26
27 my $result = $ERRORS{"UNKNOWN"};
28 my $message = "";
29
30 # Just in case of problems, let's not hang Nagios
31 $SIG{'ALRM'} = sub {
32 print "ERROR: alarm timeout\n";
33 exit $ERRORS{"UNKNOWN"};
34 };
35
36 alarm($TIMEOUT);
37
38 ##############################################################################
39 #
40 # output of queryDb
41 #
42
43 my @job_states = ( "REGISTERED", "IDLE", "RUNNING", "REALLY-RUNNING" );
44
45 my $cmd = "$QUERY_DB -vS -s " . join( ",", @job_states );
46 if ( ! open QRY, "$cmd | " ) {
47 print "ERROR: cannot read from command $cmd\n";
48 exit $ERRORS{"UNKNOWN"};
49 }
50
51 my %state_count;
52 while ( <QRY> ) {
53 if ( /^.(\w+).$/ ) {
54 $state_count{$1}++;
55 }
56 }
57
58 close QRY;
59
60
61 alarm(0);
62
63 $message = "OK";
64 $result = $ERRORS{"OK"};
65
66 # performance data
67 my $perf = "";
68 foreach my $js ( @job_states ) {
69 $state_count{$js} |= 0;
70 $perf .= sprintf "'%s'=%d ", $js, $state_count{$js};
71 }
72
73 # Write output and return exit code;
74 print "$message|$perf\n";
75 exit($result);
76

Properties

Name Value
svn:executable *

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