/[projects]/miscJava/thn_mqutils/src/main/java/com/traiana/utils/mq/MQDepth.java
ViewVC logotype

Annotation of /miscJava/thn_mqutils/src/main/java/com/traiana/utils/mq/MQDepth.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2737 - (hide annotations) (download)
Fri Oct 2 09:49:33 2015 UTC (8 years, 8 months ago) by torben
Original Path: miscJava/thn_mqutils/src/com/traiana/utils/mq/MQDepth.java
File size: 1731 byte(s)
nicer error reporting to nagios
1 torben 1980 package com.traiana.utils.mq;
2    
3     import com.ibm.mq.MQException;
4     import java.io.PrintStream;
5    
6     public class MQDepth
7     {
8     public static void main(String[] args)
9     {
10     int depth = 0;
11    
12     int warning = 2147483647;
13     int critical = 2147483647;
14    
15     if (args.length < 5) {
16     System.out.println("usage: java com.traiana.utils.mq.MQDepth [qmgr] [port] [mqServerName] [channelName] [queueName] {-w [warning threshold]} {-c [critical threshold]} {-debug}");
17     System.exit(3);
18     }
19     MQ sender = null;
20     try {
21    
22     boolean debug = false;
23     for (int i = 4; i < args.length; i++) {
24     String arg = args[i];
25     if (arg.equals("-w"))
26     warning = Integer.parseInt(args[(i + 1)]);
27     else if (arg.equals("-c"))
28     critical = Integer.parseInt(args[(i + 1)]);
29     else if (arg.equals("-debug"))
30     debug = true;
31     }
32     sender = new MQ(args[0], Integer.parseInt(args[1]), args[2], args[3], 0, debug);
33     sender.InitQueue(args[4], true);
34     depth = sender.getDepth();
35    
36    
37 torben 2737 } catch (Exception e) {
38     //e.printStackTrace();
39     System.out.println( e.getClass().getName() + ": " + e.getMessage() );
40     System.exit(3);
41 torben 1980 } finally {
42     if (sender != null)
43     try {
44     sender.close();
45     } catch (MQException e) {
46     e.printStackTrace();
47     }
48     }
49    
50     if (depth < warning) {
51     System.out.println("OK: depth=" + depth);
52     System.exit(0);
53     } else if (depth >= critical) {
54     System.out.println("CRITICAL: depth=" + depth);
55     System.exit(2);
56     } else {
57     System.out.println("WARNING: depth=" + depth);
58     System.exit(1);
59     }
60    
61    
62     }
63     }
64    
65     /* Location: C:\Users\thn\workspace\mq-utils.jar
66     * Qualified Name: com.traiana.utils.mq.MQDepth
67     * JD-Core Version: 0.6.2
68 torben 2737 */

  ViewVC Help
Powered by ViewVC 1.1.20