@Test
public void testJmxScanForStatuses() throws Exception {
makeTestJmx("test:name=bean1,type=TestJmx", 10, 10);
NagiosJmxCommand cmd = (NagiosJmxCommand)
nagiosLib.jmxscan(
zorka.query("test", "test:type=TestJmx,*", "name").get("Nom")
.metric(perfmon.metric("TEST", "B"))
).withSummaryLine("TEST ${STATUS} - test item ${ATTR.name} ${LVAL0} ${UNIT0};")
.withFirstResult().withLabel("${name}")
.withPerfLine("${LABEL}=${LVAL0}${UNIT0};${LVAL0}");
cmd.withRcMin("LVAL0", 15, 5);
assertEquals("Should respond with WARN status",
NrpePacket.WARN, cmd.cmd().getResultCode());
cmd.withRcMin("LVAL0", 20, 15);
assertEquals("Should respond with ERROR status",
NrpePacket.ERROR, cmd.cmd().getResultCode());
cmd.withRcMax("LVAL0", 7, 15);
assertEquals("Should respond with WARN status",
NrpePacket.WARN, cmd.cmd().getResultCode());
cmd.withRcMax("LVAL0", 5, 9);
assertEquals("Should respond with WARN status",
NrpePacket.ERROR, cmd.cmd().getResultCode());
}