# foreach $service ( $host->service_names() ) { $services{$service}++;}}
if( grep( /^ping$/, keys %main::SERVICES ) ) { push( @names, "ping" ); }
+ if( grep( /^ping6$/, keys %main::SERVICES ) ) { push( @names, "ping6" ); }
foreach $service ( sort keys %main::SERVICES ) {
- push( @names, $service ) unless $service eq "ping"; }
+ push( @names, $service ) unless $service =~ /ping(6)?/; }
# Print the horizontal axis of the table (names of the services)
}
if( grep( /^ping$/, (@s) ) ) { push( @names, "ping" ); }
+ if( grep( /^ping6$/, (@s) ) ) { push( @names, "ping6" ); }
foreach $service ( sort (@s) ) {
- push( @names, $service ) unless $service eq "ping"; }
+ push( @names, $service ) unless $service =~ /ping(6)?/; }
# Print the horizontal axis of the table (names of the services)
--- /dev/null
+# Register the function the plugin registry
+$PLUGINS{'ping6'} = \&check_ping6;
+
+# This routine checks connectivity. It first trys to "ping6" the machine via
+# a TCP echo using the Net::Ping module, if it can't reach it via that
+# mechanism, then it resorts to the command line ping program. Using the
+# Net::Ping speeds things up quite a bit...
+
+# $Id: check_ping,v 1.10 2001/08/06 23:08:59 sljohnson Exp $
+
+use Spong::SafeExec qw(safe_exec);
+
+sub check_ping6 {
+ my( $host ) = @_;
+ my( $color, $rt, $summary, $message ) = ( "green", "", "", "" );
+ my( @down );
+
+ if( @{$HOSTS{$host}->{'ipv6_addr'}} ) {
+ @hostlist = @{$HOSTS{$host}->{'ipv6_addr'}};
+ } else {
+ @hostlist = ( $host );
+ }
+
+ foreach $host ( @hostlist ) {
+ my $myping = $PING6;
+ my $pingok = 0;
+ $myping =~ s/HOST/$host/g;
+
+ $message = safe_exec($myping);
+ { local $/; undef $/;
+
+ if( $message =~ /bytes from/ ) { $pingok = 1; }
+ if( $message =~ /is alive/ ) { $pingok = 1; }
+ if( $message =~ /octets from/ ) { $pingok = 1; }
+ }
+
+ if( ! $pingok ) {
+ $color = "red";
+ $message .= "\n";
+ push( @down, $host );
+ }
+ }
+
+
+ $summary = "ping6 failed for " . join( ',', @down ) if $color eq "red";
+ $summary = "ping6 ok" if $color eq "green";
+
+ &debug( "ping6 - $host - $color, $summary" );
+ return( $color, $summary, $message );
+}
+
+1;