Beispiel #1
0
        //public PerformanceCounterWrapper NET { get; set; } // Impossible?

        public ProcessPFC(string process)
        {
            Name = process;
            CPU  = new PerformanceCounterWrapper("Process", "% Processor Time", Name);
            MEM  = new PerformanceCounterWrapper("Process", "Private Bytes", Name);
            NVM  = new PerformanceCounterWrapper("PhysicalDisk", "Disk Bytes/sec", Name);
        }
Beispiel #2
0
        protected virtual void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing)
            {
                CPU.Dispose();
                MEM.Dispose();
                NVM.Dispose();
                CPU = null;
                MEM = null;
                NVM = null;

                disposed = true;
            }
        }
Beispiel #3
0
        void InitCounters()
        {
            Console.WriteLine("Initializing counters...");

            //cpuusage = new PerformanceCounterWrapper("Processor", "% Processor Time", "_Total");

            /*
             * var cpus = new PerformanceCounterCategory("Processor").GetInstanceNames();
             * cores = cpus.Count() - 1;
             * Console.WriteLine("Cores: {0}", cores);
             * coreusage = new PerformanceCounterWrapper[cores];
             * for (int core = 0; core < cores; core++)
             *      coreusage[core] = new PerformanceCounterWrapper("Processor", "% Processor Time", core.ToString());
             */

            //new PerformanceCounterWrapper("Processor", "% Processor Time", "processnamewithoutexe");
            //new PerformanceCounterWrapper("Process", "Private Bytes", "processnamewithoutexe");
            //new PerformanceCounterWrapper("PhysicalDisk", "Disk Bytes/sec", "processnamewithoutexe");

            //memfree = new PerformanceCounterWrapper("Memory", "Available MBytes", null);
            //var memfree = new PerformanceCounterWrapper("Memory", "Available Bytes", null);

            memcommit     = new PerformanceCounterWrapper("Memory", "% Committed Bytes In Use", null);      // swap usage?
            privatememory = new PerformanceCounterWrapper("Process", "Private Bytes", "_Total");            // memory pressure in bytes

            cpuqueue = new PerformanceCounterWrapper("System", "Processor Queue Length", null);             // > 5 bad

            nvmbytes = new PerformanceCounterWrapper("PhysicalDisk", "Disk Bytes/sec", "_Total");
            nvmtime  = new PerformanceCounterWrapper("PhysicalDisk", "% Disk Time", "_Total");
            nvmqueue = new PerformanceCounterWrapper("PhysicalDisk", "Current Disk Queue Length", "_Total"); // > 5 bad

            var    nics     = new PerformanceCounterCategory("Network Interface").GetInstanceNames();        // 0 = loopback
            string oldNIC   = Settings.Current.NICDevice;
            bool   nicFound = false;
            string nic      = string.Empty;

            for (int i = 1; i < nics.Length; i++)
            {
                if (nics[i] == oldNIC)
                {
                    nic      = oldNIC;
                    nicFound = true;
                    break;
                }
            }

            if (!nicFound)
            {
                nic = nics[1];
                Settings.Current.NICDevice = nic;
            }

            if (!string.IsNullOrEmpty(Settings.Current.NICDevice))
            {
                netin    = new PerformanceCounterWrapper("Network Interface", "Bytes Received/sec", nic);
                netout   = new PerformanceCounterWrapper("Network Interface", "Bytes Sent/sec", nic);
                netqueue = new PerformanceCounterWrapper("Network Interface", "Output Queue Length", nic);
            }

            splitio      = new PerformanceCounterWrapper("LogicalDisk", "Split IO/sec", "_Total");
            nvmtransfers = new PerformanceCounterWrapper("LogicalDisk", "Disk Transfers/sec", "_Total");
            avgnvmread   = new PerformanceCounterWrapper("LogicalDisk", "Avg. Disk Sec/Read", "_Total");
            avgnvmwrite  = new PerformanceCounterWrapper("LogicalDisk", "Avg. Disk Sec/Write", "_Total");

            interrupt = new PerformanceCounterWrapper("Processor", "% Interrupt Time", "_Total");

            if (Settings.Current.PageFaultsEnabled)
            {
                pagefault = new PerformanceCounterWrapper("Memory", "Page Faults/sec", null);
                pagereads = new PerformanceCounterWrapper("Memory", "Page Reads/sec", null);
            }

            /*
             * // Unreliable if router is involved.
             * var netband = new PerformanceCounterWrapper("Network Interface", "Current Bandwidth", nic);
             * Console.WriteLine("Bandwidth: {0:N0} kB", netband.Value/1000);
             */

            if (OHWSensors)
            {
                HWmon        = new OHW();
                AdminSensors = MKAh.Execution.IsAdministrator;
            }

            Console.WriteLine("Initialization complete.");
        }