line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBD::Sys::Plugin::Win32::Procs; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
4331
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
117
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
119
|
|
5
|
3
|
|
|
3
|
|
17
|
use vars qw($VERSION @colNames); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
179
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
14
|
use base qw(DBD::Sys::Table); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1945
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$VERSION = "0.102"; |
10
|
|
|
|
|
|
|
@colNames = qw(pid ppid uid sess cmndline start fulltime virtsize fname state threads); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=pod |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
DBD::Sys::Plugin::Win32::Procs - provides a table containing running processes |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$processes = $dbh->selectall_hashref("select * from procs", "pid"); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 ISA |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
DBD::Sys::Plugin::Win32::Procs; |
25
|
|
|
|
|
|
|
ISA DBD::Sys::Table |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This module provides the table C for the MSWin32 compatible |
30
|
|
|
|
|
|
|
environment (this might cover cygwin, too). |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 COLUMNS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head3 pid |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Process ID |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head3 ppid |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Parent process ID |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head3 uid |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
UID of process |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head3 sess |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Session ID |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head3 fulltime |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
User + system time |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head3 virtsize |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Virtual memory size (bytes) |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head3 fname |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
File name |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head3 start |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Start time (seconds since the epoch) |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head3 state |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
State of process |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head3 cmndline |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Full command line of process |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head3 threads |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Amount of threads used by this process |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my ( $have_win32_process_info, $have_win32_process_commandline ); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 METHODS |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 get_col_names |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Returns the column names of the table as named in L |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
0
|
1
|
|
sub get_col_names() { @colNames } |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 get_primary_key |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Returns 'pid' - which is the process identifier. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
0
|
1
|
|
sub get_primary_key() { return 'pid'; } |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 collect_data |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Retrieves the data from L and put it into fetchable rows. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub collect_data |
107
|
|
|
|
|
|
|
{ |
108
|
0
|
|
|
0
|
1
|
|
my $self = $_[0]; |
109
|
0
|
|
|
|
|
|
my @data; |
110
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
unless ( defined($have_win32_process_info) ) |
112
|
|
|
|
|
|
|
{ |
113
|
0
|
|
|
|
|
|
( $have_win32_process_info, $have_win32_process_commandline ) = ( 0, 0 ); |
114
|
0
|
|
|
|
|
|
eval { require Win32::Process::Info; $have_win32_process_info = 1; }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
eval { require Win32::Process::CommandLine; $have_win32_process_commandline = 1; }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
0
|
0
|
|
|
|
|
Win32::Process::Info->import( 'NT', 'WMI' ) if ($have_win32_process_info); |
118
|
0
|
0
|
|
|
|
|
Win32::Process::CommandLine->import() if ($have_win32_process_commandline); |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
0
|
0
|
|
|
|
|
if ($have_win32_process_info) |
122
|
|
|
|
|
|
|
{ |
123
|
0
|
|
|
|
|
|
for my $procInfo ( Win32::Process::Info->new()->GetProcInfo() ) |
124
|
|
|
|
|
|
|
{ |
125
|
0
|
|
0
|
|
|
|
( my $uid = $procInfo->{OwnerSid} || 0 ) =~ s/.*-//; |
126
|
0
|
|
|
|
|
|
my $cli = ""; |
127
|
0
|
0
|
|
|
|
|
Win32::Process::CommandLine::GetPidCommandLine( $procInfo->{ProcessId}, $cli ) |
128
|
|
|
|
|
|
|
if ($have_win32_process_commandline); |
129
|
0
|
|
0
|
|
|
|
$cli ||= ""; |
130
|
0
|
|
|
|
|
|
$cli =~ s{^\S+\\}{}; |
131
|
0
|
|
|
|
|
|
$cli =~ s{\s+$}{}; |
132
|
0
|
|
0
|
|
|
|
push( |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
133
|
|
|
|
|
|
|
@data, |
134
|
|
|
|
|
|
|
[ |
135
|
|
|
|
|
|
|
$procInfo->{ProcessId}, |
136
|
|
|
|
|
|
|
$procInfo->{ParentProcessId} || 0, |
137
|
|
|
|
|
|
|
$uid, |
138
|
|
|
|
|
|
|
$procInfo->{SessionId} || 0, |
139
|
|
|
|
|
|
|
$cli || $procInfo->{Name} || "", |
140
|
|
|
|
|
|
|
$procInfo->{CreationDate}, |
141
|
|
|
|
|
|
|
int( |
142
|
|
|
|
|
|
|
( $procInfo->{KernelModeTime} || 0 ) + |
143
|
|
|
|
|
|
|
( $procInfo->{UserModeTime} || 0 ) + .499 |
144
|
|
|
|
|
|
|
), |
145
|
|
|
|
|
|
|
$procInfo->{VirtualSize} || $procInfo->{WorkingSetSize}, |
146
|
|
|
|
|
|
|
$procInfo->{ExecutablePath}, |
147
|
|
|
|
|
|
|
$procInfo->{_status} || $procInfo->{Status} || $procInfo->{ExecutionState}, |
148
|
|
|
|
|
|
|
$procInfo->{ThreadCount} || 1, |
149
|
|
|
|
|
|
|
] |
150
|
|
|
|
|
|
|
); |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
return \@data; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 PREREQUISITES |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
The module L is required to provide data for the |
160
|
|
|
|
|
|
|
table. In rare cases, it could be useful to have |
161
|
|
|
|
|
|
|
L installed, too. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 AUTHOR |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Jens Rehsack Alexander Breibach |
166
|
|
|
|
|
|
|
CPAN ID: REHSACK |
167
|
|
|
|
|
|
|
rehsack@cpan.org alexander.breibach@googlemail.com |
168
|
|
|
|
|
|
|
http://www.rehsack.de/ |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
The primary hint how to provide this table for windows comes from |
173
|
|
|
|
|
|
|
H.Merijn Brand. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 COPYRIGHT |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This program is free software; you can redistribute |
178
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
The full text of the license can be found in the |
181
|
|
|
|
|
|
|
LICENSE file included with this module. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 SUPPORT |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Free support can be requested via regular CPAN bug-tracking system. There is |
186
|
|
|
|
|
|
|
no guaranteed reaction time or solution time, but it's always tried to give |
187
|
|
|
|
|
|
|
accept or reject a reported ticket within a week. It depends on business load. |
188
|
|
|
|
|
|
|
That doesn't mean that ticket via rt aren't handles as soon as possible, |
189
|
|
|
|
|
|
|
that means that soon depends on how much I have to do. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Business and commercial support should be acquired from the authors via |
192
|
|
|
|
|
|
|
preferred freelancer agencies. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
1; |
197
|
|
|
|
|
|
|
|