本文整理汇总了Java中org.rhq.core.domain.event.EventSeverity类的典型用法代码示例。如果您正苦于以下问题:Java EventSeverity类的具体用法?Java EventSeverity怎么用?Java EventSeverity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EventSeverity类属于org.rhq.core.domain.event包,在下文中一共展示了EventSeverity类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Rule
import org.rhq.core.domain.event.EventSeverity; //导入依赖的package包/类
/**
* Constructs an arbitrary rule.
*
* @param genericTrap
* @param specificTrap
* @param enterprise
* @param trapOid
* @param varbind
* @param value
* @param severity
*/
public Rule(int genericTrap, int specificTrap, OID enterprise, OID trapOid,
OID varbind, Pattern value, EventSeverity severity) {
if (enterprise == null)
throw new NullPointerException();
if (trapOid == null)
throw new NullPointerException();
if (varbind == null)
throw new NullPointerException();
if (value == null)
throw new NullPointerException();
if (severity == null)
throw new NullPointerException();
this.genericTrap = genericTrap;
this.specificTrap = specificTrap;
this.enterprise = enterprise;
trapOid = trapOid(genericTrap, specificTrap, trapOid);
this.trapOid = trapOid;
this.varbind = varbind;
this.value = value;
this.severity = severity;
}
示例2: convertLevel
import org.rhq.core.domain.event.EventSeverity; //导入依赖的package包/类
private EventSeverity convertLevel(int level) {
if (level < Level.INFO.intValue()) {
return EventSeverity.DEBUG;
} else if (level < Level.WARNING.intValue()) {
return EventSeverity.INFO;
} else if (level < Level.SEVERE.intValue()) {
return EventSeverity.WARN;
} else if (level < WsLevel.FATAL.intValue()) {
return EventSeverity.ERROR;
} else {
return EventSeverity.FATAL;
}
}
示例3: publishEvent
import org.rhq.core.domain.event.EventSeverity; //导入依赖的package包/类
public void publishEvent(EventContext context, String sourceLocation, long timestamp, EventSeverity severity, String detail) {
StringBuilder buffer = null;
for (int i=0; i<detail.length(); i++) {
char c = detail.charAt(i);
if (c < 32 && c != '\r' && c != '\n' && c != '\t') {
if (buffer == null) {
buffer = new StringBuilder(detail.length());
buffer.append(detail, 0, i);
}
buffer.append(" ");
} else if (buffer != null) {
buffer.append(c);
}
}
if (buffer != null) {
detail = buffer.toString();
if (log.isWarnEnabled()) {
// We only log a warning every 5 minutes
synchronized (lastSanitizeWarningLock) {
long time = System.currentTimeMillis();
if (time - lastSanitizeWarning > 300000) {
lastSanitizeWarning = time;
log.warn("Got a RasMessage with invalid characters from " + sourceLocation
+ " (severity: " + severity + "): " + detail);
}
}
}
}
Utils.publishEvent(context, new Event("LogEvent", sourceLocation, timestamp, severity, detail));
EventStats.incrementEventsPublished();
}
示例4: severity
import org.rhq.core.domain.event.EventSeverity; //导入依赖的package包/类
private EventSeverity severity(int exitCode) throws Exception {
switch (exitCode) {
case 0: return EventSeverity.INFO;
case 1: return EventSeverity.WARN;
case 2: return EventSeverity.ERROR;
default: throw new Exception("unexpected exit code " + exitCode + ": " + output.trim());
}
}
示例5: match
import org.rhq.core.domain.event.EventSeverity; //导入依赖的package包/类
/**
* Returns the matching severity for this PDU, or null if no match.
*/
public EventSeverity match(PDU pdu) {
if (pdu instanceof PDUv1) {
PDUv1 pdu1 = (PDUv1) pdu;
if (genericTrap != UNSET && genericTrap != pdu1.getGenericTrap()) {
log.trace("no match generic trap");
return null;
}
if (specificTrap != UNSET && specificTrap != pdu1.getSpecificTrap()) {
log.trace("no match specific trap");
return null;
}
if (!pdu1.getEnterprise().startsWith(enterprise)) {
log.trace("no match enterprise");
return null;
}
} else {
OID oid = (OID) pdu.getVariable(SnmpConstants.snmpTrapOID);
if (oid != null && oid.startsWith(trapOid)) {
log.trace("no match enterprise");
return null;
}
}
if (varbind.size() != 0) {
Variable v = pdu.getVariable(varbind);
if (v == null) {
log.trace("no required variable found");
return null;
}
if (!value.matcher(v.toString()).find()) {
log.trace("no match variable");
return null;
}
}
return severity;
}
示例6: match
import org.rhq.core.domain.event.EventSeverity; //导入依赖的package包/类
/**
* Return a matching event severity, or INFO if not matched.
*/
public EventSeverity match(PDU pdu) {
for (Rule rule : rules) {
EventSeverity es = rule.match(pdu);
if (es != null)
return es;
}
return EventSeverity.INFO;
}
示例7: test
import org.rhq.core.domain.event.EventSeverity; //导入依赖的package包/类
@Test
public void test() throws Exception {
log.info("sending snmp trap...");
ResourceType type = getResourceType(TYPE);
Configuration conf = getConfiguration(type);
conf.setSimpleValue("port", "" + port);
conf.setSimpleValue("filter", "(\\d+-\\d+-\\d+\\s+)?(\\d+:\\d+:\\d+(,\\d+)?\\s*)?");
conf.setSimpleValue(SnmpTrapdComponent.SOURCE_LOCATION, alertSource.toString());
ResourceComponent trapd = manuallyAdd(type, conf);
String prefix = "2013-06-03 22:23:38,858 ";
String hello = "hello \u2013 world";
sendTrap(prefix + hello);
log.info("listening...");
Event event = null;
TestEventContext eventContext = getEventContext(trapd);
for (int i = 0; i < 16; i++) {
Thread.sleep(250);
List<Event> events = eventContext.getEvents();
log.info("events " + events);
if (events.size() > 0) {
event = events.get(0);
break;
}
}
assertTrue("Did not get event (in time)", event != null);
assertEquals(EventSeverity.INFO, event.getSeverity());
assertEquals("SnmpTrap", event.getType());
assertEquals("alertName: " + hello + "\n" +
"alertSeverity: medium\n" +
alertSource + ": rhq.org\n", event.getDetail());
assertEquals("rhq.org", event.getSourceLocation());
trapd.stop();
}
示例8: getAvailabilityCurrent
import org.rhq.core.domain.event.EventSeverity; //导入依赖的package包/类
/**
* Returns the current availability.
*/
AvailabilityType getAvailabilityCurrent() {
log.debug("getAvailabilityCurrent() " + key);
if (settings.isEmpty()) {
log.debug("no settings; nothing to do");
return UP;
}
if (!settingTrue(ENABLED)) {
log.debug("disabled");
return UP;
}
ProcessExecution pe = getExecution();
try {
if (log.isDebugEnabled())
log.debug("executing: " + pe);
long start = System.nanoTime();
ProcessExecutionResults result = info.executeProcess(pe);
if (result.getError() != null)
throw new Exception(result.getError());
if (result.getExitCode() == null)
throw new IllegalStateException("unable to get exit code; process timed out?");
output = result.getCapturedOutput();
if (output.length() > OUTPUT_MAX)
output = output.substring(0, OUTPUT_MAX);
if (log.isDebugEnabled())
log.debug("output:\n" + output);
int exitCode = result.getExitCode();
elapsed = (int)(System.nanoTime() - start);
if (exitCode != lastExitCode) {
log.debug("exit code " + exitCode + " changed, send event");
EventSeverity es = severity(exitCode);
if (output.length() == 0)
output = "exit code " + exitCode;
Event event = new Event(EVENT_TYPE, key, System.currentTimeMillis(), es, output);
eventContext.publishEvent(event);
lastExitCode = exitCode;
}
} catch (Exception e) {
log.error("failed to execute", e);
return DOWN;
}
switch (lastExitCode) {
case 0:
case 1: return UP;
default: return DOWN;
}
}
示例9: pushEvent
import org.rhq.core.domain.event.EventSeverity; //导入依赖的package包/类
public void pushEvent() {
EventSeverity severity = EventSeverity.ERROR;
Event event = new Event("test", "loc", System.currentTimeMillis(), severity, "detail");
resourceContext.getEventContext().publishEvent(event);
}
示例10: publishEvent
import org.rhq.core.domain.event.EventSeverity; //导入依赖的package包/类
void publishEvent(EventContext context, String sourceLocation, long timestamp, EventSeverity severity, String detail);