| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Proc::ProcessTableLight; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '0.01'; |
|
4
|
|
|
|
|
|
|
require Exporter; |
|
5
|
|
|
|
|
|
|
@ISA = qw(Exporter); |
|
6
|
|
|
|
|
|
|
@EXPORT_OK = qw(process_table); |
|
7
|
1
|
|
|
1
|
|
14083
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
242
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Proc::ProcessTableLight - Very simple variant of Proc::ProcessTable based on ps unix command |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use strict; |
|
16
|
|
|
|
|
|
|
use Proc::ProcessTableLight 'process_table'; |
|
17
|
|
|
|
|
|
|
use Data::Dumper 'Dumper'; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
my $process_table = process_table; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
foreach my $process (@{$process_table}){ |
|
23
|
|
|
|
|
|
|
print Dumper($process); |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
This module provides access to list of process. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub process_table{ |
|
33
|
|
|
|
|
|
|
|
|
34
|
0
|
|
|
0
|
1
|
|
my @rows=`ps axu`; |
|
35
|
0
|
|
|
|
|
|
my @process_table=(); |
|
36
|
0
|
|
|
|
|
|
my @nams=(); |
|
37
|
0
|
|
|
|
|
|
my $i=0; |
|
38
|
0
|
|
|
|
|
|
foreach my $row (@rows){ |
|
39
|
0
|
|
|
|
|
|
$i++; |
|
40
|
0
|
|
|
|
|
|
my @p=split(/\t/, $row); |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
if ($row=~/^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$/g){ |
|
43
|
0
|
0
|
|
|
|
|
if ($i==1){ |
|
44
|
0
|
|
|
|
|
|
@nams = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11); |
|
45
|
|
|
|
|
|
|
} else { |
|
46
|
0
|
|
|
|
|
|
my @vals = ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11); |
|
47
|
0
|
|
|
|
|
|
my $process={}; |
|
48
|
0
|
|
|
|
|
|
for (my $i=0; $i <= $#vals; $i++){ |
|
49
|
0
|
|
|
|
|
|
$process->{$nams[$i]} = $vals[$i]; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
push(@process_table, $process); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
return \@process_table; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 process_table |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
run ps axu unix command and parce it in array of hash`s and return it |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
L. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 AUTHOR |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Bulichev Evgeniy, >. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Copyright (c) 2017 Bulichev Evgeniy. All rights reserved. |
|
78
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it |
|
79
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |