GreatBay Beacon Endpoint Profiler

Uses ssh to check the status of the HA setup in an active/passive cluster, as well as the status of each of the individual servers.

Essentially just parses:

service profiler HAstatus

service profiler status

  • sub trim($);
    sub trim($)
    {
    my $string = shift;
    $string =~ s/^\s+//;
    $string =~ s/\s+$//;
    return $string;
    }

    $string = `service profiler HAstatus`;

    $left = index($string, " ");
    $right = index($string, " ", $left + 1);

    #HArole will either be primary or secondary
    #HAstatus will either be online or offline
    $HArole = trim(substr($string, $left, $right - $left));
    $HAstatus = trim(substr($string, index($string, " ", $right + 1)));

    #if we get a cli argument, we can check to see if a service is running
    $numargs = $#ARGV + 1;
    if ($numargs == 1)
    {
    #service should be one of {Server|Forwarder|NetMap|NetTrap|NetWatch|NetInquiry|NetRelay}
    #servicestatus should be running on the Primary HA, and Not Running on the secondary
    $service = $ARGV[0];
    $servicestatus = `service profiler status | grep $service`;
    $servicestatus = trim(substr($servicestatus, length($service)+4)) . "\n";

    if ($HArole eq "Primary")
    {
    #Services should be running on the Primary
    print $servicestatus . "\n";

    if ($servicestatus eq "Running")
    {
    #good
    print "Message: " . $service . " is " . $servicestatus . "\n";
    print "Statistic: 1\n";
    exit 0;
    }
    else
    {
    #bad - services on the HA Primary should be running
    print "Message: " . $service . " is " . $servicestatus . "\n";
    print "Statistic: 0\n";
    exit 1;
    }
    }
    else
    {
    #Services should be not running on the HA Secondary
    print "Message: " . $service . " is " . $servicestatus . "\n";
    print "Statistic: 1\n";
    exit 0;
    }

    }



    #if we did not check for the status of a specific service, just report the status of the HA
    if ($HAstatus eq "Online")
    {
    #good
    print "Message: " . $string . "\n";
    print "Statistic: 1\n";
    exit 0;
    }
    else
    {
    #bad
    print "Message: " . $string . "\n";
    print "Statistic: 0";
    exit 1;
    }