Ejemplo n.º 1
0
        public Int64 monitor(Int32 PID)
        {
            Int64 cpuUsages = 0;

            try
            {
                WMIProcess_Query pr = new WMIProcess_Query();
                cpuUsages = (Int64)pr.cpuUsageOfProcess(PID);
            }
            catch (Exception e)
            {
                Logger.Log("cpuUsagesMonitor.monitor:" + e.Message);
            }
            return(cpuUsages);
        }
Ejemplo n.º 2
0
        public Int64 monitor(Int32 PID)
        {
            Int64 virtualSize = 0;

            try
            {
                WMIProcess_Query             wmi_query = new WMIProcess_Query();
                System.Collections.Hashtable ht        = wmi_query.processProperties(PID);

                virtualSize = Convert.ToInt64(ht["VirtualSize"].ToString());
            }
            catch (Exception e)
            {
                Logger.Log("Exception VirtualMemoryMonitor: " + e.Message);
            }

            //Int64 workingSize = Convert.ToInt64(ht["WorkingSetSize"].ToString());

            return(virtualSize);
        }
Ejemplo n.º 3
0
        public Hashtable processProperties(Int32 processID)
        {
            ArrayList processPropertiesArray = new ArrayList();
            Hashtable ht = new Hashtable();


            SelectQuery msQuery = new SelectQuery("SELECT * FROM Win32_Process Where ProcessId = '" + processID + "'");

            ManagementObjectSearcher searcher = new ManagementObjectSearcher(msQuery);

            foreach (ManagementObject item in searcher.Get())
            {
                /* try{ processPropertiesArray.Add("CommandLine: " + item["CommandLine"].ToString()); }
                 * catch (SystemException){}                    */
                // try{ processPropertiesArray.Add("CreationDate: " + item["CreationDate"].ToString()); }
                // catch (SystemException){}

                /*try{ processPropertiesArray.Add("ExecutablePath: " + item["ExecutablePath"].ToString()); }
                 * catch (SystemException){}*/
                //try{ processPropertiesArray.Add("ExecutionState: " + item["ExecutionState"].ToString()); }
                //catch (SystemException){}

                /*try{ processPropertiesArray.Add("Handle: " + item["Handle"].ToString()); }
                 * catch (SystemException){}
                 * try{ processPropertiesArray.Add("HandleCount: " + item["HandleCount"].ToString()); }
                 * catch (SystemException){}
                 * try{ processPropertiesArray.Add("InstallDate: " + item["InstallDate"].ToString()); }
                 * catch (SystemException){}*/
                try{ processPropertiesArray.Add("KernelModeTime: " + item["KernelModeTime"].ToString()); }
                catch (SystemException) {}
                try{ processPropertiesArray.Add("MaximumWorkingSetSize: " + item["MaximumWorkingSetSize"].ToString()); }
                catch (SystemException) {}

                /* try{ processPropertiesArray.Add("Memory Usage: " + ProcessMethod.TranslateMemoryUsage(item["WorkingSetSize"].ToString())); }
                 * catch (SystemException){}*/
                /*  try{ processPropertiesArray.Add("MinimumWorkingSetSize: " + item["MinimumWorkingSetSize"].ToString()); }
                 * catch (SystemException){}*/
                try{ processPropertiesArray.Add("Name: " + item["Name"].ToString()); }
                catch (SystemException) {}

                /*try{ processPropertiesArray.Add("OSName: " + item["OSName"].ToString()); }
                 * catch (SystemException){}
                 * try{ processPropertiesArray.Add("PageFaults: " + item["PageFaults"].ToString()); }
                 * catch (SystemException){}
                 * try{ processPropertiesArray.Add("PageFileUsage: " + item["PageFileUsage"].ToString()); }
                 * catch (SystemException){}
                 * try{ processPropertiesArray.Add("ParentProcessId: " + item["ParentProcessId"].ToString()); }
                 * catch (SystemException){}
                 * try{ processPropertiesArray.Add("PeakPageFileUsage: " + item["PeakPageFileUsage"].ToString()); }
                 * catch (SystemException){} */
                try { processPropertiesArray.Add("PeakVirtualSize: " + TranslateVirtualSize(item["PeakVirtualSize"].ToString())); }
                catch (SystemException) {}

                /*try{ processPropertiesArray.Add("PeakWorkingSetSize: " + item["PeakWorkingSetSize"].ToString()); }
                 * catch (SystemException){}
                 * try{ processPropertiesArray.Add("Priority: " + item["Priority"].ToString()); }
                 * catch (SystemException){}
                 * try{ processPropertiesArray.Add("PrivatePageCount: " + item["PrivatePageCount"].ToString()); }
                 * catch (SystemException){}    */
                try{ processPropertiesArray.Add("ProcessId: " + item["ProcessId"].ToString()); }
                catch (SystemException) {}

                /*try{ processPropertiesArray.Add("QuotaNonPagedPoolUsage: " + item["QuotaNonPagedPoolUsage"].ToString()); }
                 * catch (SystemException){}
                 * try{ processPropertiesArray.Add("QuotaPagedPoolUsage: " + item["QuotaPagedPoolUsage"].ToString()); }
                 * catch (SystemException){}
                 * try{ processPropertiesArray.Add("QuotaPeakNonPagedPoolUsage: " + item["QuotaPeakNonPagedPoolUsage"].ToString()); }
                 * catch (SystemException){}
                 * try{ processPropertiesArray.Add("QuotaPeakPagedPoolUsage: " + item["QuotaPeakPagedPoolUsage"].ToString()); }
                 * catch (SystemException){}    */
                try{ processPropertiesArray.Add("SessionId: " + item["SessionId"].ToString()); }
                catch (SystemException) {}

                /*try{ processPropertiesArray.Add("Status: " + item["Status"].ToString()); }
                 * catch (SystemException){}
                 * try{ processPropertiesArray.Add("TerminationDate: " + item["TerminationDate"].ToString()); }
                 * catch (SystemException){}
                 * try{ processPropertiesArray.Add("ThreadCount: " + item["ThreadCount"].ToString()); }
                 * catch (SystemException){}    */
                try{ processPropertiesArray.Add("UserModeTime: " + item["UserModeTime"].ToString()); }
                catch (SystemException) {}
                try{ processPropertiesArray.Add("VirtualSize: " + WMIProcess_Query.TranslateVirtualSize(item["VirtualSize"].ToString())); }
                catch (SystemException) {}
                //try{ processPropertiesArray.Add("WindowsVersion: " + item["WindowsVersion"].ToString()); }
                //catch (SystemException){}
                try { processPropertiesArray.Add("WorkingSetSize: " + WMIProcess_Query.TranslateVirtualSize(item["WorkingSetSize"].ToString())); }
                catch (SystemException) {}

                ht.Add("VirtualSize", item["VirtualSize"].ToString());
                ht.Add("WorkingSetSize", item["WorkingSetSize"].ToString());
            }

            Logger.Log("----------------------------");
            foreach (string item in processPropertiesArray)
            {
                Logger.Log(item.ToString());
            }

            return(ht);
        }