mooli tayer has uploaded a new change for review. Change subject: notifier: modify the oid schema for SNMP notification. ......................................................................
notifier: modify the oid schema for SNMP notification. Change-Id: Ib12fd6d48af8c48ffa683376097be14bf83ac0ed Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1136818 Signed-off-by: Mooli Tayer <mta...@redhat.com> --- M backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/transport/snmp/Snmp.java M packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.conf.in 2 files changed, 65 insertions(+), 26 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/95/32895/1 diff --git a/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/transport/snmp/Snmp.java b/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/transport/snmp/Snmp.java index ec62f97..f68171e 100644 --- a/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/transport/snmp/Snmp.java +++ b/backend/manager/tools/src/main/java/org/ovirt/engine/core/notifier/transport/snmp/Snmp.java @@ -13,6 +13,7 @@ import org.apache.log4j.Logger; import org.ovirt.engine.core.common.AuditLogType; import org.ovirt.engine.core.common.EventNotificationMethod; +import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.notifier.NotificationServiceException; import org.ovirt.engine.core.notifier.dao.DispatchResult; import org.ovirt.engine.core.notifier.filter.AuditLogEvent; @@ -21,11 +22,7 @@ import org.snmp4j.CommunityTarget; import org.snmp4j.PDU; import org.snmp4j.mp.SnmpConstants; -import org.snmp4j.smi.OID; -import org.snmp4j.smi.OctetString; -import org.snmp4j.smi.TimeTicks; -import org.snmp4j.smi.UdpAddress; -import org.snmp4j.smi.VariableBinding; +import org.snmp4j.smi.*; import org.snmp4j.transport.DefaultUdpTransportMapping; public class Snmp extends Transport { @@ -97,63 +94,105 @@ // PDU class is for SNMPv2c units PDU v2pdu = new PDU(); v2pdu.setType(PDU.TRAP); - int auditLogTypeVal = AuditLogType.UNASSIGNED.getValue(); + int auditLogId = AuditLogType.UNASSIGNED.getValue(); try { // TODO mtayer: what about db? add to audit log type - auditLogTypeVal = AuditLogType.valueOf(event.getName()).getValue(); + auditLogId = AuditLogType.valueOf(event.getName()).getValue(); } catch (IllegalArgumentException e) { log.warn("Could not find event: " + event.getName() + " in auditLogTypes"); } - OID trapOID = SnmpConstants.getTrapOID(profile.oid, ENTERPRISE_SPECIFIC, auditLogTypeVal); - v2pdu.add(new VariableBinding(SnmpConstants.snmpTrapOID, trapOID)); + // TODO link here to snmp notifications@wiki - that should have a link to the SNMP mib src. + + // snmpTrapOID -> baseoid.notifications.audit + v2pdu.add(new VariableBinding(SnmpConstants.snmpTrapOID, + new OID(profile.oid).append(1).append(1))); + // sysUpTime -> TimeTicks v2pdu.add(new VariableBinding(SnmpConstants.sysUpTime, new TimeTicks((System.nanoTime() - nanoStart) / 10000000))); + + // baseoid.object.audit + OID auditObject = new OID(profile.oid).append(1).append(2); + v2pdu.add(new VariableBinding( - new OID(trapOID).append(0), - new OctetString(event.getMessage()))); + new OID(auditObject).append(1), + new OctetString(event.getName()))); v2pdu.add(new VariableBinding( - new OID(trapOID).append(1), - new OctetString(event.getSeverity().name()))); + new OID(auditObject).append(2), + new Integer32(auditLogId))); v2pdu.add(new VariableBinding( - new OID(trapOID).append(2), - new OctetString(event.getType().name()))); + new OID(auditObject).append(3), + new Integer32(event.getSeverity().getValue()))); v2pdu.add(new VariableBinding( - new OID(trapOID).append(3), - new OctetString(event.getLogTime().toString()))); + new OID(auditObject).append(4), + new OctetString(event.getMessage()))); v2pdu.add(new VariableBinding( - new OID(trapOID).append(4), - new OctetString(event.getLogTypeName()))); + new OID(auditObject).append(5), + new Integer32(event.getType().getValue()))); + v2pdu.add(new VariableBinding( + new OID(auditObject).append(6), + new OctetString(event.getLogTime().toString()))); + if (!StringUtils.isEmpty(event.getUserName())) { v2pdu.add(new VariableBinding( - new OID(trapOID).append(5), + new OID(auditObject).append(7), new OctetString(event.getUserName()))); + } + if (event.getUserId() != null && !event.getUserId().equals(Guid.Empty)) { + v2pdu.add(new VariableBinding( + new OID(auditObject).append(8), + new OctetString(event.getUserId().toString()))); } if (!StringUtils.isEmpty(event.getVmName())) { v2pdu.add(new VariableBinding( - new OID(trapOID).append(6), + new OID(auditObject).append(9), new OctetString(event.getVmName()))); + } + if (event.getVmId() != null && !event.getVmId().equals(Guid.Empty)) { + v2pdu.add(new VariableBinding( + new OID(auditObject).append(10), + new OctetString(event.getVmId().toString()))); } if (!StringUtils.isEmpty(event.getVdsName())) { v2pdu.add(new VariableBinding( - new OID(trapOID).append(7), + new OID(auditObject).append(11), new OctetString(event.getVdsName()))); + } + if (event.getVdsId() != null && !event.getVdsId().equals(Guid.Empty)) { + v2pdu.add(new VariableBinding( + new OID(auditObject).append(12), + new OctetString(event.getVdsId().toString()))); } if (!StringUtils.isEmpty(event.getVmTemplateName())) { v2pdu.add(new VariableBinding( - new OID(trapOID).append(8), + new OID(auditObject).append(13), new OctetString(event.getVmTemplateName()))); + } + if (event.getVmTemplateId() != null && !event.getVmTemplateId().equals(Guid.Empty)) { + v2pdu.add(new VariableBinding( + new OID(auditObject).append(12), + new OctetString(event.getVmTemplateId().toString()))); } if (!StringUtils.isEmpty(event.getStoragePoolName())) { v2pdu.add(new VariableBinding( - new OID(trapOID).append(9), + new OID(auditObject).append(13), new OctetString(event.getStoragePoolName()))); + } + if (event.getStoragePoolId()!= null && !event.getStoragePoolId().equals(Guid.Empty)) { + v2pdu.add(new VariableBinding( + new OID(auditObject).append(14), + new OctetString(event.getStoragePoolId().toString()))); } if (!StringUtils.isEmpty(event.getStorageDomainName())) { v2pdu.add(new VariableBinding( - new OID(trapOID).append(10), + new OID(auditObject).append(15), new OctetString(event.getStorageDomainName()))); } + if (event.getStorageDomainId() != null && !event.getStorageDomainId().equals(Guid.Empty)) { + v2pdu.add(new VariableBinding( + new OID(auditObject).append(16), + new OctetString(event.getStorageDomainId().toString()))); + } CommunityTarget target = new CommunityTarget(); target.setCommunity(profile.community); target.setVersion(SnmpConstants.version2c); diff --git a/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.conf.in b/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.conf.in index 1cdbe24..b197c6e 100644 --- a/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.conf.in +++ b/packaging/services/ovirt-engine-notifier/ovirt-engine-notifier.conf.in @@ -154,7 +154,7 @@ # Default TRAP Object Identifier for alerts. # -# iso.organization.DoD.Internet.private.enterprises.redhat.ovirt-engine.notifications.audit-log +# iso.organization.DoD.Internet.private.enterprises.redhat.ovirt.ovirt-engine.notifier # 1.3.6.1.4.1.2312.13.1.1 SNMP_OID=1.3.6.1.4.1.2312.13.1.1 -- To view, visit http://gerrit.ovirt.org/32895 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib12fd6d48af8c48ffa683376097be14bf83ac0ed Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: mooli tayer <mta...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches