@Test public void testParse() throws Exception { final String statusText = "Total Accesses: " + TOTAL_ACCESSES + "\n" + "Total kBytes: " + KBYTES + "\n" + "CPULoad: .044688\n" + "Uptime: " + UPTIME + "\n" + "ReqPerSec: " + RPS + "\n" + "BytesPerSec: " + BPS + "\n" + "BytesPerReq: " + BPR + "\n" + "BusyWorkers: " + BUSY_WORKERS + "\n" + "IdleWorkers: " + IDLE_WORKERS + "\n" + "Scoreboard: __________________K___W_K_____K______________K____" + repeat('.', OPEN_SLOTS) + "\n"; ApacheStatusPoller.StatusFetcher fetcher = () -> new ByteArrayInputStream(statusText.getBytes("UTF-8")); ApacheStatusPoller poller = new ApacheStatusPoller(fetcher); List<Metric> metrics = poller.pollImpl(TIMESTAMP); Metric accesses = counter("Total_Accesses", TOTAL_ACCESSES); Metric kBytes = counter("Total_kBytes", KBYTES); Metric uptime = counter("Uptime", UPTIME); List<Metric> counters = UnmodifiableList.of(accesses, kBytes, uptime); Metric busyWorkers = gauge("BusyWorkers", BUSY_WORKERS); Metric idleWorkers = gauge("IdleWorkers", IDLE_WORKERS); List<Metric> gauges = UnmodifiableList.of(busyWorkers, idleWorkers); Metric waitingForConnection = scoreboard("WaitingForConnection", 45.0); Metric startingUp = scoreboard("StartingUp", 0.0); Metric readingRequest = scoreboard("ReadingRequest", 0.0); Metric sendingReply = scoreboard("SendingReply", 1.0); Metric keepalive = scoreboard("Keepalive", 4.0); Metric dnsLookup = scoreboard("DnsLookup", 0.0); Metric closingConnection = scoreboard("ClosingConnection", 0.0); Metric logging = scoreboard("Logging", 0.0); Metric gracefullyFinishing = scoreboard("GracefullyFinishing", 0.0); Metric idleCleanupOfWorker = scoreboard("IdleCleanupOfWorker", 0.0); Metric unknownState = scoreboard("UnknownState", 0.0); List<Metric> scoreboard = UnmodifiableList.of(waitingForConnection, startingUp, readingRequest, sendingReply, keepalive, dnsLookup, closingConnection, logging, gracefullyFinishing, idleCleanupOfWorker, unknownState); List<Metric> expected = new ArrayList<>(); expected.addAll(counters); expected.addAll(gauges); expected.addAll(scoreboard); assertEquals(metrics, expected); }
List<Metric> pollImpl(long timestamp) { try { try (InputStream statusStream = fetcher.fetchStatus()) { return StatusPageParserUtil.parse(statusStream, timestamp); } } catch (IOException e) { logger.error("Could not fetch status page", e); return EMPTY_LIST; } }
ApacheStatusPoller extends BaseMetricPoller { List<Metric> pollImpl(long timestamp) { try { try (InputStream statusStream = fetcher.fetchStatus()) { return StatusPageParserUtil.parse(statusStream, timestamp); } } catch (IOException e) { logger.error("Could not fetch status page", e); return EMPTY_LIST; } } }
ApacheStatusPoller extends BaseMetricPoller { List<Metric> pollImpl(long timestamp) { try { try (InputStream statusStream = fetcher.fetchStatus()) { return StatusPageParserUtil.parse(statusStream, timestamp); } } catch (IOException e) { logger.error("Could not fetch status page", e); return EMPTY_LIST; } } ApacheStatusPoller(StatusFetcher fetcher); }
ApacheStatusPoller extends BaseMetricPoller { List<Metric> pollImpl(long timestamp) { try { try (InputStream statusStream = fetcher.fetchStatus()) { return StatusPageParserUtil.parse(statusStream, timestamp); } } catch (IOException e) { logger.error("Could not fetch status page", e); return EMPTY_LIST; } } ApacheStatusPoller(StatusFetcher fetcher); @Override List<Metric> pollImpl(boolean reset); }
ApacheStatusPoller extends BaseMetricPoller { List<Metric> pollImpl(long timestamp) { try { try (InputStream statusStream = fetcher.fetchStatus()) { return StatusPageParserUtil.parse(statusStream, timestamp); } } catch (IOException e) { logger.error("Could not fetch status page", e); return EMPTY_LIST; } } ApacheStatusPoller(StatusFetcher fetcher); @Override List<Metric> pollImpl(boolean reset);  }