public void WindowsPerfmonInputCRUD() { Service service = Connect(); InputCollection inputCollection = service.GetInputs(); ServiceInfo info = service.GetInfo(); if (info.OsName.Equals("Windows")) { string name = "sdk-input-wp"; Args args = new Args(); if (inputCollection.ContainsKey(name)) { inputCollection.Remove(name); inputCollection.Refresh(); } Assert.IsFalse(inputCollection.ContainsKey(name), assertRoot + "#57"); // CRUD Windows Perfmon Input args.Add("interval", 600); args.Add("object", "Server"); inputCollection.Create(name, InputKind.WindowsPerfmon, args); Assert.IsTrue(inputCollection.ContainsKey(name), assertRoot + "#58"); WindowsPerfmonInput windowsPerfmonInput = (WindowsPerfmonInput)inputCollection.Get(name); windowsPerfmonInput.Index = "main"; windowsPerfmonInput.Counters = new string[] { "% Privileged Time" }; windowsPerfmonInput.Instances = new string[] { "wininit" }; windowsPerfmonInput.Object = "Process"; windowsPerfmonInput.Interval = 1200; windowsPerfmonInput.Update(); Assert.AreEqual(1, windowsPerfmonInput.Counters.Length, assertRoot + "#59"); Assert.IsTrue(this.Contains(windowsPerfmonInput.Counters, "% Privileged Time"), assertRoot + "#60"); Assert.AreEqual(windowsPerfmonInput.Index, "main", assertRoot + "#60.1"); Assert.IsTrue(this.Contains(windowsPerfmonInput.Instances, "wininit"), assertRoot + "#61"); Assert.AreEqual(1200, windowsPerfmonInput.Interval, assertRoot + "#62"); Assert.AreEqual("Process", windowsPerfmonInput.Object, assertRoot + "#63"); // set multi-series values and update. windowsPerfmonInput.Counters = new string[] { "% Privileged Time", "% User Time" }; windowsPerfmonInput.Instances = new string[] { "smss", "csrss" }; windowsPerfmonInput.Update(); Assert.AreEqual(2, windowsPerfmonInput.Counters.Length, assertRoot + "#64"); Assert.IsTrue(this.Contains(windowsPerfmonInput.Counters, "% Privileged Time"), assertRoot + "#65"); Assert.IsTrue(this.Contains(windowsPerfmonInput.Counters, "% User Time"), assertRoot + "#66"); Assert.AreEqual(2, windowsPerfmonInput.Instances.Length, assertRoot + "#67"); Assert.IsTrue(this.Contains(windowsPerfmonInput.Instances, "smss"), assertRoot + "#68"); Assert.IsTrue(this.Contains(windowsPerfmonInput.Instances, "csrss"), assertRoot + "#69"); windowsPerfmonInput.Remove(); inputCollection.Refresh(); Assert.IsFalse(inputCollection.ContainsKey(name), assertRoot + "#70"); } }
/// <summary> /// Touch all the properties of all any input /// </summary> /// <param name="input">The Input</param> private void TouchSpecificInput(Input input) { InputKind inputKind = input.GetKind(); TcpConnections tcpConnections = null; UdpConnections udpConnections = null; string[] dummyStrings; string dummyString; bool dummyBoolean; DateTime dummyDate; int dummyInt; if (inputKind.Equals(InputKind.Monitor)) { MonitorInput monitorInput = (MonitorInput)input; dummyString = monitorInput.Blacklist; dummyString = monitorInput.CrcSalt; dummyInt = monitorInput.FileCount; dummyBoolean = monitorInput.FollowTail; dummyString = monitorInput.Host; dummyString = monitorInput.HostRegex; dummyString = monitorInput.IgnoreOlderThan; dummyString = monitorInput.Index; dummyString = monitorInput.Queue; dummyBoolean = monitorInput.IsRecursive; dummyString = monitorInput.Source; dummyString = monitorInput.SourceType; dummyInt = monitorInput.TimeBeforeClose; dummyString = monitorInput.Whitelist; } else if (inputKind.Equals(InputKind.Script)) { ScriptInput scriptInput = (ScriptInput)input; dummyDate = scriptInput.EndTime; dummyString = scriptInput.Group; dummyString = scriptInput.Host; dummyString = scriptInput.Index; dummyString = scriptInput.Interval; dummyDate = scriptInput.StartTime; } else if (inputKind.Equals(InputKind.Tcp)) { TcpInput tcpInput = (TcpInput)input; dummyString = tcpInput.ConnectionHost; dummyString = tcpInput.Group; dummyString = tcpInput.Host; dummyString = tcpInput.Index; dummyString = tcpInput.Queue; dummyString = tcpInput.RestrictToHost; dummyString = tcpInput.Source; dummyString = tcpInput.SourceType; dummyBoolean = tcpInput.SSL; tcpConnections = tcpInput.Connections(); dummyString = tcpConnections.Connection; dummyString = tcpConnections.Servername; } else if (inputKind.Equals(InputKind.TcpSplunk)) { TcpSplunkInput tcpSplunkInput = (TcpSplunkInput)input; dummyString = tcpSplunkInput.ConnectionHost; dummyString = tcpSplunkInput.Group; dummyString = tcpSplunkInput.Host; dummyString = tcpSplunkInput.Index; dummyString = tcpSplunkInput.Queue; dummyString = tcpSplunkInput.Source; dummyString = tcpSplunkInput.SourceType; dummyBoolean = tcpSplunkInput.SSL; tcpConnections = tcpSplunkInput.Connections(); dummyString = tcpConnections.Connection; dummyString = tcpConnections.Servername; } else if (inputKind.Equals(InputKind.Udp)) { UdpInput udpInput = (UdpInput)input; dummyString = udpInput.ConnectionHost; dummyString = udpInput.Group; dummyString = udpInput.Host; dummyString = udpInput.Index; dummyString = udpInput.Queue; dummyString = udpInput.Source; dummyString = udpInput.SourceType; dummyBoolean = udpInput.NoAppendingTimeStamp; dummyBoolean = udpInput.NoPriorityStripping; udpConnections = udpInput.Connections(); dummyString = udpConnections.Group; } else if (inputKind.Equals(InputKind.WindowsActiveDirectory)) { WindowsActiveDirectoryInput windowsActiveDirectoryInput = (WindowsActiveDirectoryInput)input; dummyString = windowsActiveDirectoryInput.Index; dummyBoolean = windowsActiveDirectoryInput.MonitorSubtree; dummyString = windowsActiveDirectoryInput.StartingNode; dummyString = windowsActiveDirectoryInput.TargetDc; } else if (inputKind.Equals(InputKind.WindowsEventLog)) { WindowsEventLogInput windowsEventLogInput = (WindowsEventLogInput)input; dummyString = windowsEventLogInput.Hosts; dummyString = windowsEventLogInput.Index; dummyString = windowsEventLogInput.LocalName; dummyStrings = windowsEventLogInput.Logs; dummyString = windowsEventLogInput.LookupHost; } else if (inputKind.Equals(InputKind.WindowsPerfmon)) { WindowsPerfmonInput windowsPerfmonInput = (WindowsPerfmonInput)input; dummyStrings = windowsPerfmonInput.Counters; dummyString = windowsPerfmonInput.Index; dummyStrings = windowsPerfmonInput.Instances; dummyInt = windowsPerfmonInput.Interval; dummyString = windowsPerfmonInput.Object; } else if (inputKind.Equals(InputKind.WindowsRegistry)) { WindowsRegistryInput windowsRegistryInput = (WindowsRegistryInput)input; dummyBoolean = windowsRegistryInput.Baseline; dummyString = windowsRegistryInput.Hive; dummyString = windowsRegistryInput.Index; dummyBoolean = windowsRegistryInput.MonitorSubnodes; dummyString = windowsRegistryInput.Proc; dummyStrings = windowsRegistryInput.Type; } else if (inputKind.Equals(InputKind.WindowsWmi)) { WindowsWmiInput windowsWmiInput = (WindowsWmiInput)input; dummyString = windowsWmiInput.Classes; dummyStrings = windowsWmiInput.Fields; dummyString = windowsWmiInput.Index; dummyStrings = windowsWmiInput.Instances; dummyInt = windowsWmiInput.Interval; dummyString = windowsWmiInput.LocalName; dummyString = windowsWmiInput.LookupHost; dummyString = windowsWmiInput.Servers; dummyString = windowsWmiInput.Wql; } else { Assert.Fail(); } }