| perfSONAR_PS-Collectors-LinkStatus documentation | view source | Contained in the perfSONAR_PS-Collectors-LinkStatus distribution. |
perfSONAR_PS::Collectors::LinkStatus::Agent::Script - This module provides an agent for the Link Status Collector that gets status information by executing a script.
This agent will run a script that should print out the link status information in the format: "timestamp,measurement_value".
use strict; use warnings; use Log::Log4perl qw(get_logger);
our $VERSION = 0.09;
use fields 'TYPE', 'SCRIPT','PARAMETERS';
my $self = fields::new($class);
$self->{"TYPE"} = $type;
$self->{"SCRIPT"} = $script;
$self->{"PARAMETERS"} = $parameters;
return $self;
}
return $self->{TYPE};
}
$self->{TYPE} = $type;
return;
}
$self->{SCRIPT} = $script;
return;
}
return $self->{SCRIPT};
}
$self->{PARAMETERS} = $parameters;
return;
}
return $self->{PARAMETERS};
}
my $cmd = $self->{SCRIPT} . " " . $self->{TYPE};
if (defined $self->{PARAMETERS}) {
$cmd .= " " . $self->{PARAMETERS};
}
$logger->debug("Command to run: $cmd");
open my $SCRIPT, "-|", $cmd or return (-1, "Couldn't execute cmd: $cmd");
my @lines = <$SCRIPT>;
close($SCRIPT);
if ($#lines < 0) {
my $msg = "script returned no output";
return (-1, $msg);
}
if ($#lines > 0) {
my $msg = "script returned invalid output: more than one line";
return (-1, $msg);
}
$logger->debug("Command returned \"$lines[0]\"");
chomp($lines[0]);
my ($measurement_time, $measurement_value) = split(',', $lines[0]);
if (not defined $measurement_time or $measurement_time eq "") {
my $msg = "script returned invalid output: does not contain measurement time";
return (-1, $msg);
}
if (not defined $measurement_value or $measurement_value eq "") {
my $msg = "script returned invalid output: does not contain link status";
return (-1, $msg);
}
$measurement_value = lc($measurement_value);
return (0, $measurement_time, $measurement_value);
}
1;
__END__
To join the 'perfSONAR-PS' mailing list, please visit:
https://mail.internet2.edu/wws/info/i2-perfsonar
The perfSONAR-PS subversion repository is located at:
https://svn.internet2.edu/svn/perfSONAR-PS
Questions and comments can be directed to the author, or the mailing list. Bugs, feature requests, and improvements can be directed here:
https://bugs.internet2.edu/jira/browse/PSPS
$Id:$
Aaron Brown, aaron@internet2.edu
You should have received a copy of the Internet2 Intellectual Property Framework along with this software. If not, see <http://www.internet2.edu/membership/ip.html>
Copyright (c) 2004-2008, Internet2 and the University of Delaware
All rights reserved.
| perfSONAR_PS-Collectors-LinkStatus documentation | view source | Contained in the perfSONAR_PS-Collectors-LinkStatus distribution. |