MachineInfo/KeepAlive.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 8 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 45 CC 2 SCAR 12.0
CC
2
Cov
0%
get
6.0
units
2.0
BEGIN
2.0
CRAP 3.3
1 =head1 NAME
2  
3 Probe::MachineInfo::KeepAlive - Keepalive
4  
5 =head1 SYNOPSIS
6  
7 blah
8  
9 =head1 DESCRIPTION
10  
11 blah
12  
13 =head1 PUBLIC INTERFACE
14  
15 =cut
16  
17 package Probe::MachineInfo::KeepAlive;
18  
19  
20 # pragmata
21 use base qw(Probe::MachineInfo::Metric);
22 use strict;
23 use warnings;
24  
25  
26 # Standard Perl Library and CPAN modules
27  
28 #
29 # CLASS ATTRIBUTES
30 #
31  
32 #
33 # CONSTRUCTOR
34 #
35  
36  
37 =head2 get
38  
39 get()
40  
41 Calculates keepalive by multiplying /proc/sys/net/ipv4/tcp_keepalive_{intvl,probes}
42  
43 =cut
44  
45 sub get {
46 my ($self) = @_;
47  
48 my @values = ();
49 my $filename_base = '/proc/sys/net/ipv4/tcp_keepalive_';
50  
51 foreach my $property (qw(intvl probes)) {
52 my $filename = $filename_base . $property;
53 open(FILE, '<', $filename) or $self->log->warn("Unable to open $filename: $!\n") and return;
54 my $value = <FILE>;
55 chomp $value;
56 close(FILE) or $self->log->debug("Unable to close $filename: $!\n");
57 push @values, $value;
58 }
59  
60 return unless @values == 2;
61  
62 my $keepalive = $values[0] * $values[1];
63  
64 # Return in mins
65 return $keepalive/60;
66 }
67  
68 =head2 units
69  
70 units()
71  
72 mins
73  
74 =cut
75  
76 sub units {
77 my ($self) = @_;
78  
79 return "mins";
80 }
81  
82 1;
83  
84 =head1 AUTHOR
85  
86 Sagar R. Shah
87  
88 =cut