ASNMTAP

 view release on metacpan or  search on metacpan

plugins/jUnit/check_jUnit.pl  view on Meta::CPAN

} elsif ( defined $_ACTIVATED and ! $_ACTIVATED ) {
  $objectPlugins->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, alert => "Test has been deactivated with status '$_STATUS' onto the jUnit server. PLEASE contact Monitoring Office" }, $TYPE{REPLACE} );
} elsif ( defined $_ACTIVATED and $_STATUS ne 'ASNMTAP' ) {
  $objectPlugins->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, alert => "Test has been activated with status '$_STATUS' onto the jUnit server. PLEASE contact Monitoring Office" }, $TYPE{REPLACE} );
} else {
  $objectPlugins->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, alert => "No base service defined into the table $jUnitServerTablDR from database $jUnitServerDbDR" }, $TYPE{APPEND} );
}

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# End plugin  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

$objectPlugins->exit (7);

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

sub scan_socket_info_jUnit {
  my ($asnmtapInherited, $protocol, $host, $port, $service, $request, $socketTimeout, $xml, $debug) = @_;

  my ($exit, $result, $action, $socketProtocol);
  $exit   = 0;
  $action = '<NIHIL>';

  print "\nscan_socket_info : <$protocol><$host><$port><$service><$request>\n$xml\n\n" if ($debug >= 2);

  if ($protocol eq 'tcp' || $protocol eq 'udp') { $socketProtocol = $protocol; } else { $socketProtocol = 'tcp'; }

  $SIG{ALRM} = sub { alarm (0); $exit = 1 };
  alarm ( 10 ); $exit = 0;

  use IO::Socket;

  if (defined $socketTimeout) {
    $result = new IO::Socket::INET ('Proto' => $socketProtocol, 'PeerAddr' => $host, 'PeerPort' => $port, 'Timeout' => $socketTimeout);
  } else {
    $result = new IO::Socket::INET ('Proto' => $socketProtocol, 'PeerAddr' => $host, 'PeerPort' => $port);
  }

  if ($result) {
    print "IO::Socket::INET : $result\n" if ($debug >= 2);
  } else {
    print "IO::Socket::INET : <NIHIL>\n" if ($debug >= 2);
    $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, alert => "Cannot connect to $host:$port" }, $TYPE{APPEND} );
    return ( $ERRORS{UNKNOWN} );
  }

  $result->autoflush(1);

  if ($socketProtocol eq 'tcp') {
    print "jUnit($port): wait for answer\n" if ($debug >= 2);

    while (<$result>) {
      chomp;
      print "jUnit($port): <$_>\n" if ($debug >= 2);
      if ($exit) { $action = '<TIMEOUT>'; last; }

      SWITCH: {
        if ($_ =~ /^junitserver signal INIT$/)                 {
		  $action = 'junitserver signal INIT'; 
		  $xml =~ s/\n//g if ($xmlCleanUpLineFeeds); 
		  $xml =~ s/> +</></g if ($xmlCleanUpSpaces); 
		  print $result "$xml\n";
		  print "$xml\n" if ( $debug );
        }

        if ($_ =~ /^junitserver signal XML_NOTOK$/)            { $action = 'junitserver signal XML_NOTOK'; last; }
        if ($_ =~ /^junitserver signal WRONG USER\/PASSWORD$/) { $action = 'junitserver signal WRONG USER/PASSWORD'; last; }
        if ($_ =~ /^junitserver signal SENT_OK$/)              { $action = 'junitserver signal SENT_OK'; last; }
      }
    }
  } elsif ($socketProtocol eq 'udp') {
    print "udp : $service($port), no RFC implementation\n" if ($debug >= 2);
  }

  alarm (0); $SIG{ALRM} = 'DEFAULT';
  close ( $result );

  unless (defined $request) { $request = "$service($port)"; }

  if ($request eq $action) {
    $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{OK}, alert => $action }, $TYPE{APPEND} );
    return ( $ERRORS{OK} );
  } else {
    $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, alert => "Wrong answer from $host $service: $action" }, $TYPE{APPEND} );
    return ( $ERRORS{UNKNOWN} );
  }
}

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

sub errorTrapDBI {
  my ($asnmtapInherited, $error_message) = @_;

  $$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, alert => $error_message, error => "$DBI::err ($DBI::errstr)" }, $TYPE{APPEND} );
  return 0;
}

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



( run in 0.482 second using v1.01-cache-2.11-cpan-e1769b4cff6 )