From: <pn...@hy...> - 2010-01-25 07:25:12
|
Author: pnguyen Date: 2010-01-24 23:25:02 -0800 (Sun, 24 Jan 2010) New Revision: 14230 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14230 Modified: trunk/plugins/netservices/etc/hq-plugin.xml trunk/src/org/hyperic/hq/bizapp/shared/action/SnmpActionConfig.java trunk/src/org/hyperic/hq/ui/json/action/escalation/BaseAction.java trunk/src/org/hyperic/hq/ui/json/action/escalation/crud/SaveAction.java trunk/web/WEB-INF/classes/ApplicationResources.properties trunk/web/admin/config/NewEscalation.jsp trunk/web/admin/config/ViewEscalation.jsp trunk/web/resource/common/monitor/alerts/config/ViewEscalation.jsp Log: [HPD-200] Implement SNMP variable bindings; Update usage of SNMP terminology Modified: trunk/plugins/netservices/etc/hq-plugin.xml =================================================================== --- trunk/plugins/netservices/etc/hq-plugin.xml 2010-01-24 09:24:20 UTC (rev 14229) +++ trunk/plugins/netservices/etc/hq-plugin.xml 2010-01-25 07:25:02 UTC (rev 14230) @@ -259,7 +259,7 @@ optional="true"/> <option name="snmpSecurityContext" - description="SNMP Security Context Name (v3 only)" + description="SNMP Context Name (v3 only)" optional="true"/> <option name="snmpAuthType" Modified: trunk/src/org/hyperic/hq/bizapp/shared/action/SnmpActionConfig.java =================================================================== --- trunk/src/org/hyperic/hq/bizapp/shared/action/SnmpActionConfig.java 2010-01-24 09:24:20 UTC (rev 14229) +++ trunk/src/org/hyperic/hq/bizapp/shared/action/SnmpActionConfig.java 2010-01-25 07:25:02 UTC (rev 14230) @@ -13,10 +13,12 @@ protected static final String CFG_OID = "oid"; protected static final String CFG_ADDRESS = "address"; protected static final String CFG_NOTIFICATION_MECHANISM = "snmpNotificationMechanism"; + protected static final String CFG_VARIABLE_BINDINGS = "variableBindings"; protected String oid; protected String address; protected String snmpNotificationMechanism; + protected String variableBindings; // in JSON format private String implementor = "com.hyperic.hq.bizapp.server.action.alert.SnmpAction"; @@ -24,10 +26,13 @@ public SnmpActionConfig() { } - public SnmpActionConfig(String address, String oid, String snmpNotificationMechanism) { + public SnmpActionConfig(String snmpNotificationMechanism, + String address, String oid, + String variableBindings) { + this.snmpNotificationMechanism = snmpNotificationMechanism; this.address = address; this.oid = oid; - this.snmpNotificationMechanism = snmpNotificationMechanism; + this.variableBindings = variableBindings; } public void setOid(String oid) { @@ -46,26 +51,52 @@ return address; } + public String getSnmpNotificationMechanism() { + return snmpNotificationMechanism; + } + + public void setSnmpNotificationMechanism(String snmpNotificationMechanism) { + this.snmpNotificationMechanism = snmpNotificationMechanism; + } + + /** + * Gets the variable bindings configuration in JSON format + */ + public String getVariableBindings() { + return variableBindings; + } + + /** + * Sets the variable bindings configuration in JSON format + */ + public void setVariableBindings(String variableBindings) { + this.variableBindings = variableBindings; + } + /* (non-Javadoc) * @see org.hyperic.hq.events.ActionConfigInterface#getConfigSchema() */ public ConfigSchema getConfigSchema() { - StringConfigOption address, oid, snmpNotificationMechanism; ConfigSchema res = new ConfigSchema(); - address = new StringConfigOption(CFG_ADDRESS, + StringConfigOption address = new StringConfigOption(CFG_ADDRESS, "Transport Address ([transport:]address)", ""); address.setMinLength(1); res.addOption(address); - oid = new StringConfigOption(CFG_OID, "OID", "1.3.6"); + StringConfigOption oid = new StringConfigOption(CFG_OID, "OID", "1.3.6"); oid.setMinLength(1); res.addOption(oid); - snmpNotificationMechanism = new StringConfigOption(CFG_NOTIFICATION_MECHANISM, "SNMP Notification Mechanism", "v1 Trap"); + StringConfigOption snmpNotificationMechanism = + new StringConfigOption(CFG_NOTIFICATION_MECHANISM, "SNMP Notification Mechanism", "v2c Trap"); snmpNotificationMechanism.setMinLength(1); res.addOption(snmpNotificationMechanism); + StringConfigOption variableBindings = + new StringConfigOption(CFG_VARIABLE_BINDINGS, "User Variable Bindings", "[]"); + res.addOption(variableBindings); + return res; } @@ -76,6 +107,7 @@ response.setValue(CFG_ADDRESS, this.getAddress()); response.setValue(CFG_OID, this.getOid()); response.setValue(CFG_NOTIFICATION_MECHANISM, this.getSnmpNotificationMechanism()); + response.setValue(CFG_VARIABLE_BINDINGS, this.getVariableBindings()); return response; } @@ -85,6 +117,7 @@ setAddress(config.getValue(CFG_ADDRESS)); setOid(config.getValue(CFG_OID)); setSnmpNotificationMechanism(config.getValue(CFG_NOTIFICATION_MECHANISM)); + setVariableBindings(config.getValue(CFG_VARIABLE_BINDINGS)); } catch (IllegalArgumentException ex) { throw new InvalidActionDataException(ex); } @@ -97,12 +130,4 @@ public void setImplementor(String implementor) { this.implementor = implementor; } - - public String getSnmpNotificationMechanism() { - return snmpNotificationMechanism; - } - - public void setSnmpNotificationMechanism(String snmpNotificationMechanism) { - this.snmpNotificationMechanism = snmpNotificationMechanism; - } } Modified: trunk/src/org/hyperic/hq/ui/json/action/escalation/BaseAction.java =================================================================== --- trunk/src/org/hyperic/hq/ui/json/action/escalation/BaseAction.java 2010-01-24 09:24:20 UTC (rev 14229) +++ trunk/src/org/hyperic/hq/ui/json/action/escalation/BaseAction.java 2010-01-25 07:25:02 UTC (rev 14230) @@ -75,8 +75,10 @@ protected void streamResult(JsonActionContext context) throws JSONException, IOException { - context.getJSONResult().write( + if (context.getJSONResult() != null) { + context.getJSONResult().write( context.getWriter(), context.isPrettyPrint()); + } } } Modified: trunk/src/org/hyperic/hq/ui/json/action/escalation/crud/SaveAction.java =================================================================== --- trunk/src/org/hyperic/hq/ui/json/action/escalation/crud/SaveAction.java 2010-01-24 09:24:20 UTC (rev 14229) +++ trunk/src/org/hyperic/hq/ui/json/action/escalation/crud/SaveAction.java 2010-01-25 07:25:02 UTC (rev 14230) @@ -107,8 +107,11 @@ String address = ((String[])p.get("snmpIP"))[0]; String oid = ((String[])p.get("snmpOID"))[0]; String snmpNotificationMechanism = ((String[])p.get("snmpNotificationMechanism"))[0]; + String variableBindings = ((String[])p.get("variableBindings"))[0]; - return new SnmpActionConfig(address, oid, snmpNotificationMechanism); + return new SnmpActionConfig(snmpNotificationMechanism, + address, oid, + variableBindings); } private ActionConfigInterface Modified: trunk/web/WEB-INF/classes/ApplicationResources.properties =================================================================== --- trunk/web/WEB-INF/classes/ApplicationResources.properties 2010-01-24 09:24:20 UTC (rev 14229) +++ trunk/web/WEB-INF/classes/ApplicationResources.properties 2010-01-25 07:25:02 UTC (rev 14230) @@ -650,15 +650,15 @@ admin.settings.SNMPConfigPropTab=SNMP Server Configuration Properties admin.settings.SNMPVersion=SNMP Protocol Version: admin.settings.SNMPNone=SNMP Not Enabled -admin.settings.SNMPAuthProtocol=Auth Protocol: -admin.settings.SNMPAuthPassphrase=Auth Passphrase: +admin.settings.SNMPAuthProtocol=Authentication Protocol: +admin.settings.SNMPAuthPassphrase=Authentication Passphrase: admin.settings.SNMPPrivProtocol=Privacy Protocol: admin.settings.SNMPPrivPassphrase=Privacy Passphrase: admin.settings.SNMPCommunity=Community: -admin.settings.SNMPContextName=Target Context Name: +admin.settings.SNMPContextName=Context Name: admin.settings.SNMPSecurityName=Security Name: -admin.settings.SNMPEngineID=Engine ID: -admin.settings.SNMPTrapOID=Trap OID: +admin.settings.SNMPEngineID=Context Engine ID: +admin.settings.SNMPTrapOID=SNMP Trap OID: admin.settings.SNMPEnterpriseOID=Enterprise OID: admin.settings.SNMPGenericID=Generic ID: admin.settings.SNMPSpecificID=Specific ID: @@ -1951,6 +1951,9 @@ alert.config.escalation.wait.hours=wait {0} hours alert.config.escalation.scheme=Escalation Scheme: alert.config.escalation.scheme.for=Escalation Scheme for {0}: +alert.config.escalation.action.snmp.notification=SNMP Notification +alert.config.escalation.action.snmp.oid=OID +alert.config.escalation.action.snmp.varbinds=Variable Bindings alert.config.escalation.allow.pause=Allow user to pause escalation for alert.config.escalation.allow.pause.indefinitely=Allow user to pause escalation until fixed alert.config.escalation.allow.continue=Continue escalation without pausing @@ -2029,7 +2032,7 @@ alert.config.edit.notification.PageTitle=Edit {0}: Alert Notification Action -alert.config.edit.snmp.address=Address of the target SNMP engine: +alert.config.edit.snmp.address=IP Address: alert.config.edit.snmp.oid=OID: alert.config.edit.snmp.notificationMechanism=Notification Mechanism: Modified: trunk/web/admin/config/NewEscalation.jsp =================================================================== --- trunk/web/admin/config/NewEscalation.jsp 2010-01-24 09:24:20 UTC (rev 14229) +++ trunk/web/admin/config/NewEscalation.jsp 2010-01-25 07:25:02 UTC (rev 14230) @@ -358,7 +358,7 @@ addOption(select2, 'SMS', 'SMS'); addOption(select2, 'Syslog', 'Sys Log'); <c:if test="${snmpEnabled}"> - addOption(select2, 'SNMP', 'SNMP Trap'); + addOption(select2, 'SNMP', '<fmt:message key="alert.config.escalation.action.snmp.notification"/>'); </c:if> addOption(select2, 'NoOp', 'Suppress Alerts'); Modified: trunk/web/admin/config/ViewEscalation.jsp =================================================================== --- trunk/web/admin/config/ViewEscalation.jsp 2010-01-24 09:24:20 UTC (rev 14229) +++ trunk/web/admin/config/ViewEscalation.jsp 2010-01-25 07:25:02 UTC (rev 14230) @@ -14,7 +14,7 @@ normal use of the program, and does *not* fall under the heading of "derived work". - Copyright (C) [2004-2009], Hyperic, Inc. + Copyright (C) [2004-2010], Hyperic, Inc. This file is part of HQ. HQ is free software; you can redistribute it and/or modify @@ -179,6 +179,7 @@ var configSnmpOID = actionConfig.oid; var configSnmpIP = actionConfig.address; var configSnmpNotificationMechanism = actionConfig.snmpNotificationMechanism; + var configSnmpVarBinds = eval(actionConfig.variableBindings); var actionId = actions[i].action.id; var actionsClassName = actions[i].action.className; var actionsVersion = actions[i].action._version_; @@ -275,7 +276,26 @@ usersTextDiv.innerHTML = 'Suppress duplicate alerts for: ' + actionWaitTime; waitDiv.innerHTML = " "; } else if (actionClass[d] == "SnmpAction") { - usersTextDiv.innerHTML = '<table cellpadding="0" cellspacing="0" border="0"><tr><td rowSpan="3" vAlign="top" style="padding-right:3px;">Snmp Trap:</td><td style="padding:0px 2px 2px 2px;"><fmt:message key="resource.autodiscovery.server.IPAddressTH"/>: ' + configSnmpIP + '</td></tr><tr><td style="padding:2px;"><fmt:message key="admin.settings.SNMPTrapOID"/> ' + configSnmpOID + '</td></tr><tr><td style="padding:2px;"><fmt:message key="admin.settings.SNMPNotificationMechanism"/> ' + configSnmpNotificationMechanism + '</td></tr></table>' + var snmpInnerHTML = + '<table cellpadding="0" cellspacing="0" border="0">' + + '<tr><td rowSpan="4" vAlign="top" style="padding-right:3px;"><fmt:message key="alert.config.escalation.action.snmp.notification"/>:</td>' + + '<td colspan="2" style="padding:2px;"><fmt:message key="resource.autodiscovery.server.IPAddressTH"/>: ' + configSnmpIP + '</td></tr>' + + '<tr><td colspan="2" style="padding:0px 2px 2px 2px;"><fmt:message key="admin.settings.SNMPNotificationMechanism"/> ' + configSnmpNotificationMechanism + '</td></tr>' + + '<tr><td vAlign="top" style="padding:2px;" nowrap="nowrap"><fmt:message key="alert.config.escalation.action.snmp.varbinds"/>: </td>' + + '<td style="padding:2px;"><table>' + + '<tr><td style="padding-right:5px;"><fmt:message key="alert.config.escalation.action.snmp.oid"/>: ' + configSnmpOID + '</td>' + + '<td>Value: {snmp_trap.gsp}</td></tr>'; + + if (typeof configSnmpVarBinds != 'object') { + configSnmpVarBinds = []; + } + for (var s = 0; s < configSnmpVarBinds.length; s++) { + snmpInnerHTML += '<tr><td style="padding-right:5px;"><fmt:message key="alert.config.escalation.action.snmp.oid"/>: ' + + configSnmpVarBinds[s].oid + '</td>' + + '<td>Value: ' + configSnmpVarBinds[s].value + '</td></tr>'; + } + snmpInnerHTML += '</table></td></tr></table>'; + usersTextDiv.innerHTML = snmpInnerHTML; } } @@ -486,9 +506,22 @@ td5.setAttribute('width', '30%'); td5.setAttribute('rowSpan', '3'); td5.setAttribute('id', 'displaySelAction'); - td5.innerHTML = '<table cellpadding="2" cellspacing="0" border="0" width="100%"><tbody><tr><td class=BlockTitle colSpan=3>Action Details</td></tr><tr><td id="actionName" vAlign="top" width="50%">Action: Email</td></tr><tr><td id="userListDisplay" valign="top" style="display:none;"></td></tr><tr><td><table cellpadding="2" cellspacing="0" border="0"><tr><td id=metaText style="display:none"></td></tr><tr><td id=productText style="display:none"></td></tr><tr><td id=versionText style="display:none"></td></tr></table></td></tr><tr><td><table cellpadding="2" cellspacing="0" border="0"><tr><td id=IPText style="display:none"></td></tr><tr><td id=OIDText style="display:none"></td></tr><tr><td id=NotificationMechanismText style="display:none"></td></tr></table></td></tr><tr><td id="time" colspan="3" valign="top" style="display:none;"></td></tr></tbody></table>'; + td5.innerHTML = '<table cellpadding="2" cellspacing="0" border="0" width="100%">' + + '<tbody><tr><td class=BlockTitle colSpan=3>Action Details</td></tr>' + + '<tr><td id="actionName" vAlign="top" width="50%">Action: Email</td></tr>' + + '<tr><td id="userListDisplay" valign="top" style="display:none;"></td></tr>' + + '<tr><td><table cellpadding="2" cellspacing="0" border="0">' + + '<tr><td id=metaText style="display:none"></td></tr>' + + '<tr><td id=productText style="display:none"></td></tr>' + + '<tr><td id=versionText style="display:none"></td></tr></table></td></tr>' + + '<tr><td><table cellpadding="2" cellspacing="0" border="0">' + + '<tr><td id=IPText style="display:none"></td></tr>' + + '<tr><td id=NotificationMechanismText style="display:none"></td></tr>' + + '<tr><td id=OIDText style="display:none"></td></tr>' + + '<tr><td id=VariableBindingsText style="display:none"></td></tr></table></td></tr>' + + '<tr><td id="time" colspan="3" valign="top" style="display:none;"></td></tr>' + + '</tbody></table>'; - escTr1.appendChild(td1); td1.setAttribute('colSpan', '3'); @@ -528,7 +561,7 @@ addOption(select2, 'SMS', 'SMS'); addOption(select2, 'Syslog', 'Sys Log'); <c:if test="${snmpEnabled}"> - addOption(select2, 'SNMP', 'SNMP Trap'); + addOption(select2, 'SNMP', '<fmt:message key="alert.config.escalation.action.snmp.notification"/>'); </c:if> addOption(select2, 'NoOp', 'Suppress Alerts'); @@ -574,7 +607,14 @@ dojo11.byId('snmpinput').style.display = 'none'; dojo11.byId('snmpinput').style.textAlign = 'left'; //sysDiv.setAttribute('width', '40%'); - snmpDiv.innerHTML = '<fmt:message key="resource.autodiscovery.server.IPAddressTH"/>: <fmt:message key="inform.config.escalation.scheme.IPAddress"/><br> <input type=text name=snmpIP id=snmpIPinput' + " size=30 onMouseOut=copysnmpIP(this);checkIP(this);><br>" + '<fmt:message key="admin.settings.SNMPTrapOID"/> <fmt:message key="inform.config.escalation.scheme.OID"/><br> <input type=text name=snmpOID id=snmpOIDinput' + " size=30 onMouseOut=copysnmpOID(this);checkOID(this);><br> <select name='snmpNotificationMechanism' id='snmpNotificationMechanismSelect' onchange='copySnmpNotificationMechanism(this);'><option>v1 Trap</option><option>v2c Trap</option><option>Inform</option></select>"; + snmpDiv.innerHTML = '<fmt:message key="resource.autodiscovery.server.IPAddressTH"/>: <fmt:message key="inform.config.escalation.scheme.IPAddress"/><br>' + + '<input type=text name=snmpIP id=snmpIPinput size=30 onMouseOut=copysnmpIP(this);checkIP(this);><br>' + + '<fmt:message key="admin.settings.SNMPNotificationMechanism"/><br>' + + "<select name='snmpNotificationMechanism' id='snmpNotificationMechanismSelect' onchange='copySnmpNotificationMechanism(this);'><option>v1 Trap</option><option>v2c Trap</option><option>Inform</option></select><br>" + + '<fmt:message key="alert.config.escalation.action.snmp.oid"/> <fmt:message key="inform.config.escalation.scheme.OID"/><br>' + + '<input type=text name=snmpOID id=snmpOIDinput size=30 onMouseOut=copysnmpOID(this);checkOID(this);><br>' + + '<fmt:message key="alert.config.escalation.action.snmp.varbinds"/><br>' + + "<textarea rows='4' cols='25' name='variableBindings' id='variableBindingsTextArea' onchange='copyVariableBindings(this);'></textarea>"; td4.appendChild(usersDiv); usersDiv.setAttribute('id', 'usersDiv' + liID); @@ -631,9 +671,15 @@ function copysnmpOID(el) { var OIDDisplay = dojo11.byId('OIDText'); OIDDisplay.style.display = ""; - OIDDisplay.innerHTML = '<fmt:message key="admin.settings.SNMPTrapOID"/> ' + el.value; + OIDDisplay.innerHTML = '<fmt:message key="alert.config.escalation.action.snmp.oid"/>: ' + el.value; } +function copyVariableBindings(el) { + var display = dojo11.byId('VariableBindingsText'); + display.style.display = ""; + display.innerHTML = '<fmt:message key="alert.config.escalation.action.snmp.varbinds"/>: ' + el.value; +} + function copySnmpNotificationMechanism(el) { var display = dojo11.byId('NotificationMechanismText'); display.style.display = ""; Modified: trunk/web/resource/common/monitor/alerts/config/ViewEscalation.jsp =================================================================== --- trunk/web/resource/common/monitor/alerts/config/ViewEscalation.jsp 2010-01-24 09:24:20 UTC (rev 14229) +++ trunk/web/resource/common/monitor/alerts/config/ViewEscalation.jsp 2010-01-25 07:25:02 UTC (rev 14230) @@ -49,7 +49,7 @@ onloads.push(showViewEscResponse); function showViewEscResponse() { - var tmp = eval('( <c:out value="${escalationJSON}" escapeXml="false" /> )'); + var tmp = <c:out value="${escalationJSON}" escapeXml="false"/> ; var notifyAll = tmp.escalation.notifyAll var actions = tmp.escalation.actions; var allowPause = tmp.escalation.allowPause; @@ -80,6 +80,7 @@ var configSnmpOID = actionConfig.oid; var configSnmpIP = actionConfig.address; var configSnmpNotificationMechanism = actionConfig.snmpNotificationMechanism; + var configSnmpVarBinds = eval(actionConfig.variableBindings); var actionId = actions[i].action.id; var actionsClassName = actions[i].action.className; var actionsVersion = actions[i].action._version_; @@ -163,7 +164,26 @@ usersTextDiv.innerHTML = 'Suppress duplicate alerts for: ' + actionWaitTime; waitDiv.innerHTML = " "; } else if (actionClass[d] == "SnmpAction") { - usersTextDiv.innerHTML = '<table cellpadding="0" cellspacing="0" border="0"><tr><td rowSpan="3" vAlign="top" style="padding-right:3px;">Snmp Trap:</td><td style="padding:0px 2px 2px 2px;"><fmt:message key="resource.autodiscovery.server.IPAddressTH"/>: ' + configSnmpIP + '</td></tr><tr><td style="padding:2px;"><fmt:message key="admin.settings.SNMPTrapOID"/> ' + configSnmpOID + '</td></tr><tr><td style="padding:2px;"><fmt:message key="admin.settings.SNMPNotificationMechanism"/> ' + configSnmpNotificationMechanism + '</td></tr></table>' + var snmpInnerHTML = + '<table cellpadding="0" cellspacing="0" border="0">' + + '<tr><td rowSpan="4" vAlign="top" style="padding-right:3px;"><fmt:message key="alert.config.escalation.action.snmp.notification"/>:</td>' + + '<td colspan="2" style="padding:2px;"><fmt:message key="resource.autodiscovery.server.IPAddressTH"/>: ' + configSnmpIP + '</td></tr>' + + '<tr><td colspan="2" style="padding:0px 2px 2px 2px;"><fmt:message key="admin.settings.SNMPNotificationMechanism"/> ' + configSnmpNotificationMechanism + '</td></tr>' + + '<tr><td vAlign="top" style="padding:2px;" nowrap="nowrap"><fmt:message key="alert.config.escalation.action.snmp.varbinds"/>: </td>' + + '<td style="padding:2px;"><table>' + + '<tr><td style="padding-right:5px;"><fmt:message key="alert.config.escalation.action.snmp.oid"/>: ' + configSnmpOID + '</td>' + + '<td>Value: {snmp_trap.gsp}</td></tr>'; + + if (typeof configSnmpVarBinds != 'object') { + configSnmpVarBinds = []; + } + for (var s = 0; s < configSnmpVarBinds.length; s++) { + snmpInnerHTML += '<tr><td style="padding-right:5px;"><fmt:message key="alert.config.escalation.action.snmp.oid"/>: ' + + configSnmpVarBinds[s].oid + '</td>' + + '<td>Value: ' + configSnmpVarBinds[s].value + '</td></tr>'; + } + snmpInnerHTML += '</table></td></tr></table>'; + usersTextDiv.innerHTML = snmpInnerHTML; } } |