[smokeping-users] Smokeping::probes::basefork:ping fails

Tony DeMatteis tonydema at gmail.com
Wed Sep 5 16:32:47 CEST 2018


Greetings,

I have been attempting to debug an issue with a custom probe I've written
based off the TelnetIOSPing probe.  The probe returns an array of ping
results to the caller, Smokeping::probes::basefork::ping, but the "$result"
variable read in the caller equals "interrupted".  I have been unable to
get any further with identifying why this is the case.  I'm not an active
perl programmer but drawing on some older experience.  I've included what I
believe to be the pertinent code and some debug output; the values of the
ping @output and  the @times array both before and after the processor
which formats the times to values for RRD.  Perhaps it's something obvious
and I apologize for that.  Any help pointing me in the right direction
would be great.  Thank you

The probe connects to a Mikrotik Router via SSH and retrieves ping stats.
Then it parses the result with the exact same code as from the
TelnetIOSPing probe.

*# /usr/share/perl5/Smokeping/probes/base.pm <http://base.pm/>*
*# The only modification to the base.pm <http://base.pm/> code is the
do_debug statements*

    while ($s->handles and $timeleft > 0) {
      for my $ready ($s->can_read($timeleft)) {
        $s->remove($ready);
        my $response = <$ready>;
        close $ready;

*$self->do_debug("Returned from probe");*
*$self->do_debug(Dumper \$response);  <--- Result = 'interrupted'*

        chomp $response;
        my @times = split(/ /, $response);
        my $target = $targetlookup{$ready};
        my $tree = $target->{tree};
        $self->{rtts}{$tree} = \@times;

        $self->do_debug("$target->{addr}: got $response");
      }
      $timeleft = $timeout - (time() - $starttime);
    }

*# /usr/share/perl5/Smokeping/probes/MikrotikRouterOSPing.pm*
...
  #
  # Get ping stats
  #
  if ( $psource ) {
    @output = $ssh->capture("ping $dest count=$pings size=$bytes
src-address=$psource");
  } else {
    @output = $ssh->capture("ping $dest count=$pings size=$bytes");
  }
  $ssh->system("quit");

# DEBUG - Log raw result
logit("MikrotikRouterOSPing Raw result from host:");
logit(@output);

  my @times = ();
  while (@output) {
    my $outputline = shift @output;
    chomp($outputline);
    $outputline =~ /(\d)ms/ && push(@times,$1);
  }

logit("MikrotikRouterOSPing \@times[] Pre Preprocessing.");
logit(@times);

  @times = map {sprintf "%.10e", $_ / $self->{pingfactor}} sort {$a <=> $b}
@times;

# DEBUG - Pings Post processing
logit("MikrotikRouterOSPing Pings Post Preprocessing.  Returning this to
caller:");
logit(@times);

my $parent = getcaller();
logit("MikrotikRouterOSPing Returning ping times to $parent");

  return @times;
}

*# Debug Logging results*

MikrotikRouterOSPing Raw result from host:
-------------------[ DEBUG ]---------------------
$VAR1 = [
',        '  SEQ HOST                                     SIZE TTL TIME
STATUS
',        '    0 8.8.8.8                                56 255 7ms
',        '    1 8.8.8.8                                56 255 9ms
',        '    2 8.8.8.8                                56 255 5ms
',        '    3 8.8.8.8                                56 255 8ms
',        '    4 8.8.8.8                                56 255 9ms
',        '    5 8.8.8.8                                56 255 9ms
',        '    6 8.8.8.8                                56 255 8ms
',        '    7 8.8.8.8                                56 255 10ms
',        '    8 8.8.8.8                                56 255 7ms
',        '    9 8.8.8.8                                56 255 9ms
',        '   10 8.8.8.8                                56 255 7ms
',        '   11 8.8.8.8                                56 255 10ms
',        '   12 8.8.8.8                                56 255 7ms
',        '   13 8.8.8.8                                56 255 9ms
',        '   14 8.8.8.8                                56 255 7ms
',        '   15 8.8.8.8                                56 255 8ms
',        '   16 8.8.8.8                                56 255 8ms
',        '   17 8.8.8.8                                56 255 8ms
',        '   18 8.8.8.8                                56 255 8ms
',        '   19 8.8.8.8                                56 255 9ms
',        '    sent=20 received=20 packet-loss=0% min-rtt=5ms avg-rtt=8ms
max-rtt=10ms
'         '
        ];
MikrotikRouterOSPing @times[] Pre Preprocessing.
-------------------[ DEBUG ]---------------------
$VAR1 = [
          '7',
          '9',
          '5',
          '8',
          '9',
          '9',
          '8',
          '0',
          '7',
          '9',
          '7',
          '0',
          '7',
          '9',
          '7',
          '8',
          '8',
          '8',
          '8',
          '9',
          '5'
        ];
MikrotikRouterOSPing Pings Post Preprocessing.  Returning this to caller:
-------------------[ DEBUG ]---------------------
$VAR1 = [
          '0.0000000000e+00',
          '0.0000000000e+00',
          '5.0000000000e-03',
          '5.0000000000e-03',
          '7.0000000000e-03',
          '7.0000000000e-03',
          '7.0000000000e-03',
          '7.0000000000e-03',
          '7.0000000000e-03',
          '8.0000000000e-03',
          '8.0000000000e-03',
          '8.0000000000e-03',
          '8.0000000000e-03',
          '8.0000000000e-03',
          '8.0000000000e-03',
          '9.0000000000e-03',
          '9.0000000000e-03',
          '9.0000000000e-03',
          '9.0000000000e-03',
          '9.0000000000e-03',
          '9.0000000000e-03'
        ];
MikrotikRouterOSPing Returning ping times to
Smokeping::probes::basefork::ping
Thu Aug 30 15:22:50 2018 - MikrotikRouterOSPing: Returned from probe
*Thu Aug 30 15:22:50 2018 - MikrotikRouterOSPing: $VAR1 = \'interrupted**';*
*Thu Aug 30 15:22:50 2018 - MikrotikRouterOSPing: 8.8.8.8
<http://8.8.8.8/>: got interrupted*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.oetiker.ch/pipermail/smokeping-users/attachments/20180905/c6ad1ab0/attachment.html>


More information about the smokeping-users mailing list