Probe::MachineInfo::KeepAlive - Keepalive


Probe-MachineInfo documentation Contained in the Probe-MachineInfo distribution.

Index


Code Index:

NAME

Top

Probe::MachineInfo::KeepAlive - Keepalive

SYNOPSIS

Top

blah

DESCRIPTION

Top

blah

PUBLIC INTERFACE

Top

get

 get()

Calculates keepalive by multiplying /proc/sys/net/ipv4/tcp_keepalive_{intvl,probes}

units

 units()

mins

AUTHOR

Top

Sagar R. Shah


Probe-MachineInfo documentation Contained in the Probe-MachineInfo distribution.
package Probe::MachineInfo::KeepAlive;


# pragmata
use base qw(Probe::MachineInfo::Metric);
use strict;
use warnings;


# Standard Perl Library and CPAN modules

#
# CLASS ATTRIBUTES
#

#
# CONSTRUCTOR
#


sub get {
	my ($self) = @_;

	my @values = ();
	my $filename_base = '/proc/sys/net/ipv4/tcp_keepalive_';

	foreach my $property (qw(intvl probes)) {
		my $filename = $filename_base . $property;
		open(FILE, '<', $filename) or $self->log->warn("Unable to open $filename: $!\n") and return;
		my $value = <FILE>;
		chomp $value;
		close(FILE) or $self->log->debug("Unable to close $filename: $!\n");
		push @values, $value;
	}

	return unless @values == 2;

	my $keepalive = $values[0] * $values[1];

	# Return in mins
	return $keepalive/60;
}

sub units {
	my ($self) = @_;

	return "mins";
}

1;