-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathqmmonitor2.c
executable file
·2961 lines (2728 loc) · 122 KB
/
qmmonitor2.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* @(#) MQMBID sn=p941-lrep-L240917 su=_WdFky3R3Ee-6Cq_6nLjb_A pn=samples/c/amqsruaa.c.pre */
/********************************************************************/
/* */
/* Program name: qmmonitor2 */
/* */
/* Description: Sample C program that subscribes to MQ resource */
/* usage topics and formats the resulting published */
/* PCF data. */
/* This sample also acts as primary documentation */
/* for customers/vendors wishing to gain a greater */
/* understanding of the (flexible) structure and */
/* nature of MQ's resource usage publications. */
/* <copyright */
/* notice="lm-source-program" */
/* pids="5724-H72" */
/* years="1994,2024" */
/* crc="1728343970" > */
/* Licensed Materials - Property of IBM */
/* */
/* 5724-H72 */
/* */
/* (C) Copyright IBM Corp. 1994, 2024 All Rights Reserved. */
/* */
/* US Government Users Restricted Rights - Use, duplication or */
/* disclosure restricted by GSA ADP Schedule Contract with */
/* IBM Corp. */
/* </copyright> */
/********************************************************************/
/* */
/* Function: */
/* */
/* */
/* AMQSRUAA is a sample C program to subscribe and get messages */
/* showing how MQ is using resources. It is a basic example of */
/* how to request and consume this type of administrative data. */
/* */
/* */
/* sample */
/* -- subscribes non-durably to the topics identified by the */
/* input parameters. */
/* */
/* -- calls MQGET repeatedly to get messages from the topics, */
/* and writes to stdout. */
/* */
/* -- writes a message for each MQI reason other than */
/* MQRC_NONE; stops if there is a MQI completion code */
/* of MQCC_FAILED, or when the requested number of */
/* resource usage publications have been consumed. */
/* */
/* */
/* */
/* Program logic: */
/* Determine name of admin topics from the input parameters. */
/* MQSUB topics for INPUT */
/* while no MQI failures, */
/* . MQGET next message */
/* . format the results */
/* . (no message available counts as failure, and loop ends) */
/* MQCLOSE the topic */
/* */
/* */
/* The queue manager publishes resource usage data to topics to be */
/* consumed by subscribers to those topics. At queue manager */
/* start up the queue manager publishes a set of messages on */
/* "meta-topics" describing what resource usage topics are */
/* supported by this queue manager, and the content of the */
/* messages published to those topics. */
/* Administrative tools subscribe to the meta-data to discover */
/* what resource usage information is available, and on what */
/* topics, and then subscribe to the advertised topics in order */
/* to consume resource usage data. */
/* */
/* It is worth noting that pretty much the only static information */
/* used by amqsruaa.c is the "META_PREFIX" definition which */
/* identifies the root topic for the meta-data publications and */
/* no other statically defined data needs to be used. */
/* */
/* Well written MQ admin programs consuming this type of data */
/* should try to follow this model. */
/* */
/* Much of the published data represents well understood MQ */
/* concepts, such as the rate at which messages are being */
/* produced and consumed. This type of data is very unlikely to */
/* change across MQ configurations. */
/* A subset of the published data is more reflective of MQ */
/* internals, for example data relating to rates of queue */
/* avoidance (put to waiting getter), or data relating to lock */
/* contention. This type of data is likely to change across */
/* MQ configurations. A well written program that subscribes to and */
/* consumes this type of data should not need changing when new */
/* resource usage information is added, nor when the currently */
/* published topics and content are changed. */
/* */
/********************************************************************/
/* */
/* AMQSRUAA has the following parameters */
/* optional: */
/* (1) Queue manager name (-m) */
/* (2) The CLASS(s) (-c) */
/* (3) The TYPE(s) (-t) */
/* (4) The Object name(s) (-o) */
/* (5) The number of publications to process (-n) */
/* (6) The debug level (-d) */
/* (7) Metadata prefix (-p) */
/* (8) The model queue name (-s) */
/* */
/* Examples: */
/* amqsrua -m QM1 -c CPU -t QMgrSummary -n 5 */
/* amqsrua -m QM1 -c STATMQI -t PUT -t GET */
/* amqsrua -m QM1 -c STATQ -o QUEUE1 -t PUT -t GET -n 10 */
/* amqsrua -m QM1 -c DISK -t Log -n 10 */
/* amqsrua -m QM1 -s MODELQUEUE1 */
/* */
/********************************************************************/
/* Notes: */
/* */
/* 1. The primary purpose of amqsruaa is to demonstrate how to */
/* interpret the meta-data to make appropriate subscriptions */
/* and how to process the ensuing publications. In order to keep */
/* this focus, amqsruaa.c is intentionally very simplistic in */
/* its error handling, and is NOT intended to be a good example */
/* of comprehensive MQ error handling. */
/* Similarly the usability of amqsruaa as a sample executable */
/* is somewhat constrained by the desire to keep the source */
/* code focused on its primary purpose. */
/* */
/* */
/********************************************************************/
/*
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/CLASSES/en_GB
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/CLASSES
Register Class: 0000 CPU Platform central processing units
Register Class: 0001 DISK Platform persistent data stores
Register Class: 0002 STATMQI API usage statistics
Register Class: 0003 STATQ API per-queue usage statistics
Register Class: 0004 STATAPP Per-application usage statistics
Register Class: 0005 NHAREPLICA Native HA replica statistics
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/CPU/TYPES
Register Type : 0000 0000 SystemSummary CPU performance - platform wide
TopicLen: 58
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/CPU/SystemSummary
Register Type : 0000 0001 QMgrSummary CPU performance - running queue manager
TopicLen: 56
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/CPU/QMgrSummary
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/DISK/TYPES
Register Type : 0001 0000 SystemSummary Disk usage - platform wide
TopicLen: 59
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/DISK/SystemSummarya
Register Type : 0001 0001 QMgrSummary Disk usage - running queue managers
TopicLen: 57
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/DISK/QMgrSummarySum
Register Type : 0001 0002 Log Disk usage - queue manager recovery log
TopicLen: 49
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/DISK/Log
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/TYPES
Register Type : 0002 0000 CONNDISC MQCONN and MQDISC
TopicLen: 57
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/CONNDISCDIS
Register Type : 0002 0001 OPENCLOSE MQOPEN and MQCLOSE
TopicLen: 58
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/OPENCLOSEni
Register Type : 0002 0002 INQSET MQINQ and MQSET
TopicLen: 55
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/INQSETS
Register Type : 0002 0003 PUT MQPUT
TopicLen: 52
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/PUT
Register Type : 0002 0004 GET MQGET
TopicLen: 52
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/GET
Register Type : 0002 0005 SYNCPOINT Commit and rollback
TopicLen: 58
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/SYNCPOINTAR
Register Type : 0002 0006 SUBSCRIBE Subscribe
TopicLen: 58
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/SUBSCRIBE
Register Type : 0002 0007 PUBLISH Publish
TopicLen: 56
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/PUBLISH
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATQ/TYPES
Register Type : 0003 0000 OPENCLOSE MQOPEN and MQCLOSE
TopicLen: 56
Register Type : 0003 0001 INQSET MQINQ and MQSET
TopicLen: 53
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATQ/INQSETMQI
Register Type : 0003 0002 PUT MQPUT and MQPUT1
TopicLen: 50
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATQ/PUTTA
Register Type : 0003 0003 GET MQGET
TopicLen: 50
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATQ/GETr/
Register Type : 0003 0004 GENERAL General queue metrics
TopicLen: 54
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATQ/GENERAL
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATAPP/TYPES
Register Type : 0004 0000 INSTANCE Application instance statistics
TopicLen: 57
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATAPP/INSTANCE
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/NHAREPLICA/TYPES
Register Type : 0005 0000 REPLICATION Native HA Replication statistics
TopicLen: 63
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/NHAREPLICA/REPLICATION
Register Type : 0005 0001 RECOVERY Native HA recovery group statistics
TopicLen: 60
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/NHAREPLICA/RECOVERY
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/CPU/SystemSummary
Register Elem :0000 0000 0000 10000 User CPU time percentage
Register Elem :0000 0000 0001 10000 System CPU time percentage
Register Elem :0000 0000 0002 0100 CPU load - one minute average
Register Elem :0000 0000 0003 0100 CPU load - five minute average
Register Elem :0000 0000 0004 0100 CPU load - fifteen minute average
Register Elem :0000 0000 0005 10000 RAM free percentage
Register Elem :0000 0000 0006 1048576 RAM total bytes
Update Type :0000 0000 $SYS/MQ/INFO/QMGR/PERF0/Monitor/CPU/SystemSummary
TopicLen: 49
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/CPU/SystemSummary
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/CPU/QMgrSummary
Register Elem :0000 0001 0000 10000 User CPU time - percentage estimate for queue manager
Register Elem :0000 0001 0001 10000 System CPU time - percentage estimate for queue manager
Register Elem :0000 0001 0002 1048576 RAM total bytes - estimate for queue manager
Update Type :0000 0001 $SYS/MQ/INFO/QMGR/PERF0/Monitor/CPU/QMgrSummary
TopicLen: 47
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/CPU/QMgrSummary
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/DISK/SystemSummary
Register Elem :0001 0000 0004 1048576 MQ trace file system - bytes in use
Register Elem :0001 0000 0005 10000 MQ trace file system - free space
Register Elem :0001 0000 0006 1048576 MQ errors file system - bytes in use
Register Elem :0001 0000 0007 10000 MQ errors file system - free space
Register Elem :0001 0000 0008 0001 MQ FDC file count
Update Type :0001 0000 $SYS/MQ/INFO/QMGR/PERF0/Monitor/DISK/SystemSummary
TopicLen: 50
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/DISK/SystemSummaryntageE
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/DISK/QMgrSummary
Register Elem :0001 0001 0000 1048576 Queue Manager file system - bytes in use
Register Elem :0001 0001 0001 10000 Queue Manager file system - free space
Update Type :0001 0001 $SYS/MQ/INFO/QMGR/PERF0/Monitor/DISK/QMgrSummary
TopicLen: 48
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/DISK/QMgrSummarys file system - bytes in use
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/DISK/Log
Register Elem :0001 0002 0000 0001 Log - bytes in use
Register Elem :0001 0002 0001 0001 Log - bytes max
Register Elem :0001 0002 0002 0001 Log file system - bytes in use
Register Elem :0001 0002 0003 0001 Log file system - bytes max
Register Elem :0001 0002 0004 0002 Log - physical bytes written
Register Elem :0001 0002 0005 0002 Log - logical bytes written
Register Elem :0001 0002 0006 1000000 Log - write latency
Register Elem :0001 0002 0007 10000 Log - current primary space in use
Register Elem :0001 0002 0008 10000 Log - workload primary space utilization
Register Elem :0001 0002 0009 1048576 Log - bytes required for media recovery
Register Elem :0001 0002 0010 1048576 Log - bytes occupied by reusable extents
Register Elem :0001 0002 0011 1048576 Log - bytes occupied by extents waiting to be archived
Register Elem :0001 0002 0012 0001 Log - write size
Register Elem :0001 0002 0013 10000 Log file system - free space
Register Elem :0001 0002 0014 0003 Log - disk written log sequence number
Register Elem :0001 0002 0015 0003 Log - quorum log sequence number
Update Type :0001 0002 $SYS/MQ/INFO/QMGR/PERF0/Monitor/DISK/Log
TopicLen: 40
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/DISK/Log
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/CONNDISC
Register Elem :0002 0000 0000 0002 MQCONN/MQCONNX count
Register Elem :0002 0000 0001 0002 Failed MQCONN/MQCONNX count
Register Elem :0002 0000 0002 0001 Concurrent connections - high water mark
Register Elem :0002 0000 0003 0002 MQDISC count
Update Type :0002 0000 $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/CONNDISC
TopicLen: 48
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/CONNDISC- physical bytes written
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/OPENCLOSE
Register Elem :0002 0001 0000 0002 MQOPEN count
Register Elem :0002 0001 0001 0002 Failed MQOPEN count
Register Elem :0002 0001 0002 0002 MQCLOSE count
Register Elem :0002 0001 0003 0002 Failed MQCLOSE count
Update Type :0002 0001 $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/OPENCLOSE
TopicLen: 49
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/OPENCLOSE/PERF0/Monitor/STATMQI/CONNDISC- physical bytes written
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/INQSET
Register Elem :0002 0002 0000 0002 MQINQ count
Register Elem :0002 0002 0001 0002 Failed MQINQ count
Register Elem :0002 0002 0002 0002 MQSET count
Register Elem :0002 0002 0003 0002 Failed MQSET count
Update Type :0002 0002 $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/INQSET
TopicLen: 46
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/INQSETENCLOSE/PERF0/Monitor/STATMQI/CONNDISC- physical bytes written
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/PUT
Register Elem :0002 0003 0000 0002 Interval total MQPUT/MQPUT1 count
Register Elem :0002 0003 0001 0002 Interval total MQPUT/MQPUT1 byte count
Register Elem :0002 0003 0002 0002 Non-persistent message MQPUT count
Register Elem :0002 0003 0003 0002 Persistent message MQPUT count
Register Elem :0002 0003 0004 0002 Failed MQPUT count
Register Elem :0002 0003 0005 0002 Non-persistent message MQPUT1 count
Register Elem :0002 0003 0006 0002 Persistent message MQPUT1 count
Register Elem :0002 0003 0007 0002 Failed MQPUT1 count
Register Elem :0002 0003 0008 0002 Put non-persistent messages - byte count
Register Elem :0002 0003 0009 0002 Put persistent messages - byte count
Register Elem :0002 0003 0010 0002 MQSTAT count
Update Type :0002 0003 $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/PUT
TopicLen: 43
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/PUTytes occupied by extents waiting to be archived
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/GET
Register Elem :0002 0004 0000 0002 Interval total destructive get- count
Register Elem :0002 0004 0001 0002 Interval total destructive get - byte count
Register Elem :0002 0004 0002 0002 Non-persistent message destructive get - count
Register Elem :0002 0004 0003 0002 Persistent message destructive get - count
Register Elem :0002 0004 0004 0002 Failed MQGET - count
Register Elem :0002 0004 0005 0002 Got non-persistent messages - byte count
Register Elem :0002 0004 0006 0002 Got persistent messages - byte count
Register Elem :0002 0004 0007 0002 Non-persistent message browse - count
Register Elem :0002 0004 0008 0002 Persistent message browse - count
Register Elem :0002 0004 0009 0002 Failed browse count
Register Elem :0002 0004 0010 0002 Non-persistent message browse - byte count
Register Elem :0002 0004 0011 0002 Persistent message browse - byte count
Register Elem :0002 0004 0012 0002 Expired message count
Register Elem :0002 0004 0013 0002 Purged queue count
Register Elem :0002 0004 0014 0002 MQCB count
Register Elem :0002 0004 0015 0002 Failed MQCB count
Register Elem :0002 0004 0016 0002 MQCTL count
Update Type :0002 0004 $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/GET
TopicLen: 43
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/GET
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/SYNCPOINT
Register Elem :0002 0005 0000 0002 Commit count
Register Elem :0002 0005 0002 0002 Rollback count
Update Type :0002 0005 $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/SYNCPOINT
TopicLen: 49
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/SYNCPOINT
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/SUBSCRIBE
Register Elem :0002 0006 0000 0002 Create durable subscription count
Register Elem :0002 0006 0001 0002 Alter durable subscription count
Register Elem :0002 0006 0002 0002 Resume durable subscription count
Register Elem :0002 0006 0003 0002 Create non-durable subscription count
Register Elem :0002 0006 0006 0002 Failed create/alter/resume subscription count
Register Elem :0002 0006 0007 0002 Delete durable subscription count
Register Elem :0002 0006 0008 0002 Delete non-durable subscription count
Register Elem :0002 0006 0009 0002 Subscription delete failure count
Register Elem :0002 0006 0010 0002 MQSUBRQ count
Register Elem :0002 0006 0011 0002 Failed MQSUBRQ count
Register Elem :0002 0006 0012 0001 Durable subscriber - high water mark
Register Elem :0002 0006 0013 0001 Durable subscriber - low water mark
Register Elem :0002 0006 0014 0001 Non-durable subscriber - high water mark
Register Elem :0002 0006 0015 0001 Non-durable subscriber - low water mark
Update Type :0002 0006 $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/SUBSCRIBE
TopicLen: 49
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/SUBSCRIBE
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATMQI/PUBLISH
Register Elem :0002 0007 0000 0002 Topic MQPUT/MQPUT1 interval total
Register Elem :0002 0007 0001 0002 Interval total topic bytes put
Register Elem :0002 0007 0002 0002 Published to subscribers - message count
Register Elem :0002 0007 0003 0002 Published to subscribers - byte count
Register Elem :0002 0007 0004 0002 Non-persistent - topic MQPUT/MQPUT1 count
Register Elem :0002 0007 0005 0002 Persistent - topic MQPUT/MQPUT1 count
Register Elem :0002 0007 0006 0002 Failed topic MQPUT/MQPUT1 count
Update Type :0002 0007 $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/PUBLISH
TopicLen: 47
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATMQI/PUBLISH
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATQ/OPENCLOSE
Register Elem :0003 0000 0000 0002 MQOPEN count
Register Elem :0003 0000 0001 0002 MQCLOSE count
Update Type :0003 0000 $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATQ/%s/OPENCLOSE
TopicLen: 50
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATQ/%s/OPENCLOSE
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATQ/INQSET
Register Elem :0003 0001 0000 0002 MQINQ count
Register Elem :0003 0001 0001 0002 MQSET count
Update Type :0003 0001 $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATQ/%s/INQSET
TopicLen: 47
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATQ/%s/INQSETENCLOSE
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATQ/PUT
Register Elem :0003 0002 0000 0002 MQPUT/MQPUT1 count
Register Elem :0003 0002 0001 0002 MQPUT byte count
Register Elem :0003 0002 0002 0002 MQPUT non-persistent message count
Register Elem :0003 0002 0003 0002 MQPUT persistent message count
Register Elem :0003 0002 0004 0002 MQPUT1 non-persistent message count
Register Elem :0003 0002 0005 0002 MQPUT1 persistent message count
Register Elem :0003 0002 0006 0002 non-persistent byte count
Register Elem :0003 0002 0007 0002 persistent byte count
Register Elem :0003 0002 0008 10000 queue avoided puts
Register Elem :0003 0002 0009 10000 queue avoided bytes
Register Elem :0003 0002 0010 10000 lock contention
Register Elem :0003 0002 0011 0002 rolled back MQPUT count
Update Type :0003 0002 $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATQ/%s/PUT
TopicLen: 44
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATQ/%s/PUT
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATQ/GET
Register Elem :0003 0003 0000 0002 MQGET count
Register Elem :0003 0003 0001 0002 MQGET byte count
Register Elem :0003 0003 0002 0002 destructive MQGET non-persistent message count
Register Elem :0003 0003 0003 0002 destructive MQGET persistent message count
Register Elem :0003 0003 0004 0002 destructive MQGET non-persistent byte count
Register Elem :0003 0003 0005 0002 destructive MQGET persistent byte count
Register Elem :0003 0003 0006 0002 MQGET browse non-persistent message count
Register Elem :0003 0003 0007 0002 MQGET browse persistent message count
Register Elem :0003 0003 0008 0002 MQGET browse non-persistent byte count
Register Elem :0003 0003 0009 0002 MQGET browse persistent byte count
Register Elem :0003 0003 0010 0002 destructive MQGET fails
Register Elem :0003 0003 0011 0002 destructive MQGET fails with MQRC_NO_MSG_AVAILABLE
Register Elem :0003 0003 0012 0002 destructive MQGET fails with MQRC_TRUNCATED_MSG_FAILED
Register Elem :0003 0003 0013 0002 MQGET browse fails
Register Elem :0003 0003 0014 0002 MQGET browse fails with MQRC_NO_MSG_AVAILABLE
Register Elem :0003 0003 0015 0002 MQGET browse fails with MQRC_TRUNCATED_MSG_FAILED
Register Elem :0003 0003 0016 0002 rolled back MQGET count
Update Type :0003 0003 $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATQ/%s/GET
TopicLen: 44
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATQ/%s/GET
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATQ/GENERAL
Register Elem :0003 0004 0000 0002 messages expired
Register Elem :0003 0004 0001 0002 queue purged count
Register Elem :0003 0004 0002 1000000 average queue time
Register Elem :0003 0004 0003 0001 Queue depth
Update Type :0003 0004 $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATQ/%s/GENERAL
TopicLen: 48
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATQ/%s/GENERAL
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATAPP/INSTANCE
Register Elem :0004 0000 0000 0001 Instance count
Register Elem :0004 0000 0001 0001 Movable instance count
Register Elem :0004 0000 0002 0001 Instance shortfall count
Register Elem :0004 0000 0003 0002 Instances started
Register Elem :0004 0000 0004 0002 Initiated outbound instance moves
Register Elem :0004 0000 0005 0002 Completed outbound instance moves
Register Elem :0004 0000 0006 0002 Instances ended during reconnect
Register Elem :0004 0000 0007 0002 Instances ended
Update Type :0004 0000 $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATAPP/%s/INSTANCE
TopicLen: 51
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/STATAPP/%s/INSTANCEsage count
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/NHAREPLICA/REPLICATION
Register Elem :0005 0000 0000 0002 Synchronous log bytes sent
Register Elem :0005 0000 0001 0002 Catch-up log bytes sent
Register Elem :0005 0000 0002 1000000 Log write average acknowledgement latency
Register Elem :0005 0000 0003 0001 Log write average acknowledgement size
Register Elem :0005 0000 0004 0001 Backlog bytes
Register Elem :0005 0000 0005 0001 Backlog average bytes
Register Elem :0005 0000 0006 0002 Synchronous compressed log bytes sent
Register Elem :0005 0000 0007 0002 Catch-up compressed log bytes sent
Register Elem :0005 0000 0008 0002 Synchronous uncompressed log bytes sent
Register Elem :0005 0000 0009 0002 Catch-up uncompressed log bytes sent
Register Elem :0005 0000 0010 0003 Acknowledged log sequence number
Register Elem :0005 0000 0011 0001 Log file system - bytes in use
Register Elem :0005 0000 0012 10000 Log file system - free space
Register Elem :0005 0000 0013 1048576 Queue Manager file system - bytes in use
Register Elem :0005 0000 0014 10000 Queue Manager file system - free space
Register Elem :0005 0000 0015 0001 MQ FDC file count
Register Elem :0005 0000 0016 1000000 Average network round trip time
Register Elem :0005 0000 0017 1000000 Synchronous log data average compression time
Register Elem :0005 0000 0018 1000000 Catch-up log data average compression time
Register Elem :0005 0000 0019 0001 Synchronous log bytes decompressed
Register Elem :0005 0000 0020 1000000 Synchronous log data average decompression time
Register Elem :0005 0000 0021 0001 Catch-up log bytes decompressed
Register Elem :0005 0000 0022 1000000 Catch-up log data average decompression time
Update Type :0005 0000 $SYS/MQ/INFO/QMGR/PERF0/Monitor/NHAREPLICA/%s/REPLICATION
TopicLen: 57
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/NHAREPLICA/%s/REPLICATION
Subscribing to topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/NHAREPLICA/RECOVERY
Register Elem :0005 0001 0000 0002 Log bytes sent
Register Elem :0005 0001 0001 0001 Backlog bytes
Register Elem :0005 0001 0002 0001 Backlog average bytes
Register Elem :0005 0001 0003 0001 Rebase count
Register Elem :0005 0001 0004 0003 Recovery log sequence number
Register Elem :0005 0001 0005 1000000 Average network round trip time
Register Elem :0005 0001 0006 0001 Compressed log bytes sent
Register Elem :0005 0001 0007 1000000 Log data average compression time
Register Elem :0005 0001 0008 0001 Log bytes decompressed
Register Elem :0005 0001 0009 1000000 Log data average decompression time
Update Type :0005 0001 $SYS/MQ/INFO/QMGR/PERF0/Monitor/NHAREPLICA/%s/RECOVERY
TopicLen: 54
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/NHAREPLICA/%s/RECOVERYnt*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/* includes for MQI */
#include <cmqc.h>
#include <cmqxc.h>
#include <cmqcfc.h>
/* The maximum number of input classes supported by amqsruaa.c */
#define MAX_CLASS_COUNT 10
/* The maximum size of the string value of a class supported here */
#define MAX_CLASS_SIZE 32
/* The maximum number of input types supported by amqsruaa.c */
#define MAX_TYPE_COUNT 100
/* The maximum size of the string value of a type supported here */
#define MAX_TYPE_SIZE 32
/* The root of the topic tree where MQ publishes the meta-data */
/* describing what resource usage publications will be published */
/* by this queue manager. */
#define META_PREFIX "$SYS/MQ"
#if MQAT_DEFAULT == MQAT_WINDOWS_NT
#define Int64 "I64"
#elif defined(MQ_64_BIT)
#define Int64 "l"
#else
#define Int64 "ll"
#endif
/* As explained above, amqsruaa error handling is intentionally very */
/* simplistic. The program will return either 0 (expected number of */
/* pulications received, or 20 (some error occurred). */
#define ERROR_RETURN 20
#define sruUsageString "%s [-m QMGR-NAME] [-c CLASS-NAME]\n" \
"\t [-o object name] [-t TYPE-NAME]\n" \
"\t [-p metadata prefix] [-d debug level] \n"\
"\t [-n publication count]\n" \
"\t [-s model queue name]\n"
/*********************************************************************/
/* */
/* amqsruaa reads the meta data to understand what resource usage */
/* information is supported by the current queue manager */
/* configuration. */
/* This information is built into a tree to be used in selecting */
/* (if not explicitly specified) the data to be consumed and in */
/* formatting the produced data. */
/* The following typedef's are private to amqsruaa.c and represent */
/* this programs view of the meta-data. */
/*********************************************************************/
/*********************************************************************/
/* Resource usage publications are PCF messages consisting of a */
/* sequence of PCF elements. The PCF elements published for each */
/* class/type pair are advertised in the meta-data. We store a leaf */
/* in the tree describing each element, thus allowing the elements */
/* to be processed accordingly. */
/* */
/*********************************************************************/
typedef struct _sruELEM
{
struct _sruELEM * next;
MQLONG id;
MQLONG type;
MQLONG descLen;
char Buffer[1];
} sruELEM;
/*********************************************************************/
/* MQ resource usage publications are associated with a type */
/* within a class. Each publication includes the class and type */
/* which allows the class/type/element definitions to be found */
/* and the resulting publications to be handled appropriately. */
/* The class/type/element descriptions are published as meta-data */
/* at queue manager startup. */
/*********************************************************************/
typedef struct _sruTYPE
{
struct _sruTYPE * next;
MQLONG id;
MQLONG typeLen;
MQLONG descLen;
MQLONG topicLen;
MQLONG topicCCSID;
sruELEM * elem;
MQLONG flags;
char Buffer[1];
} sruTYPE;
/*********************************************************************/
/* MQ resource usage publications are associated with a class. */
/* The classes represent the top level in the tree of meta-data */
/* decribing the available resource usage information. */
/*********************************************************************/
typedef struct _sruCLASS
{
struct _sruCLASS * next;
MQLONG id;
MQLONG classLen;
MQLONG descLen;
MQLONG topicLen;
MQLONG topicCCSID;
sruTYPE * type;
MQLONG flags;
char Buffer[1];
} sruCLASS;
/*********************************************************************/
/* MQ log sequence numbers are provided as 64-bit integers. The */
/* sruINT64toLSN macro converts one into a set of four words so it */
/* can be printed in the standard <nnnn:nnnn:nnnn:nnnn> format. */
/*********************************************************************/
typedef struct _sruLSN
{
unsigned short word[4];
} sruLSN;
#if (MQENC_NATIVE & MQENC_INTEGER_REVERSED)
#define sruWORD(w) ((unsigned short)(((w) << 8) | ((w) >> 8)))
#define sruINT64toLSN(_i64,_plsn) \
{ \
union \
{ \
MQINT64 i64; \
sruLSN lsn; \
} u; \
u.i64 = (_i64); \
(_plsn)->word[3] = sruWORD(u.lsn.word[0]); \
(_plsn)->word[2] = sruWORD(u.lsn.word[1]); \
(_plsn)->word[1] = sruWORD(u.lsn.word[2]); \
(_plsn)->word[0] = sruWORD(u.lsn.word[3]); \
}
#else
#define sruWORD(w) (w)
#define sruINT64toLSN(_i64,_plsn) \
{ \
union \
{ \
MQINT64 i64; \
sruLSN lsn; \
} u; \
u.i64 = (_i64); \
(_plsn)->word[0] = u.lsn.word[0]; \
(_plsn)->word[1] = u.lsn.word[1]; \
(_plsn)->word[2] = u.lsn.word[2]; \
(_plsn)->word[3] = u.lsn.word[3]; \
}
#endif
/*********************************************************************/
/* */
/* Data globally addressable within amqsruaa.c */
/* */
/*********************************************************************/
static char QMName[50]; /* queue manager name */
static char ModelQName[50] = {0}; /* model queue name */
static char Class[MAX_CLASS_COUNT][MAX_CLASS_SIZE] = {0};
static char * ClassObjName[MAX_TYPE_COUNT] = {0};
static char Type[MAX_TYPE_COUNT][MAX_TYPE_SIZE] = {0};
static char * TypeObjName[MAX_TYPE_COUNT] = {0};
static int ClassTypeCount[MAX_CLASS_COUNT] = {0};
static int ClassCount=0;
static int TypeCount=0;
static MQHCONN Hcon = MQHC_UNUSABLE_HCONN; /* connection handle */
static MQHOBJ Hobj = MQHO_NONE; /* MQGET object handle */
static sruCLASS * ClassChain = NULL; /* root of tree */
static int sruDebug = 0;
static char * meta_prefix = META_PREFIX;
static char runmqsc[] = "runmqsc";
static char mqserver[] = "MQSERVER";
static char collectQueueDepth[] = "display queue(*) where (curdepth gt 0)";
/*********************************************************************/
/* */
/* Prototypes for functions local to amqsruaa.c */
/* */
/*********************************************************************/
int sruPromptForClass(void);
int sruPromptForType(void);
int sruSubscribe(void);
int sruDiscover(void);
int sruQueryQMName(void);
int sruFormatMessage(PMQCFH buffer, MQMD * pMd);
void sruFormatElem( PMQCFIN cfin
, sruELEM * pElem
, MQINT64 interval
, char * pObjName
, MQLONG ObjNameLen);
int sruRegisterClass( MQLONG id
, char * class
, MQLONG class_len
, char * desc
, MQLONG desc_len
, char * topic
, MQLONG topic_len
, MQLONG topic_ccsid
, MQLONG flags );
int sruRegisterType( MQLONG class_id
, MQLONG type_id
, char * type
, MQLONG type_len
, char * desc
, MQLONG desc_len
, char * topic
, MQLONG topic_len
, MQLONG topic_ccsid
, MQLONG flags);
int sruUpdateType( MQLONG class_id
, MQLONG type_id
, char * topic
, MQLONG topic_len
, MQLONG topic_ccsid );
int sruRegisterElement( MQLONG class_id
, MQLONG type_id
, MQLONG elem_id
, MQLONG elemType
, char * desc
, MQLONG desc_len );
sruCLASS * sruIdToClass(MQLONG class);
sruTYPE * sruIdToType(sruCLASS * pClass, MQLONG type);
sruELEM * sruIdToElem(sruTYPE * pType, MQLONG elem);
/*********************************************************************/
/* */
/* Main: */
/* */
/*********************************************************************/
int main(int argc, char **argv)
{
/* Declare MQI structures needed */
MQOD od = {MQOD_DEFAULT}; /* Object Descriptor */
MQMD md = {MQMD_DEFAULT}; /* Message Descriptor */
MQGMO gmo = {MQGMO_DEFAULT}; /* get message options */
/** note, sample uses defaults where it can **/
MQLONG CompCode; /* completion code */
MQLONG Reason; /* reason code */
MQBYTE buffer[4096]; /* message buffer */
MQLONG buflen; /* buffer length */
MQLONG messlen; /* message length received */
MQLONG MaxGets = -1;
MQLONG GetCount = 0;
int count;
int rc = 0;
char * parg;
MQCNO cno = {MQCNO_DEFAULT}; /* Connection options */
MQCD cd = {MQCD_CLIENT_CONN_DEFAULT}; /* Client descriptor */
MQCSP csp = {MQCSP_DEFAULT};
char channelName[MQ_CHANNEL_NAME_LENGTH]; // SVRCONN channel to connect via
char hostName[MQ_CONN_NAME_LENGTH]; // Name of machine hosting queue manager
int portNumber = 1420; // Port to connect to machine on
int clientMode = 0; // Determine if to connect in client mode
int autoMode = 0;
char userid[MQ_USER_ID_LENGTH];
char password[MQ_CSP_PASSWORD_LENGTH];
char cipherSpec[MQ_SSL_CIPHER_SPEC_LENGTH];
MQCHAR certLabel[MQ_CERT_LABEL_LENGTH + 1]; //Name of cert label
//SSL requires at least Version 4 of MQCNO (Connection Options),
// Version 7 of MQCD(Channel Definition),
// Version 1 of MQCSP(Security Parameters) and
// Version 4 of MQSCO (SSL Configuration Options) - Not currently used, set in mqcd
cno.Version = MQCNO_VERSION_5;
//Certlabel requires version 11
cd.Version = MQCD_VERSION_11;
csp.Version = MQCSP_CURRENT_VERSION;
strcpy(channelName, "SYSTEM.DEF.SVRCONN"); //Setup default channel name
setbuf(stdout, NULL); //Dont buffer output to stdout
if (sruDebug > 0)
printf("qmmonitor2 start\n");
/******************************************************************/
/* Parse arguments */
/******************************************************************/
for (count = 1; count < argc; count++)
{
if (strncmp("-m", argv[count], 2) == 0)
{
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc))
{
parg=argv[++count];
}
strncpy(QMName, parg, MQ_Q_MGR_NAME_LENGTH);
}
/* Commenting this block out as we use -s to specify channel
else if (strncmp("-s", argv[count], 2) == 0)
{
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc))
{
parg=argv[++count];
}
strncpy(ModelQName, parg, MQ_Q_NAME_LENGTH);
}
*/
else if (strncmp("-s", argv[count], 2) == 0) {
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc)) {
parg = argv[++count];
}
strncpy(channelName, parg, MQ_CHANNEL_NAME_LENGTH);
}
else if (strncmp("-c", argv[count], 2) == 0)
{
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc))
{
parg=argv[++count];
}
if (MAX_CLASS_COUNT > ClassCount)
strncpy(Class[ClassCount++], parg, MAX_CLASS_SIZE);
}
else if (strncmp("-t", argv[count], 2) == 0)
{
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc))
{
parg = argv[++count];
}
if (MAX_TYPE_COUNT > TypeCount)
strncpy(Type[TypeCount++], parg, MAX_TYPE_SIZE);
if (ClassCount)
ClassTypeCount[ClassCount - 1]++;
}
else if (strncmp("-o", argv[count], 2) == 0)
{
int i = 0;
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc))
{
parg=argv[++count];
}
for (; parg[i] != '\0'; i++)
{
if (parg[i] == '/') parg[i] = '&';
}
if (TypeCount)
TypeObjName[TypeCount - 1] = parg;
if ( ( ClassCount )
&& ( NULL == ClassObjName[ClassCount - 1] ) )
ClassObjName[ClassCount - 1] = parg;
}
else if (strncmp("-d", argv[count], 2) == 0)
{
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc))
{
parg = argv[++count];
}
sruDebug = atoi(parg);
}
else if (strncmp("-n", argv[count], 2) == 0)
{
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc))
{
parg = argv[++count];
}
MaxGets = atoi( parg );
}
else if (strncmp("-h", argv[count], 2) == 0)
{
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc))
{
parg = argv[++count];
}
strncpy(hostName, parg, MQ_CONN_NAME_LENGTH);
clientMode = 1;
}
else if (strncmp("-p", argv[count], 2) == 0)
{
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc))
{
parg = argv[++count];
}
portNumber = atoi(parg);
/*Commenting this out as we use the -p option to specify a port*/
/*meta_prefix = parg;*/ /* must not end with '/' */
/*if (meta_prefix[strlen(meta_prefix) - 1] == '/')
{
printf(sruUsageString, argv[0]);
rc = ERROR_RETURN;
goto mod_exit;
}*/
}
else if (strncmp("-s", argv[count], 2) == 0)
{
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc)) {
parg = argv[++count];
}
strncpy(channelName, parg, MQ_CHANNEL_NAME_LENGTH);
} else if (strncmp("-?", argv[count], 2) == 0) {
if ((*(parg = &(argv[count][2])) == '\0')) {
printf("Usage: qmmonitor2 [-m QMName] | [-p port] | [-s channelName] | [-h hostname] | [-n NumberStatsMsgsToRecv] | [-u Userid] | [-v Password] | [-l CipherSpec] | [-w certlabel] |\n [-c ClassSelection] | [-t TypeSelection] | [-o ObjectName] | [-d debugLevel]\n");
printf("Example: qmmonitor2 -m PERF0 -p 1420 -s SYSTEM.DEF.SVRCONN -h remoteHost -n 10 -c CPU -t SystemSummary\n");
printf("Example: qmmonitor2 -m PERF0 -p 1420 -s SYSTEM.DEF.SVRCONN -h remoteHost -n 10 -c STATQ -t PUT -o REQUEST1\n");
goto mod_exit;
}
strncpy(channelName, parg, MQ_CHANNEL_NAME_LENGTH);
} else if (strncmp("-a", argv[count], 2) == 0) {
if ((*(parg = &(argv[count][2])) == '\0')) {
autoMode = 1;
}
} else if (strncmp("-u", argv[count], 2) == 0) {
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc)) {
parg = argv[++count];
}
strncpy(userid, parg, MQ_USER_ID_LENGTH);
} else if (strncmp("-v", argv[count], 2) == 0) {
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc)) {
parg = argv[++count];
}
strncpy(password, parg, MQ_CSP_PASSWORD_LENGTH);
} else if (strncmp("-l", argv[count], 2) == 0) {
// If you are using TLS, then you will need to create a local CCDT using runmqsc -n with clientconn chan details
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc)) {
parg = argv[++count];
}
strncpy(cipherSpec, parg, MQ_SSL_CIPHER_SPEC_LENGTH);
} else if (strncmp("-w", argv[count], 2) == 0) {
// Can only be used with '-l' option above
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc)) {
parg = argv[++count];
}
strncpy(certLabel, parg, MQ_CERT_LABEL_LENGTH);
}
else
{
printf(sruUsageString, argv[0]);
rc = ERROR_RETURN;
goto mod_exit;
}
}
if (clientMode) {
if (strcmp(userid, "") != 0) {
csp.AuthenticationType = MQCSP_AUTH_USER_ID_AND_PWD;
csp.CSPUserIdPtr = &userid[0];
csp.CSPUserIdLength = (MQLONG) strlen(&userid[0]);
csp.CSPPasswordPtr = &password[0];
csp.CSPPasswordLength = (MQLONG) strlen(&password[0]);
}
// At the moment only server bindings are attempted; allow client bindings
cno.Options |= MQCNO_CLIENT_BINDING;
// Create connectionName from hostname and port
char tempName[MQ_CONN_NAME_LENGTH];
sprintf(tempName, "%s(%d)", hostName, portNumber);
strncpy(cd.ConnectionName, tempName, MQ_CONN_NAME_LENGTH);
strncpy(cd.ChannelName, channelName, MQ_CHANNEL_NAME_LENGTH);
if (strcmp(userid, "") != 0) {
printf("Connecting to host: %s using channel: %s and userid: %s\n", cd.ConnectionName, cd.ChannelName, &userid[0]);
} else {
printf("Connecting to host: %s using channel: %s without flowing userid\n", cd.ConnectionName, cd.ChannelName);
}
if (strcmp(cipherSpec, "") != 0) {
strncpy(cd.SSLCipherSpec, cipherSpec, MQ_SSL_CIPHER_SPEC_LENGTH);
printf("Connecting using SSL Cipher: %s\n", cd.SSLCipherSpec);
strncpy(cd.CertificateLabel, certLabel, MQ_CERT_LABEL_LENGTH);
printf("Connecting using Certificate Label: %s\n", cd.CertificateLabel);
}
cno.ClientConnPtr = &cd;
cno.SecurityParmsPtr = &csp;
}
/******************************************************************/
/* */
/* Connect to queue manager */
/* */
/******************************************************************/
MQCONNX(QMName, /* queue manager */
&cno, /* connection options */
&Hcon, /* connection handle */
&CompCode, /* completion code */
&Reason); /* reason code */
/* report reason and stop if it failed */
if (CompCode == MQCC_FAILED)
{
printf("MQCONNX ended with reason code %d\n", Reason);
rc = ERROR_RETURN;
goto mod_exit;
}
/* if there was a warning report the cause and continue */
if (CompCode == MQCC_WARNING)
{
printf("MQCONN generated a warning with reason code %d\n", Reason);
printf("Continuing...\n");
}
/* Find the name of the queue manager that we connected to */
rc = sruQueryQMName();
if (rc)
goto mod_exit;
/******************************************************************/
/* */
/* Create a TDQ on which to receive publications. */
/* */
/******************************************************************/
if (ModelQName[0] != '\0')
strncpy( od.ObjectName, ModelQName, MQ_Q_NAME_LENGTH);
else
strcpy( od.ObjectName, "SYSTEM.DEFAULT.MODEL.QUEUE");
MQOPEN( Hcon
, &od
, MQOO_INPUT_EXCLUSIVE
, &Hobj
, &CompCode
, &Reason );
if (MQCC_OK != CompCode)
{
printf("MQOPEN ended with reason code %d\n", Reason);
rc = ERROR_RETURN;
goto mod_exit;
}
/******************************************************************/
/* */
/* Discover which resource usage information is supported by */