Script Monitor - Perl script on remote windows system to check socket status on another system

Script Monitor - Perl script on remote windows system to check socket status on another system

Hello,

I have OpManager setup to run script monitors on a linux box that checks socket connections to a third (remote server)

OpManager runs a script on System B  that checks a port on System C and returns the result to opmanager.  This works fine.

The problem is I need to move the current linux system to windows and need to find a way to execute a perl (or other script) on System B from opmanager that checks port/socket status on System C, and get the results back to opmanager. 

This this possible?

This is the current script:

use strict;
use Socket;

# set time until connection attempt times out
my $timeout = 3;


my $hostname = 'hostname';
my $portnumber = '123';
my $host = shift || $hostname;
my $port = shift || $portnumber;
my $proto = getprotobyname('tcp');
my $iaddr = inet_aton($host);
my $paddr = sockaddr_in($port, $iaddr);
my $Response = 1;



socket(SOCKET, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";

eval {
  local $SIG{ALRM} = sub { die "timeout" };
  alarm($timeout);
  connect(SOCKET, $paddr) || error();
  alarm(0);
};

if ($@) {
  close SOCKET || die "close: $!";
$Response=$Response+11;
  print "Message: $hostname not listening on tcp port $portnumber\n";
  print "Data:\n";
  print "Response\t$Response\n";
exit 9;
}
else {
  close SOCKET || die "close: $!";
$Response=$Response-1;
  print "Message: $hostname is listening on tcp port $portnumber\n";
  print "Data:\n";
  print "Response\t$Response";
  exit 0;
}

                New to ADSelfService Plus?