File Coverage

blib/lib/Proc/ProcessTable/Match/Swapped.pm
Criterion Covered Total %
statement 8 32 25.0
branch 0 12 0.0
condition n/a
subroutine 3 5 60.0
pod 2 2 100.0
total 13 51 25.4


line stmt bran cond sub pod time code
1             package Proc::ProcessTable::Match::Swapped;
2              
3 1     1   53140 use 5.006;
  1         12  
4 1     1   5 use strict;
  1         2  
  1         17  
5 1     1   3 use warnings;
  1         2  
  1         217  
6              
7             =head1 NAME
8              
9             Proc::ProcessTable::Match::Swapped - Check if the process is swapped out.
10              
11             =head1 VERSION
12              
13             Version 0.0.0
14              
15             =cut
16              
17             our $VERSION = '0.0.0';
18              
19              
20             =head1 SYNOPSIS
21              
22             use Proc::ProcessTable::Match::Swapped;
23            
24             my $checker=Proc::ProcessTable::Match::Swapped->new(;
25            
26             if ( $checker->match( $proc ) ){
27             print "It matches.\n";
28             }
29              
30             =head1 METHODS
31              
32             =head2 new
33              
34             This intiates the object.
35              
36             my $checker=Proc::ProcessTable::Match::Swapped->new;
37              
38             =cut
39              
40             sub new{
41 0     0 1   my $self = {
42             };
43 0           bless $self;
44              
45 0           return $self;
46             }
47              
48             =head2 match
49              
50             Checks if a single Proc::ProcessTable::Process object matches.
51              
52             One argument is taken and that is a Proc::ProcessTable::Process object.
53              
54             The returned value is a boolean.
55              
56             if ( $checker->match( $proc ) ){
57             print "The connection matches.\n";
58             }
59              
60             =cut
61              
62             sub match{
63 0     0 1   my $self=$_[0];
64 0           my $object=$_[1];
65              
66 0 0         if ( !defined( $object ) ){
67 0           return 0;
68             }
69              
70 0 0         if ( ref( $object ) ne 'Proc::ProcessTable::Process' ){
71 0           return 0;
72             }
73              
74 0           my $proc_state;
75 0           eval{
76 0           $proc_state=$object->state;
77             };
78              
79             # don't bother proceeding, the object won't match ever
80             # as it does not have a fname
81 0 0         if ( ! defined( $proc_state ) ){
82 0           return 0;
83             }
84              
85             # will have a 0 rss, but is not swapped
86 0 0         if ( $proc_state =~ /^zombie$/ ){
87 0           return 0;
88             }
89              
90 0           my $proc_rss;
91 0           eval{
92 0           $proc_rss=$object->rss;
93             };
94              
95             # don't bother proceeding, the object won't match ever
96             # as it does not have a fname
97 0 0         if ( ! defined( $proc_rss ) ){
98 0           return 0;
99             }
100              
101             # if the rss 0, it is swapped out
102 0 0         if ( $proc_rss == 0 ){
103 0           return 1;
104             }
105              
106 0           return 0;
107             }
108              
109             =head1 AUTHOR
110              
111             Zane C. Bowers-Hadley, C<< >>
112              
113             =head1 BUGS
114              
115             Please report any bugs or feature requests to C, or through
116             the web interface at L. I will be notified, and then you'll
117             automatically be notified of progress on your bug as I make changes.
118              
119              
120              
121              
122             =head1 SUPPORT
123              
124             You can find documentation for this module with the perldoc command.
125              
126             perldoc Proc::ProcessTable::Match
127              
128              
129             You can also look for information at:
130              
131             =over 4
132              
133             =item * RT: CPAN's request tracker (report bugs here)
134              
135             L
136              
137             =item * AnnoCPAN: Annotated CPAN documentation
138              
139             L
140              
141             =item * CPAN Ratings
142              
143             L
144              
145             =item * Search CPAN
146              
147             L
148              
149             =back
150              
151              
152             =head1 ACKNOWLEDGEMENTS
153              
154              
155             =head1 LICENSE AND COPYRIGHT
156              
157             Copyright 2019 Zane C. Bowers-Hadley.
158              
159             This program is free software; you can redistribute it and/or modify it
160             under the terms of the the Artistic License (2.0). You may obtain a
161             copy of the full license at:
162              
163             L
164              
165             Any use, modification, and distribution of the Standard or Modified
166             Versions is governed by this Artistic License. By using, modifying or
167             distributing the Package, you accept this license. Do not use, modify,
168             or distribute the Package, if you do not accept this license.
169              
170             If your Modified Version has been derived from a Modified Version made
171             by someone other than you, you are nevertheless required to ensure that
172             your Modified Version complies with the requirements of this license.
173              
174             This license does not grant you the right to use any trademark, service
175             mark, tradename, or logo of the Copyright Holder.
176              
177             This license includes the non-exclusive, worldwide, free-of-charge
178             patent license to make, have made, use, offer to sell, sell, import and
179             otherwise transfer the Package with respect to any patent claims
180             licensable by the Copyright Holder that are necessarily infringed by the
181             Package. If you institute patent litigation (including a cross-claim or
182             counterclaim) against any party alleging that the Package constitutes
183             direct or contributory patent infringement, then this Artistic License
184             to you shall terminate on the date that such litigation is filed.
185              
186             Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
187             AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
188             THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
189             PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
190             YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
191             CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
192             CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
193             EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
194              
195              
196             =cut
197              
198             1; # End of Proc::ProcessTable::Match