/[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 2740 - (hide annotations) (download)
Fri Oct 2 14:24:36 2015 UTC (8 years, 8 months ago) by torben
File size: 1728 byte(s)
use autoClosable
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 torben 2740 boolean debug = false;
12 torben 1980
13     int warning = 2147483647;
14     int critical = 2147483647;
15    
16     if (args.length < 5) {
17     System.out.println("usage: java com.traiana.utils.mq.MQDepth [qmgr] [port] [mqServerName] [channelName] [queueName] {-w [warning threshold]} {-c [critical threshold]} {-debug}");
18     System.exit(3);
19     }
20    
21 torben 2740 for (int i = 4; i < args.length; i++) {
22     String arg = args[i];
23     if (arg.equals("-w"))
24     warning = Integer.parseInt(args[(i + 1)]);
25     else if (arg.equals("-c"))
26     critical = Integer.parseInt(args[(i + 1)]);
27     else if (arg.equals("-debug"))
28     debug = true;
29     }
30    
31     String qmgr = args[0];
32     int port = Integer.parseInt(args[1]);
33     String mqServerName = args[2];
34     String channelName = args[3];
35     String queueName = args[4];
36    
37    
38     try (MQ sender = new MQ(qmgr, port, mqServerName, channelName, 0, debug) ) {
39    
40     sender.InitQueue(queueName, true);
41 torben 1980 depth = sender.getDepth();
42    
43    
44 torben 2737 } catch (Exception e) {
45     //e.printStackTrace();
46     System.out.println( e.getClass().getName() + ": " + e.getMessage() );
47     System.exit(3);
48 torben 1980 }
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