Monitor entry point for agent having basic (level-1) and detailed (level-2) monitoring

When the agent calls its entry point, the entry point expects the name of the resource as the first argument, followed by the values of the remaining ArgList attributes.

Following implementation is for the agents that are registered as V51. Implementation is same even if the agent is an IMF-aware agent.

Note:

IMF is supported for agent version V51 and later.

# Implementation of Monitor entry point, which does Level-1  
# and Level-2 monitoring.
# 

eval 'exec /opt/VRTSperl/bin/perl -I ${CLUSTER_HOME}/lib
 -S $0 ${1+"$@"}' 
        if 0;

use strict;
use warnings;

my ($Resource, $state) = ("", "ONLINE");

$Resource = $ARGV[0]; shift;

use ag_i18n_inc;
VCSAG_SET_ENVS ($Resource);

# Fetch the value of level-1 and level-2
my ($ret, $level_one, $level_two)=(0,0,0);
($ret, $level_one, $level_two) = VCSAG_GET_MONITOR_LEVEL();

# Check if level-1 monitoring need to be performed
if ( $level_one == 1 ) {
                # Do level-1 monitoring i.e. basic monitoring
                # This would return state as ONLINE or OFFLINE or 
                  unknown
                state = do_level_one_monitoring();
}

# Check if level-2 monitoring need to be performed
if ( ($state eq "ONLINE") && ($level_two != 0) ) {
                # Do level-2 monitoring i.e. detailed monitoring
                state = do_level_two_monitoring();
}

if ( $state -eq "ONLINE" ) {
                exit 110;
}

if ( $state -eq "OFFLINE" ) {
                exit 100;
}

# unknown state
exit 99;