本文整理汇总了Java中com.googlecode.jsendnsca.Level类的典型用法代码示例。如果您正苦于以下问题:Java Level类的具体用法?Java Level怎么用?Java Level使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Level类属于com.googlecode.jsendnsca包,在下文中一共展示了Level类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: shouldConstructTwoNewMessagePayload
import com.googlecode.jsendnsca.Level; //导入依赖的package包/类
@Test
public void shouldConstructTwoNewMessagePayload() throws Exception {
final MessagePayload messagePayload = new MessagePayloadBuilder()
.withHostname("localhost")
.withLevel(Level.OK)
.withServiceName("test service")
.withMessage("test message")
.create();
final MessagePayload messagePayload2 = new MessagePayloadBuilder()
.withHostname("somehost")
.withLevel(Level.WARNING)
.withServiceName("foo service")
.withMessage("foo message")
.create();
assertEquals("localhost", messagePayload.getHostname());
assertEquals(Level.OK, messagePayload.getLevel());
assertEquals("test service", messagePayload.getServiceName());
assertEquals("test message", messagePayload.getMessage());
assertEquals("somehost", messagePayload2.getHostname());
assertEquals(Level.WARNING, messagePayload2.getLevel());
assertEquals("foo service", messagePayload2.getServiceName());
assertEquals("foo message", messagePayload2.getMessage());
}
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:27,代码来源:MessagePayloadBuilderTest.java
示例2: shouldConstructPayloadWithoutUsingLocalHostname
import com.googlecode.jsendnsca.Level; //导入依赖的package包/类
@Test
public void shouldConstructPayloadWithoutUsingLocalHostname() {
MessagePayload messagePayload = new MessagePayloadBuilder() {
@Override
MessagePayload createMessagePayload() {
return new MessagePayload(false) {
@Override
public void useLocalHostname() {
throw new UnknownHostRuntimeException(new UnknownHostException());
}
};
}
}.create();
assertEquals("UNKNOWN", messagePayload.getHostname());
assertEquals(Level.UNKNOWN, messagePayload.getLevel());
assertEquals("UNDEFINED", messagePayload.getServiceName());
assertEquals(StringUtils.EMPTY, messagePayload.getMessage());
}
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:20,代码来源:MessagePayloadBuilderTest.java
示例3: testSendToNagios
import com.googlecode.jsendnsca.Level; //导入依赖的package包/类
@Test
public void testSendToNagios() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(createRouteBuilder());
MessagePayload expectedPayload = new MessagePayload("localhost", Level.OK, camelctx.getName(), "Hello Nagios");
MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedMessageCount(1);
mock.allMessages().body().isInstanceOf(String.class);
mock.expectedBodiesReceived("Hello Nagios");
camelctx.start();
try {
ProducerTemplate template = camelctx.createProducerTemplate();
template.sendBody("direct:start", "Hello Nagios");
mock.assertIsSatisfied();
Mockito.verify(nagiosPassiveCheckSender, Mockito.times(1)).send(expectedPayload);
} finally {
camelctx.stop();
}
}
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:26,代码来源:NagiosIntegrationTest.java
示例4: testSendToNagiosWarn
import com.googlecode.jsendnsca.Level; //导入依赖的package包/类
@Test
public void testSendToNagiosWarn() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(createRouteBuilder());
MessagePayload expectedPayload1 = new MessagePayload("localhost", Level.WARNING, camelctx.getName(), "Hello Nagios");
MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedMessageCount(1);
mock.expectedBodiesReceived("Hello Nagios");
camelctx.start();
try {
ProducerTemplate template = camelctx.createProducerTemplate();
template.sendBodyAndHeader("direct:start", "Hello Nagios", NagiosConstants.LEVEL, Level.WARNING);
mock.assertIsSatisfied();
Mockito.verify(nagiosPassiveCheckSender).send(expectedPayload1);
} finally {
camelctx.stop();
}
}
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:24,代码来源:NagiosIntegrationTest.java
示例5: testSendToNagiosWarnAsText
import com.googlecode.jsendnsca.Level; //导入依赖的package包/类
@Test
public void testSendToNagiosWarnAsText() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(createRouteBuilder());
MessagePayload expectedPayload1 = new MessagePayload("localhost", Level.WARNING, camelctx.getName(), "Hello Nagios");
MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedMessageCount(1);
mock.expectedBodiesReceived("Hello Nagios");
camelctx.start();
try {
ProducerTemplate template = camelctx.createProducerTemplate();
template.sendBodyAndHeader("direct:start", "Hello Nagios", NagiosConstants.LEVEL, "WARNING");
mock.assertIsSatisfied();
Mockito.verify(nagiosPassiveCheckSender).send(expectedPayload1);
} finally {
camelctx.stop();
}
}
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:25,代码来源:NagiosIntegrationTest.java
示例6: trigger
import com.googlecode.jsendnsca.Level; //导入依赖的package包/类
public void trigger(Alarm alarm) throws AlarmCallbackException {
String[] nsca_hosts = host.split(",");
int limit = alarm.getStream().getAlarmMessageLimit();
int current = alarm.getMessageCount();
Level level = limit * 2 > current ? Level.WARNING : Level.CRITICAL;
for (String nsca_host : nsca_hosts) {
String[] nsca_host_parts = nsca_host.split(":");
NscaHost nscaHost = new NscaHost(this.senderHostName,
nsca_host_parts[0],
nsca_host_parts.length > 1 ? Integer
.parseInt(nsca_host_parts[0]) : 5667,
Encryption.XOR);
try {
nscaHost.send(level, "Stream: " + alarm.getStream().getTitle(),
alarm.getDescription());
} catch (Exception e) {
throw new AlarmCallbackException("Could not submit alert to "
+ nsca_host + ". IOException");
}
}
}
开发者ID:frederikhappel,项目名称:graylog2-plugin-alarmcallback-nsca,代码行数:22,代码来源:NscaTrigger.java
示例7: shouldConstructNewMessagePayload
import com.googlecode.jsendnsca.Level; //导入依赖的package包/类
@Test
public void shouldConstructNewMessagePayload() throws Exception {
final MessagePayload messagePayload = new MessagePayloadBuilder()
.withHostname("localhost")
.withLevel(Level.CRITICAL)
.withServiceName("test service")
.withMessage("test message")
.create();
assertEquals("localhost", messagePayload.getHostname());
assertEquals(Level.CRITICAL, messagePayload.getLevel());
assertEquals("test service", messagePayload.getServiceName());
assertEquals("test message", messagePayload.getMessage());
}
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:15,代码来源:MessagePayloadBuilderTest.java
示例8: testSendTwoToNagios
import com.googlecode.jsendnsca.Level; //导入依赖的package包/类
@Test
public void testSendTwoToNagios() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(createRouteBuilder());
MessagePayload expectedPayload1 = new MessagePayload("localhost", Level.OK, camelctx.getName(), "Hello Nagios");
MessagePayload expectedPayload2 = new MessagePayload("localhost", Level.OK, camelctx.getName(), "Bye Nagios");
MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedMessageCount(2);
mock.allMessages().body().isInstanceOf(String.class);
mock.expectedBodiesReceived("Hello Nagios", "Bye Nagios");
camelctx.start();
try {
ProducerTemplate template = camelctx.createProducerTemplate();
template.sendBody("direct:start", "Hello Nagios");
template.sendBody("direct:start", "Bye Nagios");
mock.assertIsSatisfied();
Mockito.verify(nagiosPassiveCheckSender).send(expectedPayload1);
Mockito.verify(nagiosPassiveCheckSender).send(expectedPayload2);
} finally {
camelctx.stop();
}
}
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:29,代码来源:NagiosIntegrationTest.java
示例9: testSendToNagiosMultiHeaders
import com.googlecode.jsendnsca.Level; //导入依赖的package包/类
@Test
public void testSendToNagiosMultiHeaders() throws Exception {
CamelContext camelctx = new DefaultCamelContext();
camelctx.addRoutes(createRouteBuilder());
MessagePayload expectedPayload1 = new MessagePayload("myHost", Level.CRITICAL, "myService", "Hello Nagios");
MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedMessageCount(1);
mock.expectedBodiesReceived("Hello Nagios");
Map<String, Object> headers = new HashMap<String, Object>();
headers.put(NagiosConstants.LEVEL, "CRITICAL");
headers.put(NagiosConstants.HOST_NAME, "myHost");
headers.put(NagiosConstants.SERVICE_NAME, "myService");
camelctx.start();
try {
ProducerTemplate template = camelctx.createProducerTemplate();
template.sendBodyAndHeaders("direct:start", "Hello Nagios", headers);
mock.assertIsSatisfied();
Mockito.verify(nagiosPassiveCheckSender).send(expectedPayload1);
} finally {
camelctx.stop();
}
}
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:29,代码来源:NagiosIntegrationTest.java
示例10: send
import com.googlecode.jsendnsca.Level; //导入依赖的package包/类
public void send(Level level, String serviceName, String message)
throws NagiosException, IOException {
message = message.replace("\n", "\\n");
MessagePayload payload = new MessagePayloadBuilder()
.withHostname(senderHostName).withLevel(level)
.withServiceName(serviceName).withMessage(message).create();
sender.send(payload);
}
开发者ID:frederikhappel,项目名称:graylog2-plugin-alarmcallback-nsca,代码行数:10,代码来源:NscaHost.java
示例11: withLevel
import com.googlecode.jsendnsca.Level; //导入依赖的package包/类
/**
* Set the level of the passive check
*
* @param level
* the level value
* @return the {@link MessagePayloadBuilder}
*/
public MessagePayloadBuilder withLevel(int level) {
payload.setLevel(Level.toLevel(level));
return this;
}
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:12,代码来源:MessagePayloadBuilder.java
注:本文中的com.googlecode.jsendnsca.Level类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论