private void touchSpecificInput(Input input) { InputKind inputKind = input.getKind(); TcpConnections tcpConnections = null; UdpConnections udpConnections = null; switch (inputKind) { case Monitor: MonitorInput monitorInput = (MonitorInput) input; monitorInput.getBlacklist(); monitorInput.getCrcSalt(); monitorInput.getFileCount(); monitorInput.getFollowTail(); monitorInput.getHost(); monitorInput.getHostRegex(); monitorInput.getIgnoreOlderThan(); monitorInput.getIndex(); monitorInput.getQueue(); monitorInput.getRcvBuf(); monitorInput.getRecursive(); monitorInput.getSource(); monitorInput.getSourceType(); monitorInput.getTimeBeforeClose(); monitorInput.getWhitelist(); break; case Script: ScriptInput scriptInput = (ScriptInput) input; scriptInput.getEndTime(); scriptInput.getGroup(); scriptInput.getHost(); scriptInput.getIndex(); scriptInput.getInterval(); scriptInput.getRcvBuf(); scriptInput.getStartTime(); break; case Tcp: TcpInput tcpInput = (TcpInput) input; tcpInput.getConnectionHost(); tcpInput.getGroup(); tcpInput.getHost(); tcpInput.getIndex(); tcpInput.getQueue(); tcpInput.getRcvBuf(); tcpInput.getRestrictToHost(); tcpInput.getSource(); tcpInput.getSourceType(); tcpInput.getSSL(); tcpConnections = tcpInput.connections(); tcpConnections.getConnection(); tcpConnections.getServername(); break; case TcpSplunk: TcpSplunkInput tcpSplunkInput = (TcpSplunkInput) input; tcpSplunkInput.getConnectionHost(); tcpSplunkInput.getGroup(); tcpSplunkInput.getHost(); tcpSplunkInput.getIndex(); tcpSplunkInput.getQueue(); tcpSplunkInput.getRcvBuf(); tcpSplunkInput.getSource(); tcpSplunkInput.getSourceType(); tcpSplunkInput.getSSL(); tcpConnections = tcpSplunkInput.connections(); tcpConnections.getConnection(); tcpConnections.getServername(); break; case Udp: UdpInput udpInput = (UdpInput) input; udpInput.getConnectionHost(); udpInput.getGroup(); udpInput.getHost(); udpInput.getIndex(); udpInput.getQueue(); udpInput.getRcvBuf(); udpInput.getSource(); udpInput.getSourceType(); udpInput.getNoAppendingTimeStamp(); udpInput.getNoPriorityStripping(); udpConnections = udpInput.connections(); udpConnections.getGroup(); break; case WindowsActiveDirectory: WindowsActiveDirectoryInput windowsActiveDirectoryInput = (WindowsActiveDirectoryInput) input; windowsActiveDirectoryInput.getIndex(); windowsActiveDirectoryInput.getMonitorSubtree(); windowsActiveDirectoryInput.getStartingNode(); windowsActiveDirectoryInput.getTargetDc(); break; case WindowsEventLog: WindowsEventLogInput windowsEventLogInput = (WindowsEventLogInput) input; windowsEventLogInput.getHosts(); windowsEventLogInput.getIndex(); windowsEventLogInput.getLocalName(); windowsEventLogInput.getLogs(); windowsEventLogInput.getLookupHost(); break; case WindowsPerfmon: WindowsPerfmonInput windowsPerfmonInput = (WindowsPerfmonInput) input; windowsPerfmonInput.getCounters(); windowsPerfmonInput.getIndex(); windowsPerfmonInput.getInstances(); windowsPerfmonInput.getInterval(); windowsPerfmonInput.getObject(); break; case WindowsRegistry: WindowsRegistryInput windowsRegistryInput = (WindowsRegistryInput) input; windowsRegistryInput.getBaseline(); windowsRegistryInput.getHive(); windowsRegistryInput.getIndex(); windowsRegistryInput.getMonitorSubnodes(); windowsRegistryInput.getProc(); windowsRegistryInput.getType(); break; case WindowsWmi: WindowsWmiInput windowsWmiInput = (WindowsWmiInput) input; windowsWmiInput.getClasses(); windowsWmiInput.getFields(); windowsWmiInput.getIndex(); windowsWmiInput.getInstances(); windowsWmiInput.getInterval(); windowsWmiInput.getLocalName(); windowsWmiInput.getLookupHost(); windowsWmiInput.getServers(); windowsWmiInput.getWql(); break; } }
@Test public void testMonitorInputCrud() { Service service = connect(); InputCollection inputCollection = service.getInputs(); ServiceInfo info = service.getInfo(); // CRUD Monitor input String filename; if (info.getOsName().equals("Windows")) filename = "C:\\Windows\\WindowsUpdate.log"; else if (info.getOsName().equals("Linux")) filename = "/var/log/messages"; else if (info.getOsName().equals("Darwin")) { filename = "/var/log/system.log"; } else { throw new Error("OS: " + info.getOsName() + " not supported"); } if (inputCollection.containsKey(filename)) { inputCollection.remove(filename); } inputCollection.create(filename, InputKind.Monitor); assertTrue(inputCollection.containsKey(filename)); MonitorInput monitorInput = (MonitorInput) inputCollection.get(filename); monitorInput.setBlacklist("phonyregex*1"); monitorInput.setCheckIndex(true); monitorInput.setCheckPath(true); if (service.versionCompare("4.2.1") >= 0) { monitorInput.setCrcSalt("ThisIsSalt"); monitorInput.setIgnoreOlderThan("1d"); monitorInput.setTimeBeforeClose(120); } monitorInput.setFollowTail(false); monitorInput.setHost("three.four.com"); monitorInput.setHostRegex("host*regex*"); monitorInput.setHostSegment(""); monitorInput.setIndex("main"); monitorInput.setRecursive(false); monitorInput.setRenameSource("renamedSource"); monitorInput.setSourcetype("monitor"); monitorInput.setWhitelist("phonyregex*2"); monitorInput.update(); monitorInput.disable(); // some attributes are write only; check what we can. assertEquals(assertRoot + "#1", "phonyregex*1", monitorInput.getBlacklist()); assertFalse(assertRoot + "#2", monitorInput.getFollowTail()); assertEquals(assertRoot + "#3", "three.four.com", monitorInput.getHost()); assertEquals(assertRoot + "#4", "host*regex*", monitorInput.getHostRegex()); if (service.versionCompare("4.2.1") >= 0) { assertEquals(assertRoot + "#4", "1d", monitorInput.getIgnoreOlderThan()); assertEquals(assertRoot + "#4", 120, monitorInput.getTimeBeforeClose()); } assertEquals(assertRoot + "#5", "main", monitorInput.getIndex()); assertFalse(assertRoot + "#6", monitorInput.getRecursive()); assertEquals(assertRoot + "#7", "renamedSource", monitorInput.getSource()); assertEquals(assertRoot + "#8", "monitor", monitorInput.getSourceType()); assertEquals(assertRoot + "#9", "phonyregex*2", monitorInput.getWhitelist()); monitorInput.remove(); inputCollection.refresh(); inputCollection.refresh(); assertFalse(assertRoot + "#10", inputCollection.containsKey(filename)); }