Пример #1
0
        public static TCPConnectionsInfo GetData()
        {
            TCPConnectionsInfo result = new TCPConnectionsInfo();

            var allData = ConnectionsPerProcess.GetAllTcpConnections();

            result.TotalConnections      = allData.Count;
            result.ConnectionsPerProcess = allData.GroupBy(x => x.ProcessId).ToDictionary(x => x.Key, x => x.ToList().Count);

            var a = result.ConnectionsPerProcess.Values.Sum();

            return(result);
        }
Пример #2
0
        static void Main(string[] args)
        {
            /*
             * var b = System.Diagnostics.PerformanceCounterCategory.GetCategories();
             *
             * foreach(var c in b)
             * {
             *  try
             *  {
             *      EnumerateCountersFor(c.CategoryName);
             *      Console.WriteLine();
             *      Console.WriteLine();
             *      Console.WriteLine();
             *      Console.WriteLine();
             *      Console.WriteLine();
             *      Console.WriteLine();
             *      Console.ReadLine();
             *  }
             *  catch
             *  { }
             * }*/
            Console.ReadLine();
            var services = ServiceHelper.GetService32();
            //ConnectionsHelper.GetData();

            var serviceCPU = ProcessesHelper.GetExpenses(services);
            //System.Diagnostics.Process.PerformanceCounter
            //var a1 = ConnectionsHelper.GetData();

            /* ConsumptionPerCore consumptionPerCore = new ConsumptionPerCore();
             * while (true)
             * {
             *   var data = consumptionPerCore.Step();
             *   System.Threading.Thread.Sleep(15000);
             *  Console.WriteLine();
             * }*/


            // NetworkPerNIC.Do();
            var a = ConnectionsPerProcess.GetAllTcpConnections(services);

            // var d = System.Net.NetworkInformation.
            //  var b2 = a[0].();
        }