Class ProcessMonitor
source code
Process monitor for the logging of process statistics.
The process monitor uses either the win32pdh module (windows systems)
or the ps command line utility (unix systems) to obtain and log to file
statistics on a given process as determined by the process id. Usage of
the class is to create an instance specifying the process id, the logging
interval and the log file. Once created, the process monitor is started
and stopped via its start and stop methods. Process monitors are started as a separate
thread, so control passes back to the caller of the start method
immediately.
On windows systems, statistics obtained include the CPU usage (%), the
working set (memory pages allocated), the virtual bytes (virtual address
space including shared memory segments), the private bytes (virtual
address space not including shared memory segments), the number of
process threads and the number of handles. All memory values are quoted
in KBytes and the CPU precentage represents the usage over all available
processors. A CPU usage of 100% represents a single CPU fully utilized;
it is therefore possible to obtain CPU usage figures of over 100% on
multi-core processors. The format of the log file is tab separated, with
timestamps used to denote the time each measurement was obtained, e.g.
:
Time CPU Working Virtual Private Threads Handles
------------------------------------------------------------------------
09/16/08 14:20:44 80 125164 212948 118740 44 327
09/16/08 14:20:49 86 125676 213972 120128 44 328
09/16/08 14:20:54 84 125520 212948 119116 44 328
09/16/08 14:20:59 78 125244 212948 119132 44 328
On unix systems, statistics obtained include the CPU usage (%), the
resident memory (via the rss format specifier to ps), and the virtual
memory (via the vsz format spepcifier to ps). All memory values are
quoted in KBytes and the CPU precentage represents the usage over all
available processors. A CPU usage of 100% represents a single CPU fully
utilized; it is therefore possible to obtain CPU usage figures of over
100% on multi-core processors. The format of the log file is tab
separated, with timestamps used to denote the time each measurement was
obtained, e.g. :
Time CPU Resident Virtual
----------------------------------------------------
09/16/08 14:24:10 69.5 89056 1421672
09/16/08 14:24:20 73.1 101688 1436804
09/16/08 14:24:30 82.9 102196 1436516
09/16/08 14:24:40 89.1 102428 1436372
09/16/08 14:24:50 94.2 104404 1438420
Both windows and unix operating systems support the numProcessors
argument in the variable argument list in order to normalise the CPU
statistics gathered by the number of available CPUs.
|
__init__(self,
pid,
interval,
file=None,
**kwargs)
Construct an instance of the process monitor. |
source code
|
|
|
|
|
|
|
__win32getProfileAttribute(self,
object,
instance,
inum,
counter) |
source code
|
|
|
__win32LogProfile(self,
instance,
inum,
threads,
interval,
file) |
source code
|
|
integer
|
|
|
|
|
|
__init__(self,
pid,
interval,
file=None,
**kwargs)
(Constructor)
| source code
|
Construct an instance of the process monitor.
- Parameters:
pid - The process id to monitor
interval - The interval in seconds to record the process statistics
file - The full path to the file to log the process statistics
kwargs - Keyword arguments to allow platform specific configurations
|
Return the running status of the process monitor.
- Returns: integer
- The running status (True | False)
|