-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathqmmonitor2.c
executable file
·1898 lines (1787 loc) · 83.1 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
/********************************************************************/
/* */
/* Program name: qmmonitor2 */
/* */
/* Description: Extension of Sample C program that subscribes to */
/* MQ resource usage publications and formats the */
/* published PCF data. */
/* Examples */
/* qmmonitor -m PERF0 -c CPU -t SystemSummary -h bellona010 -n 192 */
/* */
/********************************************************************/
/*
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
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
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
Register Type : 0002 0000 CONNDISC MQCONN and MQDISC
TopicLen: 57
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
Register Type : 0003 0000 OPENCLOSE MQOPEN and MQCLOSE
TopicLen: 56
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATQ/OPENCLOSE
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
Register Type : 0004 0000 INSTANCE Application instance statistics
TopicLen: 57
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/STATAPP/INSTANCE
Register Type : 0005 0000 REPLICATION Native HA Replication statistics
TopicLen: 63
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/METADATA/NHAREPLICA/REPLICATION
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
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
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
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
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
Update Type :0001 0002 $SYS/MQ/INFO/QMGR/PERF0/Monitor/DISK/Log
TopicLen: 40
Topic: $SYS/MQ/INFO/QMGR/PERF0/Monitor/DISK/LogTMQI/PUBLISH
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
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
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
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
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
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
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
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
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
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
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
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
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
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/INSTANCE
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
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
*/
#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/INFO/QMGR/%s/Monitor/METADATA/"
#if MQAT_DEFAULT == MQAT_WINDOWS_NT
#define Int64 "I64"
#elif defined(MQ_64_BIT)
#define Int64 "l"
#else
#define Int64 "ll"
#endif
/*********************************************************************/
/* */
/* 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;
sruELEM *elem;
MQLONG flags;
char Buffer[1];
} sruTYPE;
/*********************************************************************/
/* MQ resource usage publications are associated with a class. */
/* The classes represnt 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;
sruTYPE * type;
MQLONG flags;
char Buffer[1];
} sruCLASS;
/*********************************************************************/
/* */
/* Data globally addressable within amqsruaa.c */
/* */
/*********************************************************************/
static char QMName[50]; /* queue manager 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 runmqsc[] = "runmqsc";
static char mqserver[] = "MQSERVER";
static char collectQueueDepth[] = "display queue(*) where (curdepth gt 0)";
/*********************************************************************/
/* */
/* Prototypes for functions local to amqsruaa.c */
/* */
/*********************************************************************/
int sruPromptForClass();
int sruPromptForType();
int sruSubscribe();
int sruDiscover();
int sruFormatMessage(PMQCFH buffer);
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 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 flags);
int sruUpdateType(MQLONG class_id, MQLONG type_id, char * topic,
MQLONG topic_len);
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);
} 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);
}
ClassTypeCount[ClassCount - 1]++;
} else if (strncmp("-o", argv[count], 2) == 0) {
if ((*(parg = &(argv[count][2])) == '\0') && (count + 1 < argc)) {
parg = argv[++count];
}
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);
} 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);
}
}
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);
goto mod_exit;
}
/* if there was a warning report the cause and continue */
if (CompCode == MQCC_WARNING) {
printf("MQCONNX generated a warning with reason code %d\n", Reason);
printf("Continuing...\n");
}
/******************************************************************/
/* */
/* Create a TDQ on which to receive publications. */
/* */
/******************************************************************/
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);
goto mod_exit;
}
/******************************************************************/
/* */
/* Discover which resource usage information is supported by */
/* the queue manager that we're connected to by subscribing */
/* to the meta-data topics and processing the resulting */
/* publications. */
/* */
/******************************************************************/
rc = sruDiscover();
if (rc) {
goto mod_exit;
}
if (autoMode) {
printf("Entering automatic mode\n");
//First stage of automatic monitoring is to collect any useful static data from the QM
char commandLine[256];
sprintf(commandLine, "%s/TCP/%s(%d)", channelName, hostName, portNumber);
printf("CommandLine: %s", commandLine);
//Set envvar and overwrite if already exists
setenv(mqserver, commandLine, 1);
if (clientMode) {
// sprintf(commandLine, "echo $MQSERVER > /tmp/out; echo '%s' | %s -c %s >> /tmp/out", collectQueueDepth, runmqsc, QMName);
sprintf(commandLine, "echo '%s' | %s -c %s", collectQueueDepth, runmqsc, QMName);
} else {
sprintf(commandLine, "echo $MQSERVER > /tmp/out; echo '%s' | %s %s >> /tmp/out%s %s", collectQueueDepth, runmqsc, QMName);
}
system(commandLine);
FILE *fp = popen(commandLine, "r");
char line[256];
while (fgets(line, 255, fp) != NULL)
printf("LINE:%s\n", line);
int status = pclose(fp);
}
/******************************************************************/
/* */
/* If no class/type was explicitly requested then prompt for */
/* appropriate input. */
/* */
/******************************************************************/
if (0 == ClassCount) {
if (sruPromptForClass() < 0) {
goto mod_exit;
}
}
if (0 == TypeCount) {
if (sruPromptForType() < 0) {
goto mod_exit;
}
}
/******************************************************************/
/* */
/* Subscribe for messages on the appropriate topics. */
/* */
/******************************************************************/
rc = sruSubscribe();
if (rc) {
goto mod_exit;
}
/******************************************************************/
/* */
/* Get messages from the destination queue */
/* Loop until there is a failure, or the requested number */
/* of publications has been processed. */
/* */
/******************************************************************/
gmo.Options = MQGMO_WAIT /* wait for new messages */
| MQGMO_NO_SYNCPOINT /* no transaction */
| MQGMO_CONVERT /* convert if necessary */
| MQGMO_FAIL_IF_QUIESCING /* Dont hold up shutdown */
| MQGMO_NO_PROPERTIES; /* dont return properties */
gmo.WaitInterval = 30000; /* 30 second limit for waiting */
gmo.Version = MQGMO_CURRENT_VERSION;
gmo.MatchOptions = MQMO_NONE;
while (CompCode != MQCC_FAILED) {
if (MaxGets >= 0) {
if (GetCount >= MaxGets)
break;
}
GetCount++;
/****************************************************************/
/* Note that we don't (currently) expect any large resource */
/* usage messages, and when dealing with small messages it's */
/* less important (performance) to use a dynamically sized */
/* buffer. */
/****************************************************************/
buflen = sizeof(buffer); /* fixed buffer size available for GET */
/****************************************************************/
/* */
/* MQGET sets Encoding and CodedCharSetId to the values in */
/* the message returned, so these fields should be reset to */
/* the default values before every call, as MQGMO_CONVERT is */
/* specified. */
/* */
/****************************************************************/
md.Encoding = MQENC_NATIVE;
md.CodedCharSetId = MQCCSI_Q_MGR;
if (sruDebug > 0) {
printf("Calling MQGET : %d seconds wait time\n", gmo.WaitInterval / 1000);
}
MQGET(Hcon, /* connection handle */
Hobj, /* object handle */
&md, /* message descriptor */
&gmo, /* get message options */
buflen, /* buffer length */
buffer, /* message buffer */
&messlen, /* message length */
&CompCode, /* completion code */
&Reason); /* reason code */
/* report reason, if any */
if (Reason != MQRC_NONE) {
if (Reason == MQRC_NO_MSG_AVAILABLE) { /* special report for normal end */
printf("no more messages\n");
} else /* general report for other reasons */{
printf("MQGET ended with reason code %d\n", Reason);
/* treat truncated message as a failure for this sample */
/* as none of the current resource usage publications is */
/* expected to be more than 4096 bytes long. */
if (Reason == MQRC_TRUNCATED_MSG_FAILED) {
CompCode = MQCC_FAILED;
}
}
}
/****************************************************************/
/* Format and display each message received */
/****************************************************************/
if (CompCode != MQCC_FAILED) {
printf("Publication received PutDate:%8.8s PutTime:%8.8s", md.PutDate, md.PutTime);
sruFormatMessage((PMQCFH) buffer);
printf("\n");
}
}
/******************************************************************/
/* Subscription handles, and the TDQ handle, are implicitly */
/* closed at MQDISC. */
/* */
/******************************************************************/
/******************************************************************/
/* */
/* Disconnect from the queue manager. */
/* */
/******************************************************************/
if (Hcon != MQHC_UNUSABLE_HCONN) {
MQDISC(&Hcon, /* connection handle */
&CompCode, /* completion code */
&Reason); /* reason code */
/* report reason, if any */
if (Reason != MQRC_NONE) {
printf("MQDISC ended with reason code %d\n", Reason);
}
}
mod_exit:
/******************************************************************/
/* */
/* END OF AMQSSUBA */
/* */
/******************************************************************/
if (sruDebug > 0) {
printf("qmmonitor end rc=%d\n", rc);
}
return (0);
}
/*********************************************************************/
/* sruPromptForClass: */
/* If no class was explicitly requested then list the classes */
/* supported, prompt for a class, and then validate the supplied */
/* class. */
/* */
/*********************************************************************/
int sruPromptForClass() {
int class = -1;
int strLen = 0;
int idx;
sruCLASS *pClass;
char Buffer[128];
/* List the supported classes */
for (pClass = ClassChain; pClass; pClass = pClass->next) {
printf("%.*s : %.*s\n", pClass->classLen, pClass->Buffer,
pClass->descLen, pClass->Buffer + pClass->classLen);
}
/* Prompt for one of those classes */
printf("Enter Class selection\n");
printf("==> ");
fgets(Buffer, sizeof(Buffer), stdin);
for (idx = 0; idx < sizeof(Buffer); idx++) {
if ((0 == isalpha(Buffer[idx])) && (0 == isdigit(Buffer[idx]))) {
Buffer[idx] = 0;
strLen = idx;
break;
}
}
/* Validate the supplied class is one of those supported */
for (pClass = ClassChain; pClass; pClass = pClass->next) {
if ((strLen == pClass->classLen) && (0 == memcmp(pClass->Buffer, Buffer, strLen))) {
strncpy(Class[ClassCount++], Buffer, MAX_CLASS_SIZE);
return pClass->id;
}
}
printf("Invalid Class (%s) supplied\n", Buffer);
return -1;
}
/*********************************************************************/
/* sruPromptForType: */
/* If no type was explicitly requested then list the types */
/* supported (withing the 'current' class), prompt for a type, and */
/* then validate the supplied type. */
/* */
/*********************************************************************/
int sruPromptForType() {
size_t strLen = 0;
int idx;
sruCLASS *pClass;
sruTYPE *pType;
char Buffer[128];
strLen = strlen(Class[0]);
/* Find the relevant class meta-data */
for (pClass = ClassChain; pClass; pClass = pClass->next) {
if ((pClass->classLen == strLen)
&& (0 == memcmp(Class[0], pClass->Buffer, strLen))) {
/* List the types supported by this class */
for (pType = pClass->type; pType; pType = pType->next) {
printf("%.*s : %.*s\n", pType->typeLen, pType->Buffer,
pType->descLen, pType->Buffer + pType->typeLen);
}
/* Prompt for one of those types */
printf("Enter Type selection\n");
printf("==> ");
fgets(Buffer, sizeof(Buffer), stdin);
for (idx = 0; idx < sizeof(Buffer); idx++) {
if ((0 == isalpha(Buffer[idx]))
&& (0 == isdigit(Buffer[idx]))) {
Buffer[idx] = 0;
strLen = idx;
break;
}
}
/* Validate the supplied type is one of those supported */
for (pType = pClass->type; pType; pType = pType->next) {
if ((strLen == pType->typeLen) && (0 == memcmp(pType->Buffer, Buffer, strLen))) {
strncpy(Type[ClassCount - 1], Buffer, MAX_TYPE_SIZE);
ClassTypeCount[ClassCount - 1]++;
TypeCount++;
return (pType->id);
}
}
printf("Invalid Type (%s) supplied\n", Buffer);
return -1;
}
}
printf("Invalid Class (%s) supplied\n", Class[0]);
return -1;
}
/*********************************************************************/
/* sruSubscribe: */
/* Subscribe to the required resource usage publications. */
/* */
/* Lookup the topic strings under which resource usage information */
/* will be published for the requested class/type pairs. */
/* Subscribe to those topics. */
/* */
/*********************************************************************/
int sruSubscribe() {
MQSD sd = { MQSD_DEFAULT }; /* Subscription Descriptor */
MQHOBJ Hsub = MQHO_NONE; /* object handle */
char Buffer[4096];
char ObjectName[MQ_OBJECT_NAME_LENGTH + 1];
int idx, idx1, idx2, idx3;
size_t strLen;
char *pObjName = 0;
sruCLASS *pClass;
sruTYPE *pType;
MQLONG CompCode, Reason;
if (sruDebug > 0)
printf("ClassCount: %d TypeCount:%d\n", ClassCount, TypeCount);
for (idx1 = 0, idx3 = 0; idx1 < ClassCount; idx1++) {
strLen = strlen(Class[idx1]);
for (pClass = ClassChain; pClass; pClass = pClass->next) {
if ((pClass->classLen == strLen) && (0 == memcmp(pClass->Buffer, Class[idx1], strLen)))
break;
}
if (NULL == pClass) {
printf("Class %s not recognised\n", Class[idx1]);
return -1;
}
for (idx2 = 0; idx2 < ClassTypeCount[idx1]; idx2++, idx3++) {
strLen = strlen(Type[idx3]);
for (pType = pClass->type; pType; pType = pType->next) {
if ((pType->typeLen == strLen) && (0 == memcmp(pType->Buffer, Type[idx3], strLen)))
break;
}
if (pType) {
/********************************************************************************/
/* If the meta-data included MQIAMO_MONITOR_FLAGS_OBJNAME then the data */
/* is available on a per-object basis. Under these circumstances we must have */
/* an object name to qualify the topic. */
/********************************************************************************/
if (pType->flags & MQIAMO_MONITOR_FLAGS_OBJNAME) {
if (TypeObjName[idx3])
pObjName = TypeObjName[idx3];
else if (ClassObjName[idx1])
pObjName = ClassObjName[idx1];
if (!pObjName) {
printf("An object name is required for Class(%.*s) Type(%.*s)\n",
pClass->classLen, pClass->Buffer,
pType->typeLen, pType->Buffer);
printf("Enter object name\n");
printf("==> ");
memset(ObjectName, 0, MQ_OBJECT_NAME_LENGTH);
fgets(ObjectName, sizeof(ObjectName), stdin);
for( idx = 0 ; idx < MQ_OBJECT_NAME_LENGTH ; idx ++ ) {
if( '\n' == ObjectName[idx] ) {
ObjectName[idx] = 0 ;
break;
}
}
ObjectName[MQ_OBJECT_NAME_LENGTH] = 0 ;
pObjName = ObjectName;
}
if (sruDebug > 0)
printf("ObjName: %s\n", pObjName);
sprintf(Buffer, pType->Buffer + pType->typeLen + pType->descLen, pObjName);
sd.ObjectString.VSPtr = Buffer;
sd.ObjectString.VSLength = (MQLONG)(pType->topicLen + strlen(pObjName) - strlen("%s"));
} else {
sd.ObjectString.VSPtr = pType->Buffer + pType->typeLen + pType->descLen;
sd.ObjectString.VSLength = pType->topicLen;
}
if (sruDebug > 0)
printf("Subscribing to topic: %.*s\n",
sd.ObjectString.VSLength, sd.ObjectString.VSPtr);