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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3014 - (show annotations) (download)
Thu Apr 21 08:37:03 2016 UTC (8 years ago) by torben
File size: 1821 byte(s)
use commons lang3 to get stacktrace string
1 package com.traiana.utils.mq;
2
3 import com.ibm.mq.MQException;
4 import java.io.PrintStream;
5
6 import org.apache.commons.lang3.exception.ExceptionUtils;
7
8 public class MQDepth
9 {
10 public static void main(String[] args)
11 {
12 int depth = 0;
13 boolean debug = false;
14
15 int warning = 2147483647;
16 int critical = 2147483647;
17
18 if (args.length < 5) {
19 System.out.println("usage: java com.traiana.utils.mq.MQDepth [qmgr] [port] [mqServerName] [channelName] [queueName] {-w [warning threshold]} {-c [critical threshold]} {-debug}");
20 System.exit(3);
21 }
22
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
33 String qmgr = args[0];
34 int port = Integer.parseInt(args[1]);
35 String mqServerName = args[2];
36 String channelName = args[3];
37 String queueName = args[4];
38
39
40 try (MQ sender = new MQ(qmgr, port, mqServerName, channelName, 0, debug) ) {
41
42 sender.InitQueue(queueName, true);
43 depth = sender.getDepth();
44
45
46 } catch (Exception e) {
47 System.out.println( ExceptionUtils.getStackTrace(e) );
48 System.out.println( e.getClass().getName() + ": " + e.getMessage() );
49 System.exit(3);
50 }
51
52 if (depth < warning) {
53 System.out.println("OK: depth=" + depth);
54 System.exit(0);
55 } else if (depth >= critical) {
56 System.out.println("CRITICAL: depth=" + depth);
57 System.exit(2);
58 } else {
59 System.out.println("WARNING: depth=" + depth);
60 System.exit(1);
61 }
62
63
64 }
65 }
66
67 /* Location: C:\Users\thn\workspace\mq-utils.jar
68 * Qualified Name: com.traiana.utils.mq.MQDepth
69 * JD-Core Version: 0.6.2
70 */

  ViewVC Help
Powered by ViewVC 1.1.20