summaryrefslogtreecommitdiffstats
path: root/lib/Smokeping/probes
diff options
context:
space:
mode:
authorNiko Tyni <ntyni@iki.fi>2005-12-11 08:44:12 +0100
committerNiko Tyni <ntyni@iki.fi>2005-12-11 08:44:12 +0100
commitc1ac0cbb380212efff08eda78af5cbe5e18c5935 (patch)
treec4049f3aa5c0a8b4397ceffd7397d5e96d28eeed /lib/Smokeping/probes
parent4bb9e387247d11ba4c842c4f6490d0e210615d2b (diff)
downloadsmokeping-c1ac0cbb380212efff08eda78af5cbe5e18c5935.tar.gz
smokeping-c1ac0cbb380212efff08eda78af5cbe5e18c5935.tar.xz
* brought trunk/ up to date
Diffstat (limited to 'lib/Smokeping/probes')
-rw-r--r--lib/Smokeping/probes/SSH.pm43
1 files changed, 29 insertions, 14 deletions
diff --git a/lib/Smokeping/probes/SSH.pm b/lib/Smokeping/probes/SSH.pm
index 0f336d6..7756c03 100644
--- a/lib/Smokeping/probes/SSH.pm
+++ b/lib/Smokeping/probes/SSH.pm
@@ -19,7 +19,7 @@ use base qw(Smokeping::probes::basefork);
use IPC::Open3;
use Symbol;
use Carp;
-use POSIX;
+use Time::HiRes qw(gettimeofday tv_interval);
sub pod_hash {
return {
@@ -31,8 +31,12 @@ Integrates ssh-keyscan as a probe into smokeping. The variable B<binary> must
point to your copy of the ssh-keyscan program. If it is not installed on
your system yet, you should install openssh >= 3.8p1
-The Probe asks the given host n-times for it's public key. Where n is
+The Probe asks the given host n-times for it's public key, where n is
the amount specified in the config File.
+
+As part of the initialization, the probe asks localhost for it's public key
+and tries to parse the output. Make sure you have SSH running on the
+localhost as well.
DOC
authors => <<'DOC',
Christian Recktenwald <smokeping-contact@citecs.de>
@@ -51,10 +55,9 @@ sub new($$$)
# no need for this if we run as a cgi
unless ( $ENV{SERVER_SOFTWARE} ) {
- my $call = "$self->{properties}{binary} -t rsa localhost";
+ my $call = "$self->{properties}{binary} -t dsa,rsa,rsa1 localhost";
my $return = `$call 2>&1`;
if ($return =~ m/$ssh_re/s){
- $self->{pingfactor} = 10;
print "### parsing ssh-keyscan output...OK\n";
} else {
croak "ERROR: output of '$call' does not match $ssh_re\n";
@@ -79,27 +82,28 @@ sub pingone ($){
my $host = $target->{addr};
- my $query = "$self->{properties}{binary} -t rsa $host";
+ my $query = "$self->{properties}{binary} -t $target->{vars}->{keytype} $host";
my @times;
# get the user and system times before and after the test
$self->do_debug("query=$query\n");
for (my $run = 0; $run < $self->pings; $run++) {
- my @times1 = POSIX::times;
+ my $t0 = [gettimeofday];
+
my $pid = open3($inh,$outh,$errh, $query);
- while (<$outh>) {
- if (/$ssh_re/i) {
- last;
- }
- }
+ while (<$errh>) {
+ if (/$ssh_re/i) {
+ push @times, tv_interval($t0);
+ last;
+ }
+ }
waitpid $pid,0;
close $errh;
close $inh;
close $outh;
- my @times2 = POSIX::times;
- push @times, $times2[0]-$times1[0];
+
}
- @times = map {sprintf "%.10e", $_ / $self->{pingfactor}} sort {$a <=> $b} grep {$_ ne "-"} @times;
+ @times = map {sprintf "%.10e", $_ } sort {$a <=> $b} @times;
# $self->do_debug("time=@times\n");
return @times;
@@ -121,4 +125,15 @@ sub probevars {
})
}
+sub targetvars {
+ my $class = shift;
+ return $class->_makevars($class->SUPER::targetvars, {
+ keytype => {
+ _doc => "Type of key, used in ssh-keyscan -t <keytype>",
+ _re => "[dt]sa1*",
+ _example => 'dsa',
+ _default => 'rsa',
+ },
+ })
+}
1;