1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package goldengate.snmp.r66;
21
22 import goldengate.common.logging.GgInternalLogger;
23 import goldengate.common.logging.GgInternalLoggerFactory;
24 import goldengate.snmp.GgSnmpAgent;
25 import goldengate.snmp.interf.GgInterfaceMib;
26 import goldengate.snmp.utils.GgEntry;
27 import goldengate.snmp.utils.GgMORow;
28 import goldengate.snmp.utils.GgMOScalar;
29 import goldengate.snmp.utils.GgUptime;
30 import goldengate.snmp.utils.MemoryGauge32;
31 import goldengate.snmp.utils.MemoryGauge32.MemoryType;
32
33 import org.snmp4j.agent.DuplicateRegistrationException;
34 import org.snmp4j.agent.MOServer;
35 import org.snmp4j.agent.mo.MOAccessImpl;
36 import org.snmp4j.agent.mo.snmp.SNMPv2MIB;
37 import org.snmp4j.agent.mo.snmp.SysUpTime;
38 import org.snmp4j.smi.Integer32;
39 import org.snmp4j.smi.OID;
40 import org.snmp4j.smi.OctetString;
41 import org.snmp4j.smi.SMIConstants;
42 import org.snmp4j.smi.TimeTicks;
43
44
45
46
47
48
49
50 public abstract class GgPrivateMib implements GgInterfaceMib {
51
52
53
54 private static GgInternalLogger logger = GgInternalLoggerFactory
55 .getLogger(GgPrivateMib.class);
56
57
58
59
60
61 public String textualSysDecr = null;
62
63
64
65
66 public OID ggObjectId = null;
67
68
69
70
71 public String contactName = "Nobody";
72
73
74
75
76 public String textualName = "OpenR66";
77
78
79
80
81 public String address = "somewhere";
82
83
84
85
86
87
88 public int service = 72;
89
90
91
92
93 public SysUpTime upTime = null;
94
95
96
97
98
99
100
101 public String applicationProtocolBase = null;
102
103
104
105
106 public OID applicationProtocol = null;
107
108
109
110
111 public int smiPrivateCode = 66666;
112
113
114
115
116 public int smiTypeGoldengate = 66;
117
118
119
120 public String srootOIDGoldenGate;
121
122
123
124 public OID rootOIDGoldenGate;
125
126
127
128
129 public OID rootOIDGoldenGateNotif;
130
131
132
133
134 public OID rootOIDGoldenGateNotifStartOrShutdown;
135
136
137
138
139 public OID rootOIDGoldenGateInfo;
140
141
142
143 public GgMORow rowInfo;
144
145
146
147
148 public OID rootOIDGoldenGateGlobal;
149
150
151
152 public GgMORow rowGlobal;
153
154
155
156
157 public OID rootOIDGoldenGateGlobalUptime;
158
159
160
161
162 public GgMOScalar scalarUptime = null;
163
164
165
166
167 public OID rootOIDGoldenGateDetailed;
168
169
170
171 public GgMORow rowDetailed;
172
173
174
175
176 public OID rootOIDGoldenGateError;
177
178
179
180 public GgMORow rowError;
181
182
183
184
185 public SNMPv2MIB snmpv2;
186
187
188
189
190 public GgSnmpAgent agent;
191
192
193
194
195
196
197
198
199
200
201
202 public GgPrivateMib(String sysdesc, int port, int smiPrivateCodeFinal,
203 int typeGoldenGateObject, String scontactName, String stextualName,
204 String saddress, int iservice) {
205 textualSysDecr = sysdesc;
206 smiPrivateCode = smiPrivateCodeFinal;
207 smiTypeGoldengate = typeGoldenGateObject;
208 contactName = scontactName;
209 textualName = stextualName;
210 address = saddress;
211 service = iservice;
212 srootOIDGoldenGate = rootEnterpriseMib.toString() + "." +
213 smiPrivateCode + "." + smiTypeGoldengate;
214 applicationProtocolBase = srootOIDGoldenGate + ".1.1.4.";
215 ggObjectId = new OID(srootOIDGoldenGate);
216 applicationProtocol = new OID(applicationProtocolBase + port);
217 rootOIDGoldenGate = new OID(srootOIDGoldenGate);
218 rootOIDGoldenGateInfo = new OID(srootOIDGoldenGate + ".1");
219 rootOIDGoldenGateGlobal = new OID(srootOIDGoldenGate + ".2");
220 rootOIDGoldenGateGlobalUptime = new OID(
221 rootOIDGoldenGateGlobal.toString() + "." +
222 goldenGateGlobalValuesIndex.applUptime.getOID() + ".0");
223 rootOIDGoldenGateDetailed = new OID(srootOIDGoldenGate + ".3");
224 rootOIDGoldenGateError = new OID(srootOIDGoldenGate + ".4");
225 rootOIDGoldenGateNotif = new OID(srootOIDGoldenGate + ".5.1");
226 rootOIDGoldenGateNotifStartOrShutdown = new OID(srootOIDGoldenGate +
227 ".5.1.1.1");
228 }
229
230
231
232
233
234
235 @Override
236 public void setAgent(GgSnmpAgent agent) {
237 this.agent = agent;
238 }
239
240
241
242
243
244
245 @Override
246 public OID getBaseOidStartOrShutdown() {
247 return rootOIDGoldenGateNotifStartOrShutdown;
248 }
249
250
251
252
253
254
255 @Override
256 public SNMPv2MIB getSNMPv2MIB() {
257 return snmpv2;
258 }
259
260
261
262
263
264
265
266 protected void agentRegisterSystem() throws DuplicateRegistrationException {
267
268
269
270
271 agent.unregisterManagedObject(agent.getSnmpv2MIB());
272
273
274
275 snmpv2 = new SNMPv2MIB(new OctetString(textualSysDecr), ggObjectId,
276 new Integer32(service));
277 snmpv2.setContact(new OctetString(contactName));
278 snmpv2.setLocation(new OctetString(address));
279 snmpv2.setName(new OctetString(textualName));
280 snmpv2.registerMOs(agent.getServer(), null);
281 if (logger.isDebugEnabled()) {
282 logger.debug("SNMPV2: " + snmpv2.getContact() + ":" +
283 snmpv2.getDescr() + ":" + snmpv2.getLocation() + ":" +
284 snmpv2.getName() + ":" + snmpv2.getObjectID() + ":" +
285 snmpv2.getServices() + ":" + snmpv2.getUpTime());
286 }
287
288 upTime = snmpv2.getSysUpTime();
289 }
290
291
292
293
294
295
296 protected void defaultAgentRegisterGoldenGateMib()
297 throws DuplicateRegistrationException {
298
299 rowInfo = new GgMORow(this, rootOIDGoldenGateInfo,
300 goldenGateDefinition, MibLevel.staticInfo.ordinal());
301 rowInfo.registerMOs(agent.getServer(), null);
302
303 rowGlobal = new GgMORow(this, rootOIDGoldenGateGlobal,
304 goldenGateGlobalValues, MibLevel.globalInfo.ordinal());
305 GgMOScalar memoryScalar = rowGlobal.row[goldenGateGlobalValuesIndex.memoryTotal
306 .ordinal()];
307 memoryScalar.setValue(new MemoryGauge32(MemoryType.TotalMemory));
308 memoryScalar = rowGlobal.row[goldenGateGlobalValuesIndex.memoryFree
309 .ordinal()];
310 memoryScalar.setValue(new MemoryGauge32(MemoryType.FreeMemory));
311 memoryScalar = rowGlobal.row[goldenGateGlobalValuesIndex.memoryUsed
312 .ordinal()];
313 memoryScalar.setValue(new MemoryGauge32(MemoryType.UsedMemory));
314 rowGlobal.registerMOs(agent.getServer(), null);
315
316 scalarUptime = rowGlobal.row[goldenGateGlobalValuesIndex.applUptime
317 .ordinal()];
318 scalarUptime.setValue(new GgUptime(upTime));
319 changeStatus(OperStatus.restarting);
320 changeStatus(OperStatus.up);
321
322 rowDetailed = new GgMORow(this, rootOIDGoldenGateDetailed,
323 goldenGateDetailedValues, MibLevel.detailedInfo.ordinal());
324 rowDetailed.registerMOs(agent.getServer(), null);
325
326 rowError = new GgMORow(this, rootOIDGoldenGateError,
327 goldenGateErrorValues, MibLevel.errorInfo.ordinal());
328 rowError.registerMOs(agent.getServer(), null);
329 }
330
331
332
333
334
335
336 protected abstract void agentRegisterGoldenGateMib()
337 throws DuplicateRegistrationException;
338
339
340
341
342 protected void agentUnregisterMibs() {
343 logger.debug("UnRegisterGoldenGate");
344 rowInfo.unregisterMOs(agent.getServer(), agent.getDefaultContext());
345 rowGlobal.unregisterMOs(agent.getServer(), agent.getDefaultContext());
346 rowDetailed.unregisterMOs(agent.getServer(), agent.getDefaultContext());
347 rowError.unregisterMOs(agent.getServer(), agent.getDefaultContext());
348 }
349
350
351
352
353
354
355
356 @Override
357 public void registerMOs(MOServer server, OctetString context)
358 throws DuplicateRegistrationException {
359 agentRegisterSystem();
360 agentRegisterGoldenGateMib();
361 }
362
363
364
365
366
367
368
369 @Override
370 public void unregisterMOs(MOServer server, OctetString context) {
371 agentUnregisterMibs();
372 }
373
374
375
376
377
378
379 public void changeStatus(OperStatus status) {
380 GgMOScalar statusScalar = rowGlobal.row[goldenGateGlobalValuesIndex.applOperStatus
381 .ordinal()];
382 Integer32 var = (Integer32) statusScalar.getValue();
383 if (var.getValue() != status.status) {
384 var.setValue(status.status);
385 GgMOScalar lastTimeScalar = rowGlobal.row[goldenGateGlobalValuesIndex.applLastChange
386 .ordinal()];
387 TimeTicks time = (TimeTicks) lastTimeScalar.getValue();
388 time.setValue(upTime.get().getValue());
389 }
390 }
391
392
393
394
395
396
397 public static enum MibLevel {
398 staticInfo, globalInfo, detailedInfo, errorInfo, trapInfo
399 }
400
401
402
403
404
405
406 public static enum NotificationElements {
407 TrapShutdown(1),
408 TrapError(2),
409 TrapWarning(3),
410 TrapOverloaded(4),
411 InfoTask(5);
412
413 public int[] oid;
414
415 private NotificationElements(int oid) {
416 this.oid = new int[] {
417 oid };
418 }
419
420 public OID getOID(OID oidBase) {
421 return new OID(oidBase.getValue(), this.oid);
422 }
423
424 public OID getOID(OID oidBase, int rank) {
425 int[] ids = new int[] {
426 this.oid[0], rank };
427 return new OID(oidBase.getValue(), ids);
428 }
429 }
430
431
432
433
434
435 public static enum NotificationTasks {
436 globalStepInfo,
437 stepInfo,
438 rankFileInfo,
439 stepStatusInfo,
440 filenameInfo,
441 originalNameInfo,
442 idRuleInfo,
443 modeTransInfo,
444 retrieveModeInfo,
445 startTransInfo,
446 infoStatusInfo,
447 requesterInfo,
448 requestedInfo,
449 specialIdInfo;
450
451 public int getOID() {
452 return this.ordinal() + 1;
453 }
454 }
455
456
457
458
459
460 public static enum goldenGateDefinitionIndex {
461 applName,
462 applServerName,
463 applVersion,
464 applDescription,
465 applURL,
466 applApplicationProtocol;
467
468 public int getOID() {
469 return this.ordinal() + 1;
470 }
471 }
472
473
474
475 public static GgEntry[] goldenGateDefinition = {
476
477 new GgEntry(SMIConstants.SYNTAX_OCTET_STRING,
478 MOAccessImpl.ACCESS_READ_ONLY),
479
480 new GgEntry(SMIConstants.SYNTAX_OCTET_STRING,
481 MOAccessImpl.ACCESS_READ_ONLY),
482
483 new GgEntry(SMIConstants.SYNTAX_OCTET_STRING,
484 MOAccessImpl.ACCESS_READ_ONLY),
485
486 new GgEntry(SMIConstants.SYNTAX_OCTET_STRING,
487 MOAccessImpl.ACCESS_READ_ONLY),
488
489 new GgEntry(SMIConstants.SYNTAX_OCTET_STRING,
490 MOAccessImpl.ACCESS_READ_ONLY),
491
492 new GgEntry(SMIConstants.SYNTAX_OBJECT_IDENTIFIER,
493 MOAccessImpl.ACCESS_READ_ONLY) };
494
495
496
497
498
499 public static enum goldenGateGlobalValuesIndex {
500 applUptime,
501 applOperStatus,
502 applLastChange,
503 applInboundAssociations,
504 applOutboundAssociations,
505 applAccumInboundAssociations,
506 applAccumOutboundAssociations,
507 applLastInboundActivity,
508 applLastOutboundActivity,
509 applRejectedInboundAssociations,
510 applFailedOutboundAssociations,
511 applInboundBandwidthKBS,
512 applOutboundBandwidthKBS,
513 nbInfoUnknown,
514 nbInfoNotUpdated,
515 nbInfoInterrupted,
516 nbInfoToSubmit,
517 nbInfoError,
518 nbInfoRunning,
519 nbInfoDone,
520 nbStepAllTransfer,
521 memoryTotal,
522 memoryFree,
523 memoryUsed,
524 nbThreads,
525 nbNetworkConnection;
526
527 public int getOID() {
528 return this.ordinal() + 1;
529 }
530 }
531
532
533
534 public static GgEntry[] goldenGateGlobalValues = {
535
536 new GgEntry(SMIConstants.SYNTAX_TIMETICKS,
537 MOAccessImpl.ACCESS_READ_ONLY),
538
539 new GgEntry(SMIConstants.SYNTAX_INTEGER,
540 MOAccessImpl.ACCESS_READ_ONLY),
541
542 new GgEntry(SMIConstants.SYNTAX_TIMETICKS,
543 MOAccessImpl.ACCESS_READ_ONLY),
544
545 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
546 MOAccessImpl.ACCESS_READ_ONLY),
547
548 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
549 MOAccessImpl.ACCESS_READ_ONLY),
550
551 new GgEntry(SMIConstants.SYNTAX_COUNTER32,
552 MOAccessImpl.ACCESS_READ_ONLY),
553
554 new GgEntry(SMIConstants.SYNTAX_COUNTER32,
555 MOAccessImpl.ACCESS_READ_ONLY),
556
557 new GgEntry(SMIConstants.SYNTAX_TIMETICKS,
558 MOAccessImpl.ACCESS_READ_ONLY),
559
560 new GgEntry(SMIConstants.SYNTAX_TIMETICKS,
561 MOAccessImpl.ACCESS_READ_ONLY),
562
563 new GgEntry(SMIConstants.SYNTAX_COUNTER32,
564 MOAccessImpl.ACCESS_READ_ONLY),
565
566 new GgEntry(SMIConstants.SYNTAX_COUNTER32,
567 MOAccessImpl.ACCESS_READ_ONLY),
568
569
570 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
571 MOAccessImpl.ACCESS_READ_ONLY),
572
573 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
574 MOAccessImpl.ACCESS_READ_ONLY),
575
576
577 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
578 MOAccessImpl.ACCESS_READ_ONLY),
579
580 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
581 MOAccessImpl.ACCESS_READ_ONLY),
582
583 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
584 MOAccessImpl.ACCESS_READ_ONLY),
585
586 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
587 MOAccessImpl.ACCESS_READ_ONLY),
588
589 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
590 MOAccessImpl.ACCESS_READ_ONLY),
591
592 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
593 MOAccessImpl.ACCESS_READ_ONLY),
594
595 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
596 MOAccessImpl.ACCESS_READ_ONLY),
597
598
599 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
600 MOAccessImpl.ACCESS_READ_ONLY),
601
602 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
603 MOAccessImpl.ACCESS_READ_ONLY),
604
605 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
606 MOAccessImpl.ACCESS_READ_ONLY),
607
608 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
609 MOAccessImpl.ACCESS_READ_ONLY),
610
611 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
612 MOAccessImpl.ACCESS_READ_ONLY),
613
614 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
615 MOAccessImpl.ACCESS_READ_ONLY) };
616
617
618
619
620
621 public static enum goldenGateDetailedValuesIndex {
622 nbStepNotask,
623 nbStepPretask,
624 nbStepTransfer,
625 nbStepPosttask,
626 nbStepAllDone,
627 nbStepError,
628 nbAllRunningStep,
629 nbRunningStep,
630 nbInitOkStep,
631 nbPreProcessingOkStep,
632 nbTransferOkStep,
633 nbPostProcessingOkStep,
634 nbCompleteOkStep;
635
636 public int getOID() {
637 return this.ordinal() + 1;
638 }
639 }
640
641
642
643 public static GgEntry[] goldenGateDetailedValues = {
644
645 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
646 MOAccessImpl.ACCESS_READ_ONLY),
647
648 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
649 MOAccessImpl.ACCESS_READ_ONLY),
650
651 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
652 MOAccessImpl.ACCESS_READ_ONLY),
653
654 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
655 MOAccessImpl.ACCESS_READ_ONLY),
656
657 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
658 MOAccessImpl.ACCESS_READ_ONLY),
659
660 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
661 MOAccessImpl.ACCESS_READ_ONLY),
662
663
664 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
665 MOAccessImpl.ACCESS_READ_ONLY),
666
667 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
668 MOAccessImpl.ACCESS_READ_ONLY),
669
670 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
671 MOAccessImpl.ACCESS_READ_ONLY),
672
673 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
674 MOAccessImpl.ACCESS_READ_ONLY),
675
676 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
677 MOAccessImpl.ACCESS_READ_ONLY),
678
679 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
680 MOAccessImpl.ACCESS_READ_ONLY),
681
682 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
683 MOAccessImpl.ACCESS_READ_ONLY) };
684
685
686
687
688
689 public static enum goldenGateErrorValuesIndex {
690 nbStatusConnectionImpossible,
691 nbStatusServerOverloaded,
692 nbStatusBadAuthent,
693 nbStatusExternalOp,
694 nbStatusTransferError,
695 nbStatusMD5Error,
696 nbStatusDisconnection,
697 nbStatusFinalOp,
698 nbStatusUnimplemented,
699 nbStatusInternal,
700 nbStatusWarning,
701 nbStatusQueryAlreadyFinished,
702 nbStatusQueryStillRunning,
703 nbStatusNotKnownHost,
704 nbStatusQueryRemotelyUnknown,
705 nbStatusCommandNotFound,
706 nbStatusPassThroughMode,
707 nbStatusRemoteShutdown,
708 nbStatusShutdown,
709 nbStatusRemoteError,
710 nbStatusStopped,
711 nbStatusCanceled,
712 nbStatusFileNotFound,
713 nbStatusUnknown;
714
715 public int getOID() {
716 return this.ordinal() + 1;
717 }
718 }
719
720
721
722 public static GgEntry[] goldenGateErrorValues = {
723
724
725 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
726 MOAccessImpl.ACCESS_READ_ONLY),
727
728 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
729 MOAccessImpl.ACCESS_READ_ONLY),
730
731 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
732 MOAccessImpl.ACCESS_READ_ONLY),
733
734 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
735 MOAccessImpl.ACCESS_READ_ONLY),
736
737 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
738 MOAccessImpl.ACCESS_READ_ONLY),
739
740 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
741 MOAccessImpl.ACCESS_READ_ONLY),
742
743 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
744 MOAccessImpl.ACCESS_READ_ONLY),
745
746 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
747 MOAccessImpl.ACCESS_READ_ONLY),
748
749 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
750 MOAccessImpl.ACCESS_READ_ONLY),
751
752 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
753 MOAccessImpl.ACCESS_READ_ONLY),
754
755 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
756 MOAccessImpl.ACCESS_READ_ONLY),
757
758 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
759 MOAccessImpl.ACCESS_READ_ONLY),
760
761 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
762 MOAccessImpl.ACCESS_READ_ONLY),
763
764 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
765 MOAccessImpl.ACCESS_READ_ONLY),
766
767 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
768 MOAccessImpl.ACCESS_READ_ONLY),
769
770 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
771 MOAccessImpl.ACCESS_READ_ONLY),
772
773 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
774 MOAccessImpl.ACCESS_READ_ONLY),
775
776 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
777 MOAccessImpl.ACCESS_READ_ONLY),
778
779 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
780 MOAccessImpl.ACCESS_READ_ONLY),
781
782 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
783 MOAccessImpl.ACCESS_READ_ONLY),
784
785 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
786 MOAccessImpl.ACCESS_READ_ONLY),
787
788 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
789 MOAccessImpl.ACCESS_READ_ONLY),
790
791 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
792 MOAccessImpl.ACCESS_READ_ONLY),
793
794 new GgEntry(SMIConstants.SYNTAX_GAUGE32,
795 MOAccessImpl.ACCESS_READ_ONLY) };
796
797
798
799
800
801 public static enum OperStatus {
802 up(1), down(2), halted(3), congested(4), restarting(5), quiescing(6);
803
804 public int status;
805
806 private OperStatus(int status) {
807 this.status = status;
808 }
809 }
810 }