File: //opt/VRTSpbx/bin/cluster/monitor
#!/opt/VRTSvcs/bin/perl5
###############################################################
# This script monitors an PBX resource on a vcs cluster.
# This is a basic test to prove that a connection can be established.
# The outline:
# - check if pbx_exchange server is able to register a server.
# - If yes, unregister the dummy server.
###############################################################
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
& eval 'exec perl -S $0 $argv:q'
if 0;
#use strict;
my $Server;
# Get arguments by calling subroutine get_arg_list()
my @args = get_arg_list();
my ($vcs_home, $pbx_home, $arg3, $port_number, $is_windows, $separator) = @args;
my $vcs_home = $ENV{"VCS_HOME"} || $vcs_home ;
my $dir="$pbx_home$separator"."bin";
my $HALOG="$vcs_home$separator"."bin$separator"."halog";
my $command_string="";
if($^O=~/win/i)
{
$ENV{'PATH'}="$pbx_home;$ENV{'PATH'}";
$command_string = "\"$pbx_home\\bin\\monitor_server\" localhost $port_number pbx_monitor";
}
else
{
if($^O=~/hp/i)
{
$ENV{'SHLIB_PATH'}=$dir;
$ENV{'SHLIB_PATH'}.=":/opt/VRTSpbx/lib";
}
if($^O=~/aix/i)
{
$ENV{'LIBPATH'}=$dir;
$ENV{'LIBPATH'}.=":/opt/VRTSpbx/lib";
} elsif ($^O=~/Darwin/i) {
$ENV{'DYLD_LIBRARY_PATH'}=$dir;
$ENV{'DYLD_LIBRARY_PATH'}.=":/opt/VRTSpbx/lib";
}
else
{
$ENV{'LD_LIBRARY_PATH'}=$dir;
$ENV{'LD_LIBRARY_PATH'}.=":/opt/VRTSpbx/lib";
}
$command_string = "/opt/VRTSpbx/bin/cluster/monitor_server localhost $port_number pbx_monitor";
}
my $retCode=system($command_string);
if ($retCode == 0)
{
exit (110);
}
else
{
print "PBX is not running !\n";
exit(100);
}
###############################################################
# Get VCS Home, PBX Home, PBX Conf and port number arguments
# value from VCS.
###############################################################
sub get_arg_list {
my $arg;
my @argList =();
my $vcs_home = "/opt/VRTSvcs";
my $pbx_home = "/opt/VRTSpbx";
;
my $pbx_conf = "svc.conf";
my $port_number = 1556;
my $is_windows = 0;
my $separator = "/";
my $os = `ver`;
if ($os =~ /Windows/) {
$is_windows = 1;
$separator = "\\";
}
# first argument is resource name
shift(@ARGV);
for ($i=0;$i<=@ARGV;$i++) {
if ( $ARGV[$i] =~ /pbx/i) {
# extract pbx homepath
$pbx_home = $ARGV[$i];
}
elsif ($ARGV[$i] =~ /cluster/i) {
# extract vcs homepath
$vcs_home = $ARGV[$i];
}
elsif ( $ARGV[$i] =~ /\w+/) {
$port_number = $ARGV[$i];
}
}
push (@argList, $vcs_home);
push (@argList, $pbx_home);
push (@argList, $pbx_conf);
push (@argList, $port_number);
push (@argList, $is_windows);
push (@argList, $separator);
return @argList;
}