#!/bin/bash
# 
# File:   asrexachk2.6
# Author: JasWhite
# ASR Support Team
#
VERSION="ASRExachk 2.6.1"
# Production Release
# Date 8/22/2012
# Version Release Date
# 3/27/2014
# Updates
##########################################
# Added the following Devices: Exadata X4-2, Exalytics X4-2, Exalogic X4-2 Compute nodes, Big Database Appliance X4-2
# Validation of Fromip to management Interface
# validation of SNMP version on ILOM
# Updated Solaris Exadata Validation
# Added version control and output during Script execution
# Updated the Interface Validation methods
#########################################
if [ $(/usr/bin/id -u) -ne 0 ]; then
    echo Must be executed as the root user
    exit 1
fi
#########################################
#File Locations
#Exadata
    #/opt/oracle.SupportTools/
#Exalogic
    #/opt/exalogic.tools/
#Exalytics
    #/opt/exalytics/
#BDA
    #/opt/oracle.SupportTools
#VARS
#########################################
#Log File Location
LOG=/var/log/asrexachk.log
#Log Roll Variable
#clear log file if greater than 50K
if [ -e $LOG ]; then
    echo ""
else
    echo "`date` File Start" > $LOG
fi
file_size_kb=`du -k "$LOG" | cut -f1`
if [ $file_size_kb -gt "500000" ]; then
    rm -f $LOG
    echo "Log File Rolled 'date;" > $LOG
fi
#########################################
#Global Case
if [ -z $1 ]; then
    #used to add the function of checking configuration with test events
    TESTFUNCTION="TRUE"
elif [ -n $1 ]; then
    case $1 in
        -f|-F)
            TESTFUNCTION="FALSE"
            echo `date` "Running asrexachk via -f Option" >> $LOG
        ;;
        *)
            echo "Bad argument!"
            echo "Usage: $1 is not permitted"
            echo "-f is used only for configuration and hardware checks"
            echo "with no SNMP Trap testing, Running as a normal asrexachk"
            TESTFUNCTION="TRUE"
        ;;
    esac
fi

#########################################
#OS Validation Steps to determine OS Type for Processing of Exe locations differences
#OS Specific VARS
#Check for "Solaris 11" or "Solaris 11 Express" and then if "Oracle Enterprise Linux"
uname -a | grep -i "SunOS" > /dev/null 2>&1
if [ $? -eq 0 ] ; then
    #Check to see if Solaris 11 and exit script with error
    uname -r | grep "5.11" > /dev/null 2>&1
    if [ $? -eq 0 ]; then
        #"Solaris 11" or "Solaris 11 Express" executable location
        IPMILOC="/opt/ipmitool/bin"
        OSTYPE="SOLARIS"
    else
        echo "This is not a supported Solaris Version, Please contact Oracle Support"
    fi
else
    #"Oracle Enterprise Linux" executable locations
    uname -a | grep -i "Linux" > /dev/null 2>&1
    if [ $? -eq 0 ] ; then
        IPMILOC="/usr/bin"
        OSTYPE="LINUX"
    else
        #Error out if on a non-Solaris or Non-Linux Box 
        echo "This is not a supported OS Version or is a corrupted version of OS, Please contact Oracle Support"
        exit 1
    fi
fi
#########################################
#Assign Device Type for Device methods
#########################################
#Pull Device Type
#Check BMC First
$IPMILOC/ipmitool bmc info > /dev/null 2>&1
if [ $? -eq 0 ]; then
    #Pull Device type
    IPMI_VERSION=`$IPMILOC/ipmitool -V | /usr/bin/awk '{ print $3 }'`
    if [ $IPMI_VERSION != "1.8.10.4" ]; then
        IPMI_BASE_1="`echo $IPMI_VERSION | sed -e 's/\./ /g' | /usr/bin/awk '{print $1}'`"
        IPMI_BASE_2="`echo $IPMI_VERSION | sed -e 's/\./ /g' | /usr/bin/awk '{print $2}'`"
        IPMI_BASE_3="`echo $IPMI_VERSION | sed -e 's/\./ /g' | /usr/bin/awk '{print $3}'`"
        IPMI_BASE_4="`echo $IPMI_VERSION | sed -e 's/\./ /g' | /usr/bin/awk '{print $4}'`"
        if [ $IPMI_BASE_1 -ge "1" ]; then
            if [ $IPMI_BASE_2 -ge "8" ]; then
                if [ $IPMI_BASE_3 -ge "10" ]; then
                    if [ $IPMI_BASE_4 -ge "3" ]; then
                        DEV_TYPE=`$IPMILOC/ipmitool sunoem cli "show /SP system_identifier" | grep -i "system_identifier =" | /usr/bin/awk -F= '{ print $2 }' | sed -e 's/^[ \t]*//'`
                    else
                        #pull ILOM IP to pull system Identifer if possible
                         DEV_TYPE=`asradm send -n audit | grep "<product-id>" | /usr/bin/awk -F'>' '{ print $2 }' | /usr/bin/awk -F'<' '{ print $1 }'`
                    fi
                fi
            fi
        fi
    else
        DEV_TYPE=`$IPMILOC/ipmitool sunoem cli "show /SP system_identifier" | grep -i "system_identifier =" | /usr/bin/awk -F= '{ print $2 }' | sed -e 's/^[ \t]*//'`
    fi
else
    echo "#########Warning#########"
    echo "Unable to pull device type through the BMC"
    echo "Please Contact Oracle Support for BMC Communication issues"
    echo "Once corrected, re-run ASREXACHK"
    exit 0
fi
#########################################
#Check to see if Exadata
echo "$DEV_TYPE" | egrep -i "Database Machine|Exadata Storage Expansion" > /dev/null 2>&1
if [ $? -eq 0 ]; then
    METHOD_TYPE="Exadata"
    #########################################
    #General Exadata File and Executable locations
    EXADATA_MON="/opt/oracle.cellos/compmon"
    EXA_COMMAND="$EXADATA_MON/exadata_mon_hw_asr.pl"
    EXA_CELL_IMAGE=`/opt/oracle.cellos/imageinfo | grep "Active image version:"`
    EXA_DB_IMAGE=`/opt/oracle.cellos/imageinfo | grep "Image version:"`
    EXA_ONECOMMAND="/opt/oracle.SupportTools/onecommand/onecommand.params"
    #MegaCLI Path Location
    if [ $OSTYPE = "SOLARIS" ]; then
        MEGACLI="/opt/MegaRAID/MegaCli"
    else
        if [ $OSTYPE = "LINUX" ]; then
            MEGACLI="/opt/MegaRAID/MegaCli/MegaCli64"
        fi
    fi
    #########################################
else
    #check to see if BDA
    echo "$DEV_TYPE" | grep -i "Big Data"
    if [ $? -eq 0 ]; then
        METHOD_TYPE="BDA"
        #########################################
        #General BDA File and Executable locations
        EXADATA_MON="/opt/oracle/bda/compmon"
        EXA_COMMAND="$EXADATA_MON/bda_mon_hw_asr.pl"
        EXA_DB_IMAGE=`/opt/oracle/bda/bin/imageinfo | grep "IMAGE_VERSION             :"`
        INSTALL_INFO="/opt/oracle/bda/install/state/mammoth-saved.params"
        MEGACLI="/opt/oracle/bda/bin/MegaCli64"
        #########################################
    else
        #check to see if Exalytics
        echo "$DEV_TYPE" | grep -i "Exalytics"
        if [ $? -eq 0 ]; then
            METHOD_TYPE="Exalytics"
            #########################################
            #General Exalytics File and Executable locations
            EXADATA_MON="/opt/exalytics/asr"
            EXA_COMMAND="$EXADATA_MON/bda_mon_hw_asr.pl"
            EXA_DB_IMAGE=`/usr/sbin/imageinfo | grep "Image version       :"`
            MEGACLI="/opt/MegaRAID/MegaCli/MegaCli64"
            #########################################
        else
            #check to see if Exalogic
            echo "$DEV_TYPE" | grep -i "Exalogic"
            if [ $? -eq 0 ]; then
                METHOD_TYPE="Exalogic"
                #########################################
                #General Exalogic File and Executable locations
                EXA_CELL_IMAGE=`/opt/exalogic/usr/sbin/imageinfo | grep "Image version       :"`
                MEGACLI="/opt/MegaRAID/MegaCli/MegaCli64"
                EXADATA_MON="/opt/exalogic.tools/tools"
                #########################################
            else
                    echo -e '\t' "Unable to determine Device Type, System Identifier states:"
                    echo -e '\t' `$IPMILOC/ipmitool sunoem cli "show /SP system_identifier" | grep -i "system_identifier ="`
                    echo -e '\t' "If system is returning a null value or (None)"
                    echo -e '\t' "Please open a Service Request with the Exadata Hardware Team"
                    echo -e '\t' "To help set your system Identifier."
                    echo `date` "Unable to determine Device Type" >> $LOG
                    echo `$IPMILOC/ipmitool sunoem cli "show /SP system_identifier" | grep -i "system_identifier ="` >> $LOG
                    exit 1
            fi
        fi
    fi
fi
#END Assign Device Type for Device methods
#########################################
#Status return variable Function Checks
#Standard Error Outputs
ASR_Return_1() {
    echo -e '\t' "#########Warning#########" 
    echo -e '\t' "The ASR Manager Appears to be on the same Subnet as the"
    echo -e '\t' "Client Access Network or Customer Private Network"
    echo -e '\t' "ASR is not supported with this type of configuration"
    echo -e '\t' "Please have the ASR Manager IP configuration set so that"
    echo -e '\t' "the Subnet does not overlap the Subnet of the Private Interfaces:"
    if [ $METHOD_TYPE == "Exadata" ]; then
        echo -e '\t' "Client Access/Bond bondeth*or Customer Private eth2 and or eth3 Networks."
        echo -e '\t' "The ASR Manager is only allowed on the Management interfaces, which is interface:"
        echo -e '\t' "Net0/eth0 and the ILOM port NetMGMT."
    elif [[ $METHOD_TYPE == "BDA" || "Exalytics" ]]; then
        echo -e '\t' "Client Access/Bond bondeth*or Customer Private eth2 and or eth3 Networks."
        echo -e '\t' "The ASR Manager is only allowed on the Management interfaces, which is interface:"
        echo -e '\t' "Net0/eth0 and the ILOM port NetMGMT."
    fi
}
ASR_Return_2() {
    echo ""
    echo "Management IP Interface check completed"
    echo -e '\t' "#########Warning#########"
    echo -e '\t' "ASR is not supported on this node due to the Management Subnet "
    echo -e '\t' "overlapping multiple Interfaces on the Same Subnet."
    if [ $METHOD_TYPE == "Exadata" ]; then
        echo -e '\t' "Please check the Exadata Database Machine Owner's Guide"
        echo -e '\t' "or work with the Oracle Exadata Support Team"
        echo -e '\t' "on moving the Managment Interface off of the Client Access Subnet,"
        echo -e '\t' "Customer Private Network and/or Infiniband Private Network per "
        echo -e '\t' "Chapter 3 section 1 of the Exadata Database Machine Owner's Guide"
        echo -e '\t' "under the Overview of Network Requirements"
        echo -e '\t' "The ASR Manager is only allowed on the Management interfaces, which is interface:"
        echo -e '\t' "Net0/eth0 and the ILOM port NetMGMT."
    elif [[ $METHOD_TYPE == "BDA" || "Exalytics" ]]; then
        echo -e '\t' "Client Access/Bond bondeth*or Customer Private eth2 and or eth3 Networks."
        echo -e '\t' "The ASR Manager is only allowed on the Management interfaces, which is interface:"
        echo -e '\t' "Net0/eth0 and the ILOM port NetMGMT."
    fi
}
ASR_Return_3() {
    echo ""
    echo "Management IP Interface check completed"
    echo -e '\t' "ASR is supported on this Management Interface configuration"
}
ASR_Return_4() {
    echo ""
    echo "Management IP Interface check completed"
    echo -e '\t' "#########Warning#########"
    echo -e '\t' "This is a non-standard configuration which ASR is not supported on $INTFAIL"
    echo -e '\t' "Please follow instructions provided in the error above by Node IP interfce Check" 
    echo -e '\t' "for the Non-Standard Configuration"
}
ASR_Return_5() {
    echo -e '\t' "#########Warning#########"
    echo -e '\t' "Unable to determine configuration status of the DB node."
    echo -e '\t' "Please check to make sure the ASR Manager SNMP Port is"
    echo -e '\t' "setup through the command to include the port of 162 or 1162"
    echo -e '\t' "Please reference the Oracle Exadata Administration guide for more"
    echo -e '\t' "details on DB commands for ASR"
}
ASR_Return_6() {
    echo -e '\t' "#########Warning#########"
    echo -e '\t' "IPADM is reporting interface $INTFAIL as a non-standard configuration."
    echo -e '\t' "Interface/? indicates that the address was configured"
    echo -e '\t' "on the interface outside of ipadm command set."
    echo -e '\t' "This is a non-standard configuration which ASREXACHK is unable to validate against"
    echo -e '\t' "Please work with the Oracle Exadata Support Team"
    echo -e '\t' "to resolve the network setup so the value is set to a standard configuration"
}
ASR_Return_7() {
    echo -e '\t' "#########Warning#########"
    echo -e '\t' "Unable to Validate SNMP Due to Unconfigured ASR Setup"
    echo -e '\t' "This is based on a IP Validation provided in previous Checks"
    echo -e '\t' "Please contact Oracle Exadata Support for help in resolving"
    echo -e '\t' "network configuration issue"
}
ASR_Return_8() {
    echo -e '\t' "#########Warning#########"
    echo -e '\t' "Unable to Validate SNMP Due to Unconfigured ASR Setup"
    echo -e '\t' "Please check the errors provided in the Configuration Check"
    echo -e '\t' "Please contact Oracle Support for help in resolving configuration issue"
}
ASR_Return_9() {
    echo -e '\t' "#########Warning#########"
    echo -e '\t' "The Fromip does not match what is expected on the interface of eth0."
    echo -e '\t' "Please run the SNMP setup with the the from IP set to the management"
    echo -e '\t' "interface ip for this server node"
}
ASR_Return_10() {
    echo -e '\t' "#########Warning#########"
    echo -e '\t' "The Fromip is set to a hostname value instead of an IP"
    echo -e '\t' "Please run the SNMP setup with the the fromip set to the management"
    echo -e '\t' "interface ip for this server node"
}
ASR_Return_11() {
    echo -e '\t' "#########Warning#########"
    echo -e '\t' "The Fromip is not being used. If the Image is greater than 11.2.2.4.0"
    echo -e '\t' "Please run the SNMP setup with the the from IP set to the management"
    echo -e '\t' "interface IP for this server node, else if it is on a previous version"
    echo -e '\t' "of the Exadata Image you can bypass this error message"
}
#End Status return Function checks
#########################################
#End VARS
#########################################
#Main Functions for status checks
#########################################
#Functions to pull ASR Manager IP's
#########################################
#Start Exadata ASR Manager Ips
#########################################
#ASR Manager IP pull for DB node
ASR_MAN_IP_DB() {
    #Global Var set
    DUAL_ASR_ENTRY=""
    #Check for file and if exists check count of asr trap destinations, proceed if no error
    if [ -f $EXADATA_MON/asrs.state ]; then
        grep -i 162 $EXADATA_MON/asrs.state > /dev/null 2>&1
        if [ $? -eq 0 ]; then
            ASR_IP_COUNT=`grep -i 162 $EXADATA_MON/asrs.state | wc -l`
            if [ $ASR_IP_COUNT -eq "1" ]; then
                ASR_MAN=`cat $EXADATA_MON/asrs.state | grep -i 162 | /usr/bin/awk -F: '{ print $1 }'`
                if [[ $ASR_MAN =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
                    ASR_IP="$ASR_MAN"
                else
                    ASR_IP=`/usr/bin/python -c 'import socket; print socket.gethostbyname("'$ASR_MAN'")'`
                fi
                #ASR IP Expanded for checking
                ASR_MAN_octet_1="`echo $ASR_IP | sed -e 's/\./ /g' | /usr/bin/awk '{print $1}'`"
                ASR_MAN_octet_2="`echo $ASR_IP | sed -e 's/\./ /g' | /usr/bin/awk '{print $2}'`"
                ASR_MAN_octet_3="`echo $ASR_IP | sed -e 's/\./ /g' | /usr/bin/awk '{print $3}'`"
                ASR_MAN_octet_4="`echo $ASR_IP | sed -e 's/\./ /g' | /usr/bin/awk '{print $4}'`"
            else
                ASR_SETUP_STATUS="Unconfigured"
                ASR_IP="N/A"
                DUAL_ASR_ENTRY="TRUE"
            fi
        else
            ASR_SETUP_STATUS="Unconfigured"
            ASR_IP="N/A"        
        fi
    fi
}
#ASR Manager IP pull for Cell node
ASR_MAN_IP_CELL() {
    #Count instances of Type=asr. Type ASR 1 is allowed
    CELL_TYPECOUNT=`cellcli -e "list cell attributes snmpsubscriber" | grep -o -i "type=asr" | wc -l`
    CELL_ASR_COUNT=`echo $CELL_TYPECOUNT`
    if [ $CELL_ASR_COUNT -eq "1" ]; then
        ASR_MAN=`cellcli -e list cell detail | grep -i "type=asr" | grep "host=" | /usr/bin/awk -F, '{ print $1 }' | /usr/bin/awk -F= '{ print $2 }'`
        if [[ $ASR_MAN =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
            ASR_IP="$ASR_MAN"
        else
            ASR_IP=`/usr/bin/python -c 'import socket; print socket.gethostbyname("'$ASR_MAN'")'`
        fi
    else
            if [ $CELL_ASR_COUNT -gt "1" ]; then
            ASR_SETUP_STATUS="Unconfigured"
            ASR_IP="N/A"
            DUAL_ASR_ENTRY="TRUE"
        fi
    fi
}
#End Exadata ASR Manager Ips
#########################################

#########################################
#END Functions to pull ASR Manager IP's
#########################################
# Netmask calculation Function (Solaris Only)
# Convert "/" notation to dotted decimal
netmask_calc(){
    if [ "$netmask" = "30" ]; then
        subnetmask="255.255.255.252"
    else
        if [ "$netmask" = "29" ]; then
            subnetmask="255.255.255.248"
        else
            if [ "$netmask" = "28" ]; then
                subnetmask="255.255.255.240"
            else
                if [ "$netmask" = "27" ]; then
                    subnetmask="255.255.255.224"
                else
                    if [ "$netmask" = "26" ]; then
                        subnetmask="255.255.255.192"
                    else
                        if [ "$netmask" = "25" ]; then
                            subnetmask="255.255.255.128"
                        else
                            if [ "$netmask" = "24" ]; then
                                subnetmask="255.255.255.0"
                            else
                                if [ "$netmask" = "23" ]; then
                                    subnetmask="255.255.254.0"
                                else
                                    if [ "$netmask" = "22" ]; then
                                        subnetmask="255.255.252.0"
                                    else
                                        if [ "$netmask" = "21" ]; then
                                            subnetmask="255.255.248.0"
                                        fi
                                    fi
                                fi
                            fi
                        fi
                    fi
                fi
            fi
        fi
    fi
}
# END Netmask calculation Function (Solaris Only)
#########################################
#Validate IP Configurations for Linux and Solaris and comapare to 
#Configurations as well as to the ASR Manager IP
#########################################
#Linux Configuration check
linux_ip_int_check() {
    #Reset of Generic Variables
    ASR_NET="0"
    netmask="0"
    subnetmask="0"
    
    
    #Pull ASR Manager IP if the state is configured
    if [ $ASR_SETUP_STATUS = "Configured" ]; then
        ASR_MAN_IP_DB
    fi
    TMPFILE=`mktemp -q -t ipcheck.XXXXXX`
    if [ ! -z "$TMPFILE" ]; then
        #Loop To check interfaces
        #Check of eth0 is not on same subnet as the bnd network
        for file in /etc/sysconfig/network-scripts/ifcfg-*
            do
                if [ $METHOD_TYPE != "Exalytics" ]; then
                    INTNAME=`echo $file | /usr/bin/awk -F/ '{print $5 }' | /usr/bin/awk -F- '{ print $2 }'` > /dev/null 2>&1
                    NETIP=`grep -i "NETWORK" $file | /usr/bin/awk -F= '{print $2 }'` > /dev/null 2>&1
                    BCASTIP=`grep -i "BROADCAST" $file | /usr/bin/awk -F= '{print $2 }'` > /dev/null 2>&1
                    echo $INTNAME "=" $NETIP "=" $BCASTIP >> $TMPFILE
                else
                    INTNAME=`echo $file | /usr/bin/awk -F/ '{print $5 }' | /usr/bin/awk -F- '{ print $2 }'` > /dev/null 2>&1
                    NETIP=`grep -i "IPADDR" $file | /usr/bin/awk -F= '{print $2 }'` > /dev/null 2>&1
                    BCAST=`ifconfig $INTNAME | grep -i Bcast | /usr/bin/awk '{ print $3 }'` > /dev/null 2>&1
                    BCASTIP=`echo $BCAST | /usr/bin/awk -F: '{ print $2 }'` > /dev/null 2>&1
                    echo $INTNAME "=" $NETIP "=" $BCASTIP >> $TMPFILE
                fi
            #Validate ASR Manager IP to the Interface in the loop
            if [ $ASR_SETUP_STATUS = "Configured" ]; then
                # Pull subnet base and Subnet Broad Cast to validate ASR IP to interface IP
                #ASR Manager Only allowed on eth0
                #Subnet IP Expanded for checking
                SUBNET_BASE_octet_1="`echo $NETIP | sed -e 's/\./ /g' | /usr/bin/awk '{print $1}'`"
                SUBNET_BASE_octet_2="`echo $NETIP | sed -e 's/\./ /g' | /usr/bin/awk '{print $2}'`"
                SUBNET_BASE_octet_3="`echo $NETIP | sed -e 's/\./ /g' | /usr/bin/awk '{print $3}'`"
                SUBNET_BASE_octet_4="`echo $NETIP | sed -e 's/\./ /g' | /usr/bin/awk '{print $4}'`"

                #Subnet BCast Expanded for checking
                SUBNET_BROADCAST_octet_1="`echo $BCASTIP | sed -e 's/\./ /g' | /usr/bin/awk '{print $1}'`"
                SUBNET_BROADCAST_octet_2="`echo $BCASTIP | sed -e 's/\./ /g' | /usr/bin/awk '{print $2}'`"
                SUBNET_BROADCAST_octet_3="`echo $BCASTIP | sed -e 's/\./ /g' | /usr/bin/awk '{print $3}'`"
                SUBNET_BROADCAST_octet_4="`echo $BCASTIP | sed -e 's/\./ /g' | /usr/bin/awk '{print $4}'`"

                #Checking ASR Manager IP Interface Against the rest of the Interfaces
                #ASR Manager is required not to be on the Same Subnet as the Client access network
                nonmgmt_int="$INTNAME"
                if [ "$nonmgmt_int" != "eth0" ]; then          
                    # checking to see if value is setup prior to validating interface
                    if [ ! -z "$NETIP" ]; then
                        echo -e '\t' "Validating ASR Manager IP to Interface $INTNAME"
                        if [[ $ASR_MAN_octet_1 -eq $SUBNET_BASE_octet_1 && $SUBNET_BROADCAST_octet_1 ]]; then
                            if [[ $ASR_MAN_octet_2 -eq $SUBNET_BASE_octet_2 && $SUBNET_BROADCAST_octet_2 ]]; then
                                if [ $ASR_MAN_octet_3 -ge $SUBNET_BASE_octet_3 ] && [ $ASR_MAN_octet_3 -le $SUBNET_BROADCAST_octet_3 ]; then
                                    if [ $ASR_MAN_octet_4 -ge $SUBNET_BASE_octet_4 ] && [ $ASR_MAN_octet_4 -le $SUBNET_BROADCAST_octet_4 ]; then
                                        ASR_NET="1"
                                        result=$(ASR_Return_1)
                                        echo "$result"
                                        echo ""
                                        echo "interface failure $INTNAME" >> $TMPFILE
                                    fi
                                fi
                            fi
                        fi
                    fi
                else
                    ASR_NET="0"
                fi
            fi
        done
        #Validating the Subnet Count to eth0 and other activated intefaces
        #Pull eth0 Subnet IP into Variable
        ETH0=`grep -i "eth0" $TMPFILE | grep -v b | /usr/bin/awk -F= '{ print $2 }'`
        #Count Subnets that equal eth0 Subnet
        NETCOUNT=`grep -o "$ETH0" $TMPFILE | wc -l`
        #If subnet count is greater than one return value return code
        if [ $NETCOUNT -ne "1" ]; then
            ASR_NET="2"
        fi
        #Check Return Codes and report outputs
        if [ $ASR_NET -eq "1" ]; then
            INTFAIL=`grep "interface failure" $TMPFILE | /usr/bin/awk '{ print $3 }'`
            result=$(ASR_Return_4)
            echo "$result"
        else
            if [ $ASR_NET -eq "2" ]; then
                result=$(ASR_Return_2)
                echo "$result"
            else
                if [  $ASR_NET -eq "0" ]; then
                    result=$(ASR_Return_3)
                    echo "$result"
                fi
            fi
        fi
        #remove temp file
        rm -f $TMPFILE
    fi
}
#END Linux Configuration check
#########################################
#Solaris Configuration Check
solaris_ip_int_check() {
    #Reset of Generic Variables
    ASR_NET="0"
    netmask="0"
    subnetmask="0"
    
    TMPFILE=`mktemp -q -t ipcheck.XXXXXX`
    if [ ! -z "$TMPFILE" ]; then
        #Pull ASR Manager IP if the state is configured
        if [ $ASR_SETUP_STATUS = "Configured" ]; then
            ASR_MAN_IP_DB
        fi
        #Pull Solaris eth0/net0 Interface name
        ipadm show-if | grep -i "net" > /dev/null 2>&1
        if [ $? -eq 0 ]; then
            NETINT=`ipadm show-addr | grep -i "net" | grep "v4" | /usr/bin/awk '{print $1}'`
        else
            ipadm show-if | grep -i "eth" > /dev/null 2>&1
            if [ $? -eq 0 ]; then
                NETINT=`ipadm show-addr | grep -i "eth" | grep -v "bond" | grep -v "::" | /usr/bin/awk '{print $1}'`
            else
                result=$(ASR_Return_5)
                echo "$result"
            fi
        fi
        #Loop To check interfaces
        #Check of eth0 is not on same subnet as the Customer private network
        echo ""
        echo "Validating the Private Network Interfaces"
        for i in $NETINT
            do
            #check interface for status not configured by ipadm
            ipadm show-addr $i | grep -i "/?" > /dev/null 2>&1
            if [ $? -ne 0 ]; then
                int=`ipadm show-addr $i -o addr | grep -v "ADDR"`
                IPADDR=`echo $int | /usr/bin/awk -F/ '{print $1}'`
                netmask=`echo $int | /usr/bin/awk -F/ '{print $2}'`
                if [ -n "$IPADDR" ]; then
                    ## Convert "/" notation to dotted decimal#
                    netmask_calc
                    ## Get the last octet of the subnet mask#
                    netmask_octet_4="`echo $subnetmask | sed -e 's/\./ /g' | /usr/bin/awk '{print $4}'`"
                    netmask_octet_3="`echo $subnetmask | sed -e 's/\./ /g' | /usr/bin/awk '{print $3}'`"
                    ## Get first three octets of the IP address#
                    IPADDR_octet_1="`echo $IPADDR | sed -e 's/\./ /g' | /usr/bin/awk '{print $1}'`"
                    IPADDR_octet_2="`echo $IPADDR | sed -e 's/\./ /g' | /usr/bin/awk '{print $2}'`"
                    IPADDR_octet_3="`echo $IPADDR | sed -e 's/\./ /g' | /usr/bin/awk '{print $3}'`"
                    IPADDR_octet_4="`echo $IPADDR | sed -e 's/\./ /g' | /usr/bin/awk '{print $4}'`"
                ## Get the size of the subnet#
                if [[ "$netmask" == "30" || "29" || "28" || "27" || "26" || "25" || "24" ]]; then
                    subnet_size=$[256-$netmask_octet_4]
                    ## Get the last octet of the network address
                    if [ "$netmask_octet_4" = "0" ]; then
                        subnet_base="0"
                    else
                        subnet_base1=$[$IPADDR_octet_4/$subnet_size]
                        subnet_base=$[$subnet_base1*$subnet_size]
                    fi

                    SUBNET_BASE=$IPADDR_octet_1.$IPADDR_octet_2.$IPADDR_octet_3.$subnet_base
                    SUBNET_BROADCAST=$IPADDR_octet_1.$IPADDR_octet_2.$IPADDR_octet_3.$[$subnet_base-1+$subnet_size]

                else

                    if [[ "$netmask" == "23" || "22" || "21" ]]; then
                        subnet_size=$[256-$netmask_octet_3]


                        ## Get the last octet of the network address#
                        if [ "$netmask_octet_3" = "0" ]; then
                            subnet_base="0"
                        else
                            subnet_base1=$[$IPADDR_octet_3/$subnet_size]
                            subnet_base=$[$subnet_base1*$subnet_size]
                        fi
                        SUBNET_BASE=$IPADDR_octet_1.$IPADDR_octet_2.$subnet_base.$IPADDR_octet_4
                        SUBNET_BROADCAST=$IPADDR_octet_1.$IPADDR_octet_2.$[$subnet_base-1+$subnet_size].$IPADDR_octet_4
                    fi
                fi
                #Write the outputs to file
                echo $i $IPADDR $SUBNET_BASE >> $TMPFILE
                #Validate ASR Manager IP to the Interface in the loop
                if [ $ASR_SETUP_STATUS = "Configured" ]; then
                    # Pull subnet base and Subnet Broad Cast to validate ASR IP to interface IP
                    #ASR Manager Only allowed on eth0
                    #Subnet IP Expanded for checking
                    SUBNET_BASE_octet_1="`echo $SUBNET_BASE | sed -e 's/\./ /g' | /usr/bin/awk '{print $1}'`"
                    SUBNET_BASE_octet_2="`echo $SUBNET_BASE | sed -e 's/\./ /g' | /usr/bin/awk '{print $2}'`"
                    SUBNET_BASE_octet_3="`echo $SUBNET_BASE | sed -e 's/\./ /g' | /usr/bin/awk '{print $3}'`"
                    SUBNET_BASE_octet_4="`echo $SUBNET_BASE | sed -e 's/\./ /g' | /usr/bin/awk '{print $4}'`"
                    #Subnet BCast Expanded for checking
                    SUBNET_BROADCAST_octet_1="`echo $SUBNET_BROADCAST | sed -e 's/\./ /g' | /usr/bin/awk '{print $1}'`"
                    SUBNET_BROADCAST_octet_2="`echo $SUBNET_BROADCAST | sed -e 's/\./ /g' | /usr/bin/awk '{print $2}'`"
                    SUBNET_BROADCAST_octet_3="`echo $SUBNET_BROADCAST | sed -e 's/\./ /g' | /usr/bin/awk '{print $3}'`"
                    SUBNET_BROADCAST_octet_4="`echo $SUBNET_BROADCAST | sed -e 's/\./ /g' | /usr/bin/awk '{print $4}'`"
                    #Checking ASR Manager IP Interface Against the rest of the Interfaces
                    #ASR Manager is required not to be on the Same Subnet as the Client access network
                    nonmgmt_int="`echo $i | /usr/bin/awk -F/ '{ print $1}'`"
                    if [ "$nonmgmt_int" != "eth0" ]; then
                        # checking to see if value is setup prior to validating interface
                        echo -e '\t' "Validating ASR Manager IP to Interface $i"
                        if [[ $ASR_MAN_octet_1 -eq $SUBNET_BASE_octet_1 && $SUBNET_BROADCAST_octet_1 ]]; then
                            if [[ $ASR_MAN_octet_2 -eq $SUBNET_BASE_octet_2 && $SUBNET_BROADCAST_octet_2 ]]; then
                                if [ $ASR_MAN_octet_3 -ge $SUBNET_BASE_octet_3 ] && [ $ASR_MAN_octet_3 -le $SUBNET_BROADCAST_octet_3 ]; then
                                    if [ $ASR_MAN_octet_4 -ge $SUBNET_BASE_octet_4 ] && [ $ASR_MAN_octet_4 -le $SUBNET_BROADCAST_octet_4 ]; then
                                        ASR_NET="1"
                                        result=$(ASR_Return_1)
                                        echo "$result"
                                        echo ""
                                        echo "interface failure $i" >> $TMPFILE
                                    fi
                                fi
                            fi
                        fi
                    else
                        ASR_NET="0"
                    fi
                fi
            fi
        else
            ASR_NET="3"
            result=$(ASR_Return_6)
            echo "$result"
            echo ""
            echo "temp interface $i" >> $TMPFILE
        fi
        done
        #Loop To check interfaces
        #Check of eth0 is not on same subnet as the Bonded network
        echo ""
        echo "Validating the Bonded Network Interfaces"
        #Reset of Generic Variables
        netmask="0"
        subnetmask="0"
        #Pull Solaris Bonded Interface names
        BNDINT=`ipadm show-addr | grep -i "bond" | grep -v "::" | /usr/bin/awk '{print $1}'`
        #Loop To check interfaces
        #Check of eth0 is not on same subnet as the BOND network
        for j in $BNDINT
            do
            #check interface for status not configured by ipadm
            ipadm show-addr $j | grep -i "/?" > /dev/null 2>&1
            if [ $? -ne 0 ]; then
                    bndint=`ipadm show-addr $j -o addr | grep -v -i "ADDR"`
                    BNDIPADDR=`echo $bndint | /usr/bin/awk -F/ '{print $1}'`
                    netmask=`echo $bndint | /usr/bin/awk -F/ '{print $2}'`
                    BNDnetmask=$netmask
                if [ -n "$IPADDR" ]; then
                    ## Convert "/" notation to dotted decimal#
                    netmask_calc
                    ## Get the last octet of the subnet mask#
                    BNDnetmask_octet_4="`echo $subnetmask | sed -e 's/\./ /g' | /usr/bin/awk '{print $4}'`"
                    BNDnetmask_octet_3="`echo $subnetmask | sed -e 's/\./ /g' | /usr/bin/awk '{print $3}'`"
                    ## Get first three octets of the IP address#
                    BNDIPADDR_octet_1="`echo $BNDIPADDR | sed -e 's/\./ /g' | /usr/bin/awk '{print $1}'`"
                    BNDIPADDR_octet_2="`echo $BNDIPADDR | sed -e 's/\./ /g' | /usr/bin/awk '{print $2}'`"
                    BNDIPADDR_octet_3="`echo $BNDIPADDR | sed -e 's/\./ /g' | /usr/bin/awk '{print $3}'`"
                    BNDIPADDR_octet_4="`echo $BNDIPADDR | sed -e 's/\./ /g' | /usr/bin/awk '{print $4}'`"
                ## Get the size of the subnet#
                if [[ "$BNDnetmask" = "30" || "29" || "28" || "27" || "26" || "25" || "24" ]]; then
                    BNDsubnet_size=$[256-$BNDnetmask_octet_4]
                    ## Get the last octet of the network address
                    if [ "$BNDnetmask_octet_4" == "0" ]; then
                        BNDsubnet_base="0"
                    else
                        BNDsubnet_base1=$[$BNDIPADDR_octet_4/$BNDsubnet_size]
                        BNDsubnet_base=$[$BNDsubnet_base1*$BNDsubnet_size]
                    fi
                    BNDSUBNET_BASE=$BNDIPADDR_octet_1.$BNDIPADDR_octet_2.$BNDIPADDR_octet_3.$BNDsubnet_base
                    BNDSUBNET_BROADCAST=$BNDIPADDR_octet_1.$BNDIPADDR_octet_2.$BNDIPADDR_octet_3.$[$BNDsubnet_base-1+$BNDsubnet_size]
                else
                    if [[ "$BNDnetmask" = "23" || "22" || "21" ]]; then
                        BNDsubnet_size=$[256-$BNDnetmask_octet_3]
                        ## Get the last octet of the network address#
                        if [ "$BNDnetmask_octet_3" == "0" ]; then
                            BNDsubnet_base="0"
                        else
                            BNDsubnet_base1=$[$BNDIPADDR_octet_3/$BNDsubnet_size]
                            BNDsubnet_base=$[$BNDsubnet_base1*$BNDsubnet_size]
                        fi

                        BNDSUBNET_BASE=$BNDIPADDR_octet_1.$BNDIPADDR_octet_2.$BNDsubnet_base.$BNDIPADDR_octet_4
                        BNDSUBNET_BROADCAST=$BNDIPADDR_octet_1.$BNDIPADDR_octet_2.$BNDIPADDR_octet_3.$[$BNDsubnet_base-1+$BNDsubnet_size]
                    fi
                fi
                #Write the outputs to file
                echo $j $BNDIPADDR $BNDSUBNET_BASE >> $TMPFILE
                #Validate ASR Manager IP to the Interface in the loop
                if [ $ASR_SETUP_STATUS = "Configured" ]; then
                    # Pull subnet base and Subnet Broad Cast to validate ASR IP to interface IP
                    #ASR Manager Only allowed on eth0
                    #Subnet IP Exapanded for checking
                    BNDSUBNET_BASE_octet_1="`echo $BNDSUBNET_BASE | sed -e 's/\./ /g' | /usr/bin/awk '{print $1}'`"
                    BNDSUBNET_BASE_octet_2="`echo $BNDSUBNET_BASE | sed -e 's/\./ /g' | /usr/bin/awk '{print $2}'`"
                    BNDSUBNET_BASE_octet_3="`echo $BNDSUBNET_BASE | sed -e 's/\./ /g' | /usr/bin/awk '{print $3}'`"
                    BNDSUBNET_BASE_octet_4="`echo $BNDSUBNET_BASE | sed -e 's/\./ /g' | /usr/bin/awk '{print $4}'`"
                    #Subnet BCast Expanded for checking
                    BNDSUBNET_BROADCAST_octet_1="`echo $BNDSUBNET_BROADCAST | sed -e 's/\./ /g' | /usr/bin/awk '{print $1}'`"
                    BNDSUBNET_BROADCAST_octet_2="`echo $BNDSUBNET_BROADCAST | sed -e 's/\./ /g' | /usr/bin/awk '{print $2}'`"
                    BNDSUBNET_BROADCAST_octet_3="`echo $BNDSUBNET_BROADCAST | sed -e 's/\./ /g' | /usr/bin/awk '{print $3}'`"
                    BNDSUBNET_BROADCAST_octet_4="`echo $BNDSUBNET_BROADCAST | sed -e 's/\./ /g' | /usr/bin/awk '{print $4}'`"
                    #Checking ASR Manager IP Interface
                    nonmgmt_int="`echo $j | /usr/bin/awk -F/ '{ print $1}'`"
                    if [ "$nonmgmt_int" != "eth0" ]; then
                        # checking to see if value is setup prior to validating interface
                        echo -e '\t' "Validating ASR Manager IP to Interface $j"
                        if [[ $ASR_MAN_octet_1 -eq $BNDSUBNET_BASE_octet_1 && $BNDSUBNET_BROADCAST_octet_1 ]]; then
                            if [[ $ASR_MAN_octet_2 -eq $BNDSUBNET_BASE_octet_2 && $BNDSUBNET_BROADCAST_octet_2 ]]; then
                                if [ $ASR_MAN_octet_3 -ge $BNDSUBNET_BASE_octet_3 ] && [ $ASR_MAN_octet_3 -le $BNDSUBNET_BROADCAST_octet_3 ]; then
                                    if [ $ASR_MAN_octet_4 -ge $BNDSUBNET_BASE_octet_4 ] && [ $ASR_MAN_octet_4 -le $BNDSUBNET_BROADCAST_octet_4 ]; then
                                        ASR_NET="1"
                                        result=$(ASR_Return_1)
                                        echo "$result"
                                        echo ""
                                        echo "interface failure $j" >> $TMPFILE
                                    fi
                                fi
                            fi
                        fi
                    else
                        ASR_NET="0"
                    fi
                fi
            fi
        else
            ASR_NET="3"
            result=$(ASR_Return_6)
            echo "$result"
            echo ""
            echo "temp interface $j" >> $TMPFILE
        fi
        done
        #Validating the Subnet Count to eth0 and other activated intefaces
        #Pull eth0 Subnet IP into Variable for net0 device name
        grep -i "net0" $TMPFILE > /dev/null 2>&1
        if [ $? -eq 0 ]; then
            SOL11NETCOUNT=`grep -i "net0" $TMPFILE | grep -v bond | /usr/bin/awk '{print $3 }' | wc -l`
            if [ $SOL11NETCOUNT -ne "1" ]; then
                ASR_NET="2"
            fi
        else
            #Pull eth0 Subnet IP into Variable for net0 device name
            SOL11NETCOUNT=`grep -i "eth0/" $TMPFILE | grep -v bond |  /usr/bin/awk '{print $3 }' | wc -l`
            if [ $SOL11NETCOUNT -ne "1" ]; then
                ASR_NET="2"
            fi
        fi
        #Check Return Codes and report outputs
            if [ $ASR_NET -eq "1" ]; then
                INTFAIL=`grep "interface failure" $TMPFILE | /usr/bin/awk '{ print $3 }'`
                result=$(ASR_Return_4)
                echo "$result"
            else
                if [ $ASR_NET -eq "2" ]; then
                    result=$(ASR_Return_2)
                    echo "$result"
                else
                    if [  $ASR_NET -eq "0" ]; then
                        result=$(ASR_Return_3)
                        echo "$result"
                    else
                        if [ $ASR_NET -eq "3" ]; then
                            INTFAIL=`grep "temp interface" $TMPFILE | /usr/bin/awk '{ print $3 }'`
                            result=$(ASR_Return_4)
                            echo "$result"
                        fi
                    fi
                fi
            fi
        #remove temp file
        rm -f $TMPFILE
    fi
}
#End Solaris Configuration Check
#########################################
#END Validate IP Configurations for Linux and Solaris and compare to ASR Manager
#########################################
#Begin Solaris Script Validations
#########################################
#Validate Perl Location and update if needed
perl_location_validation() {
#Perl Solaris Value Location Variable
LOC_PERL="/usr/perl5/5.12/bin/perl"
#Pull Current Location and store
Which_Perl=`which perl`
#check to see if the perl command is symbolically linked
if [ -L $Which_Perl ]; then
    #Pull Link location
    CUR_VER_PERL=`ls -l $Which_Perl | /usr/bin/awk -F'>' '{ print $2 }'`
    #Validate Location to Variables
    if [ $CUR_VER_PERL == $LOC_PERL ]; then
        echo "$CUR_VER_PERL meets current standards"
    else
        #if pulls incorrect link add the correct link to the system
        #remove existing link
        echo "Removing Old Perl Symbolic Link"
        rm $Which_Perl
        #create the correct symbolic link
        echo "Adding in correct Perl Symbolic Link Location"
        ln -s $LOC_PERL $Which_Perl
    fi
fi
}
#End Solaris Script Validations
#########################################
#Linux Validations
#########################################
#Modperl Validation
#Exadata Image 11.2.3.1 upgrade check

#End Modperl Validation
#########################################
#End Linux Script Validations
#########################################
#Start BMC Validation
bmc_validation() {
$IPMILOC/ipmitool bmc info > /dev/null 2>&1
        if [ $? -ne 0 ]; then
            echo -e '\t' "#########Warning#########"
            echo -e '\t' "Please Contact Oracle Support for BMC Communication issues"
            echo -e '\t' "BMC Communication is needed for ASR to setup Trap destinations as well as run as expected"
            echo -e '\t' "Once corrected, re-run ASREXACHK"
            BMC_STATUS="1"
        else
            echo -e '\t' "BMC Communication is Currently running"
            BMC_STATUS="0"
        fi
}
#End BMC Validation
#########################################
#Start asrs.state file validation
asrs_validate() {
    #Check for asrs.state file
    if [ -f $EXADATA_MON/asrs.state ]; then
        line_count=`wc -l $EXADATA_MON/asrs.state | /usr/bin/awk '{ print $1 }'`
        if [ $line_count -gt "1" ]; then
            sed '/^$/d' asrs.state > asrs.bck
            mv -f asrs.bck asrs.state
        fi
    fi
}
#End asrs.state file validation
#########################################
#Common Component Functions Status checks
#########################################
#Start Cell Status Check
cell_validate_checks() {
    #Check for type=asr
    echo "Checking for Type of ASR"
    if [ "$DUAL_ASR_ENTRY" == "TRUE" ]; then
        echo -e '\t' "#########Warning#########"
        echo -e '\t' "Type of 'ASR' is for use for Auto Service Request only"
        echo -e '\t' "If using Grid Control or other monitoring systems, please leave the 'type' off of the command"
        echo -e '\t' "Please follow My Oracle Support Knowledge Article 1451026.1"
        ASR_TEST_VALUE="False"
    else
        ASR_TEST_VALUE="True"
    fi
    #BMC State Check
    echo ""
    echo "Checking BMC Status"
    bmc_validation
    #Check for prefaulted devices
    echo ""
    echo "Checking for Pre-Existing Errors"
    #Disk Fault check
    echo ""
    echo "Checking for HDD Faults"
    disk_fault_Status
    #Flash Fault Check
    echo ""
    echo "Checking for Flashdrive Failures"
    flash_fault_Status
    #FMA ILOM Check
    echo ""
    echo "Checking for FMA Faults"
    if [ $BMC_STATUS -eq 0 ]; then
        ilom_fault_FMA_Status
    else
        echo -e '\t' "#########Warning#########"
        echo -e '\t' "Unable to Check for FMA Faults due to BMC Driver Issue"
    fi
    #ILOM Hardware Faults
    echo ""
    echo "Checking for ILOM Hardware Faults"
    if [ $BMC_STATUS -eq 0 ]; then
        ilom_fault_Status
    else
        echo -e '\t' "#########Warning#########"
        echo -e '\t' "Unable to Check for ILOM Hardware Faults due to BMC Driver Issue"
    fi
    if [ $TESTFUNCTION == "TRUE" ]; then
        echo ""
        echo "Validating ASR Configuration with Validate SNMP"
        if [ $ASR_SETUP_STATUS == "Configured" ]; then
            #Send test event from Cell Node
            #Send test event from OS
            echo ""
            echo "Cell OS Validation"
            cellcli -e "alter cell validate snmp type=asr" > /dev/null 2>&1
            if [ $? -eq 0 ]; then
                ETH0_IP=`grep -i "IPADDR" /etc/sysconfig/network-scripts/ifcfg-eth0 | /usr/bin/awk -F= '{ print $2 }'`
                echo -e '\t' "OS Test event sent to $ASR_IP from $ETH0_IP"
                cell_os_snmp_val
                ASR_TEST_VALUE_OS="True"
            else
                ASR_TEST_VALUE_OS="False"
            fi
            #Send test event from ILOM
            echo ""
            echo "Cell ILOM Validation"
            if [ $BMC_STATUS -eq 0 ]; then
                if [ $CELL_ASR_COUNT -eq "1" ]; then
                    ilom_send_test
                else
                    echo -e '\t' "#########Warning#########"
                    echo -e '\t' "Unable to Validate SNMP Due to Unconfigured ASR Setup"
                    echo -e '\t' "Please check the errors provided in the Configuration Check"
                    ASR_TEST_VALUE="False"
                fi
            else
                echo -e '\t' "#########Warning#########"
                echo -e '\t' "Unable to validate the ILOM SNMP Notification due to BMC Driver issues"
                echo -e '\t' "Please contact Oracle Exadata Support Team for assistance in correcting the BMC Driver"
                ASR_TEST_VALUE="False"
            fi
        else
            echo -e '\t' "#########Warning#########"
            echo -e '\t' "Unable to Validate SNMP Due to Unconfigured ASR Setup"
            echo -e '\t' "Please check the errors provided in the Configuration Check"
            echo -e '\t' "Please contact ASR Support for help in resolving configuration issue"
            ASR_TEST_VALUE="False"
        fi
    fi
}
#End Cell Status Check
#########################################
#Onecommand setup check (Exadata)
#Start onecommand setup
ex_oncmd(){
    if [ -f $EXA_ONECOMMAND ]; then 
        ASR_ENB=`grep -i "ASRENABLED" $EXA_ONECOMMAND | /usr/bin/awk -F= '{ print $2 }'`
        if [ "$ASR_ENB" == "1" ]; then
            echo -e '\t' "Exadata was setup for ASR by OnceCommand"
        fi
    fi
}
#End onecommand setup
#########################################
#Fromip validation to be eth0
#Start Fromip validation
fromip_validation() {
    $EXA_COMMAND -get_snmp_subscribers -type asr | grep fromip > /dev/null 2>&1
    if [ $? -eq 0 ]; then
        fromip=`cat $EXADATA_MON/asrs.state | awk '{ print $7 }'`
        #Check fromip equals IP
        if [[ $fromip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
            #Pull Linux MGMT Interface
            if [ $OSTYPE = "LINUX" ]; then
                ifconfig eth0 | grep $fromip > /dev/null 2>&1
                if  [ $? -eq 0 ]; then
                    echo  -e '\t' "Fromip matches the Management Interface"
                else
                    result=$(ASR_Return_9)
                    echo "$result"
                    ASR_SETUP_STATUS="Unconfigured"
                fi
            fi
            #Pull Solaris MGMT
            if [ $OSTYPE = "SOLARIS" ]; then
                #Pull Solaris eth0/net0 Interface IP
                ipadm show-if | grep -i "net" > /dev/null 2>&1
                if [ $? -eq 0 ]; then
                    MGMTINT=`ipadm show-addr | grep -i "net0" | grep "v4" | /usr/bin/awk '{print $1}'`
                else
                    ipadm show-if | grep -i "eth0" > /dev/null 2>&1
                    if [ $? -eq 0 ]; then
                        MGMTINT=`ipadm show-addr | grep -i "eth0" | grep -v "bond" | grep -v "::" | /usr/bin/awk '{print $1}'`
                    else
                        result=$(ASR_Return_5)
                        echo "$result"
                    fi
                fi
                #Check MGMT to from IP
                if  [ $MGMTINT -eq $fromip ]; then
                    echo  -e '\t' "Fromip matches the Management Interface"
                else
                    result=$(ASR_Return_9)
                    echo "$result"
                    ASR_SETUP_STATUS="Unconfigured"
                fi
            fi
        else
            #Hostname value for from IP
            result=$(ASR_Return_10)
            echo "$result"
            ASR_SETUP_STATUS="Unconfigured"
        fi
    else
        #FROM IP not used
        result=$(ASR_Return_11)
        echo "$result"
        ASR_SETUP_STATUS="Unconfigured"
    fi
}
#End fromip validation
#########################################
#End Common Component Functions Status checks
#########################################
#Test Fault Injectors to send Test Event Emails and validate Path to ASR Manager
#########################################
# ILOM Test Event Function
ilom_send_test() {
    #Pull ILOM IP from BMC
    ILOM_IP=`$IPMILOC/ipmitool lan print | grep -i "IP Address              :" | /usr/bin/awk -F: '{print $2 }' | sed -e 's/^[ \t]*//'`
    #Pull ASR Manager IP to validate for test event
    #Pull Node Type
    if [ -f $EXA_COMMAND ]; then
        ASR_MAN_IP_DB
    else
        if [ -f /opt/oracle.cellos/ORACLE_CELL_NODE ]; then
            ASR_MAN_IP_CELL
        fi
    fi
    #Check which rules location has the ASR Manager IP
        for i in {1..15}
            do
                RULES=`$IPMILOC/ipmitool sunoem cli "show /SP/alertmgmt/rules/$i destination"`
                echo $RULES | grep "$ASR_IP" > /dev/null 2>&1
            if [ $? -eq 0 ]; then
                RULE_VER=`echo $i`
            fi
        done
    #Create Test Event
    if [ -n "$RULE_VER" ]; then
    SNMP_RULES=`$IPMILOC/ipmitool sunoem cli "show /SP/alertmgmt/rules/$RULE_VER snmp_version"`
        echo $SNMP_RULES | grep "1" > /dev/null 2>&1
        if [ $? -ne 0 ]; then
            echo -e '\t' "#########Warning#########"
            echo -e '\t' "The SNMP Version is set to an unsupported type."
            echo -e '\t' "Please rerun the ASR setup methods to have the snmp"
            echo -e '\t' "version to the correct method."
        fi
    RULE_TEST=`$IPMILOC/ipmitool sunoem cli "set /SP/alertmgmt/rules/$RULE_VER testrule=true"`
        echo $RULE_TEST | grep "To send a test alert" > /dev/null 2>&1
        if [ $? -eq 0 ]; then
            echo -e '\t' "#########Warning#########"
            echo -e '\t' "Unable to send Test Event due to ILOM Configuration issue"
            echo -e '\t' "Please check the ILOM Configuration to make sure the values are set correctly per ASR Exadata Scripts"
            ASR_TEST_VALUE_ILOM="False"
        else
            echo -e '\t' "ILOM Test event sent to $ASR_IP from $ILOM_IP"
            ASR_TEST_VALUE_ILOM="True"
        fi
    else
        echo -e '\t' "#########Warning#########"
        echo -e '\t' "Unable to send Test Event due to ILOM Configuration issue"
        echo -e '\t' "Please check the ILOM Configuration to make sure the values are set correctly per ASR Exadata Scripts"
        ASR_TEST_VALUE_ILOM="False"
    fi
}
#END ILOM Test Event Function
#########################################
#Cell OS fault SNMP Validation check
#Validation that MS Service has the systemidentifier value
#Start SNMP validation
cell_os_snmp_val() {
HOST=`hostname | /usr/bin/awk -F. '{ print $1 }'`
MS_ODL="/var/log/oracle/diag/asm/cell/$HOST/trace/ms-odl.log"
Date=`date '+%Y-%m-%dT%H:%M'`
grep -i "ASR SNMP" "$MS_ODL" | grep $Date | grep test | grep "$DEV_TYPE\|Exadata Storage Expansion" > /dev/null 2>&1
if [ $? -ne 0 ]; then
    echo -e '\t' "#########Warning#########"
    echo -e '\t' "ASRExachk has determined that there was a failure during the SNMP Trap Verification."
    echo -e '\t' "The failure will not inhibit the ability for ASR to create a SR but can cause delay"
    echo -e '\t' "Diagnostic time due to System Identifier missing."
    echo -e '\t' "To fix this error, please open a Service Request with the Oracle Exadata Team"
    echo `date` "Missing SystemIdentifier in SNMP Configuration" >> $LOG
fi
}
#End SNMP Validation
#END Test Fault Injectors to send Test Event Emails and validate Path to ASR Manager
#########################################
#Check for existing Faults
#########################################
#Disk Fault Check
disk_fault_Status() {
    #Check to see if temp file was not removed previously
    if [ -f /tmp/ASR-HDD-Fault-Check-Log ]; then
        rm -f /tmp/ASR-HDD-Fault-Check-Log
    fi
    #Check for Faulted drives
    HDD_FAULTED=`$MEGACLI -pdlist -aALL | awk '/Slot Number/ { counter += 1; slot[counter] = $3 } /Device Id/ { device[counter] = $3 } /Firmware state/ { state_drive[counter] = $3 } /Inquiry/ { name_drive[counter] = $3 " " $4 " " $5 " " $6 } END { for (i=1; i<=counter; i+=1) printf ( "Slot %02d Device %02d (%s) status is: %s \n", slot[i], device[i], name_drive[i], state_drive[i]); }' | grep -i -v Online | grep -i -v Hotspare`
    #If returns faulted drive, report the faulted values
    if [ $? -eq 0 ]; then
        echo -e '\t' "#########Warning#########"
        echo $HDD_FAULTED >> /tmp/ASR-HDD-Fault-Check-Log
        echo -e '\t' "Hardware Error has been detected in the HDD Logs on the Cell Node"
        echo -e '\t' "Please open up a Service Request with Oracle to resolve the Error"
        echo -e '\t' "View File /tmp/ASR-HDD-Fault-Check-Log for further"
        echo -e '\t' "Information of the Error. This log File can be copied to the "
        echo -e '\t' "Oracle Service Request for Error Reference"
    else
        echo -e '\t' "No HDD Faults Found"
    fi
}
#END Disk Fault Check
#########################################
#Flash Disk Fault Check Cell Only
flash_fault_Status() {
    #Check to see if temp file was not removed previously
    if [ -f /tmp/ASR-Flash-Fault-Check-Log ]; then
        rm -f /tmp/ASR-Flash-Fault-Check-Log
    fi
    #Flash Drive failure Check Cell only
    FLASH_FAULT=`cellcli -e list physicaldisk where status!=normal | grep FLASH`
    #If returns faulted value, report the faulted values
    if [ $? -eq 1 ]; then
        echo -e '\t' "No Flash Faults found"
    else
        echo $FLASH_FAULT >> /tmp/ASR-Flash-Fault-Check-Log
        echo -e '\t' "#########Warning#########"
        echo -e '\t' "Hardware Error has been detected in the Flash Logs on the Cell Node"
        echo -e '\t' "Please open up a Service Request with Oracle to resolve the Error"
        echo -e '\t' "View File /tmp/ASR-Flash-Fault-Check-Log for further"
        echo -e '\t' "Information of the Error. This log File can be copied to the "
        echo -e '\t' "Oracle Service Request for Error Reference"
    fi
}
#END Flash Disk Fault Check Cell Only
#########################################
#FMA Fault Check Cell Only
ilom_fault_FMA_Status() {
    #Check to see if temp file was not removed previously
    if [ -f /tmp/ASR-FMA-Fault-Check.log ]; then
        rm -f /tmp/ASR-FMA-Fault-Check.log
    fi
    #ILOM Faults
    echo `$IPMILOC/ipmitool sunoem cli "start /SP/faultmgmt/shell" "y" "fmadm faulty -a"` >> /tmp/ASR-FMA-Fault-Check.log
    if [ $? -eq 0 ]; then
        grep "No faults found" /tmp/ASR-FMA-Fault-Check.log > /dev/null 2>&1
        #If returns faulted value, report the faulted values
        if [ $? -eq 0 ]; then
            echo -e '\t' "No FMA faults found"
            rm -f /tmp/ASR-FMA-Fault-Check.log
        else
            echo -e '\t' "#########Warning#########"
            echo -e '\t' "Hardware Error has been detected in the FMA Logs on the ILOM"
            echo -e '\t' "Please open up a Service Request with Oracle to resolve the Error"
            echo -e '\t' "View File /tmp/ASR-FMA-Fault-Check.log for further "
            echo -e '\t' "Information of the Error. This log File can be copied to the Oracle"
            echo -e '\t' "Service Request for Error Reference"
        fi
    else
        echo -e '\t' "The ILOM is reporting busy, please run script again at a later time"
    fi
}
#END FMA Fault Check Cell Only
#########################################
#ILOM Hardware Fault Check Cell Only
ilom_fault_Status() {
    #Check to see if temp file was not removed previously
    if [ -f /tmp/ASR-ILOM-Fault-Check.log ]; then
        rm -f /tmp/ASR-ILOM-Fault-Check.log
    fi
    #Pull Hardware Faults
    $IPMILOC/ipmitool sunoem cli "show faulty" | /usr/bin/awk '/-----/,/->/' |  grep -v "+-" | grep -v "Session closed" >> /tmp/ASR-ILOM-Fault-Check.log
    if [ $? -eq 0 ]; then
        grep -i "sunw-msg-id" /tmp/ASR-ILOM-Fault-Check.log > /dev/null 2>&1
        if [ $? -eq 0 ]; then
            #If returns faulted value, report the faulted values
            echo -e '\t' "#########Warning#########"
            echo -e '\t' "Hardware Error has been detected in the ILOM Logs"
            echo -e '\t' "Please open up a Service Request with Oracle to resolve the Error"
            echo -e '\t' "View File /tmp/ASR-ILOM-Fault-Check.log for further"
            echo -e '\t' "Information of the Error. This log File can be copied to the Oracle"
            echo -e '\t' "Service Request for Error Reference"
        else
            echo -e '\t' "No Hardware ILOM Faults"
            rm -f /tmp/ASR-ILOM-Fault-Check.log
        fi
    else
        echo -e '\t' "The ILOM is reporting busy, please run script again at a later time"
    fi
}
#END ILOM Hardware Fault Check Cell Only
#########################################
#END Check for existing Faults
#########################################
#Main Functions for status checks
#########################################
#Status Start location
#########################################
#Return Host Name value
echo $VERSION
echo `date`
HOSTNAME=`hostname | /usr/bin/awk -F. '{ print $1 }'`
echo "Hostname: $HOSTNAME"

#Print out Device Type
echo "Device Type: $DEV_TYPE"

#Return Serial Number
if [ $OSTYPE = "LINUX" ]; then
    SERIAL_NUM=`dmidecode -s system-serial-number`
fi
if [ $OSTYPE = "SOLARIS" ]; then
    SERIAL_NUM=`$IPMILOC/ipmitool sunoem cli "show /SYS product_serial_number" | grep "product_serial_number" | /usr/bin/awk -F= '{ print $2 }'| sed -e 's/^[ \t]*//'`
fi
echo "Serial Number: $SERIAL_NUM"

echo `date` $VERSION >> $LOG
#########################################
#Start Exadata Methods
if [ $METHOD_TYPE == "Exadata" ]; then
    #########################################
    #Node type validation
    if [ -f /opt/oracle.cellos/ORACLE_CELL_NODE ]; then
        NODE_TYPE="CELL"

        
        #Cellcli retrieve trap destination of type ASR
        cellcli -e "list cell attributes snmpsubscriber" | grep -i "type=asr" > /dev/null 2>&1
        if [ $? -eq 0 ]; then
            cellcli -e list cell detail | grep -i notificationMethod | grep -i snmp > /dev/null 2>&1
            if [ $? -eq 0 ]; then
                ASR_SETUP_STATUS="Configured"
                ex_oncmd
                ASR_MAN_IP_CELL
                echo "ASR Manager IP: $ASR_IP"
                CELL_LIST=`cellcli -e "list cell attributes snmpsubscriber"`
                echo "SNMP Trap Destinations: $CELL_LIST" | sed -e 's/^[ \t]*//'
                echo "Exadata Cell Image: $EXA_CELL_IMAGE"
            else
                cellcli -e list cell detail | grep -i notificationMethod | grep -i mail > /dev/null 2>&1
                if [ $? -eq 0 ]; then
                    echo "#########Warning#########"
                    echo "ASREXACHK has found a configuration issue with the Cell Notification Method."
                    echo "ASREXACHK returned value of 'mail' only"
                    echo "Running commad to set value to include SNMP"
                    cellcli -e "alter cell notificationMethod='mail,snmp'" > /dev/null 2>&1
                    ASR_SETUP_STATUS="Configured"
                else
                    echo "#########Warning#########"
                    echo "ASREXACHK has found a configuration issue with the Cell Notification Method."
                    echo "ASREXACHK returned value with no method set"
                    echo "Running commad to set value to include SNMP"
                    cellcli -e "alter cell notificationMethod='snmp'" > /dev/null 2>&1
                    ASR_SETUP_STATUS="Configured"
                fi
            fi
        else
            ASR_SETUP_STATUS="Unconfigured"
            echo "#########Warning#########"
            echo "Unable to determine configuration status of the cell node."
            echo "Please check to make sure the ASR Manager Hostname or IP are"
            echo "setup through the cellcli command to include the type of ASR"
            echo "Please reference the Oracle Exadata Administration guide for more"
            echo "details on cell commands for ASR as well"
            echo "as My Oracle Support Knowledge Article 1451026.1 for use with Grid Control"
        fi
    else
        if [ -f $EXADATA_MON/exadata_mon_hw_asr.pl ]; then
            NODE_TYPE="DB"
            if [ -f $EXADATA_MON/asrs.state ]; then
                if [ $? -eq 0 ]; then
                    ASR_SETUP_STATUS="Configured"
                    asrs_validate
                    ex_oncmd
                    ASR_MAN_IP_DB
                    if [ "$ASR_IP" != "N/A" ]; then
                        echo "ASR Manager IP: $ASR_IP"
                        SNMP_TRAP_DEST=`$EXA_COMMAND -get_snmp_subscribers -type asr | sed -e 's/^[ \t]*//'`
                        echo "SNMP Trap Destinations: $SNMP_TRAP_DEST"
                        echo $EXA_DB_IMAGE
                    else
                        if [ "$DUAL_ASR_ENTRY" == "TRUE" ]; then
                            echo "ASR Manager IP:"
                            
                        else
                            echo "ASR Manager IP:"
                            result=$(ASR_Return_5)
                            echo "$result"
                            echo ""
                        fi
                    fi
                fi
            else
                ASR_SETUP_STATUS="Unconfigured"
            fi
        fi
    fi
    #END Node type validation
    #########################################
    #DB Nodes Process Check
    if [ $NODE_TYPE = "DB" ]; then
        echo "DB Node validation Progress"
        echo ""
        #Check to see if exadata_mon_hw_asr.pl is running
        echo "Checking for ASR/Exadata Process Running"
        ps -ef | grep exadata_mon_hw_asr.pl | grep -v grep > /dev/null 2>&1
        if [ $? -ne 0 ]; then
            echo ""
            echo -e '\t' "#########Warning#########"
            echo -e '\t' "Exadata Monitoring Script is currently not running"
            echo -e '\t' "Please Contact ASR Support for furhter Assistance"
        else
            echo -e '\t' "Exadata Monitoring Script running as expected"
        fi
        #Check to see if ASR is configured
        if [ $ASR_SETUP_STATUS == "Unconfigured" ]; then
            echo ""
            echo -e '\t' "#########Warning#########"
            echo -e '\t' "ASR Is not configured on Node"
            echo -e '\t' "Please setup ASR per process from ASR Exadata Installation Guide"
            echo -e '\t' "http://wd0338.oracle.com/archive/cd_ns/E13877_01/doc/doc.112/e13874.pdf"
        fi
    else
        #Cell Process
        if [ $NODE_TYPE == "CELL" ]; then
            echo "Cell Node validation Progress"
            echo -e '\t' "Checking for ASR/Exadata Process Running"
            if [ $ASR_SETUP_STATUS == "Unconfigured" ]; then
                echo ""
                echo -e '\t' "#########Warning#########"
                echo -e '\t' "ASR Is not configured on Node"
                echo -e '\t' "Please setup ASR per process from ASR Exadata Installation Guide"
                echo -e '\t' "http://wd0338.oracle.com/archive/cd_ns/E13877_01/doc/doc.112/e13874.pdf"
            fi
        fi
    fi
    #END DB Nodes Process
    #########################################
    # Validation Process
    #########################################
    #DB Only side Status process
    if [ $NODE_TYPE = "DB" ]; then
        #Check eth0 to make sure it is not on same subnet as the bond network
        if [ $OSTYPE = "SOLARIS" ]; then
            echo ""
            echo "Solaris DB Node IP Interface Check"
            solaris_ip_int_check
            echo ""
            echo "Solaris Perl Symbolic Link Location Validation"
            perl_location_validation
        else
            if [ $OSTYPE = "LINUX" ]; then
                echo ""
                echo "Linux DB Node IP Interface Check"
                linux_ip_int_check
            fi
        fi
        #fromip check
        echo ""
        echo "Validating Fromip"
        fromip_validation
        #BMC State check
        echo ""
        echo "Checking the BMC Status"
        bmc_validation
        #check for prefaulted Devices and notify console screen
        echo ""
        echo "Checking for Pre-Existing Errors"
        #Check for prefaulted devices
        #Disk Fault check
        echo ""
        echo "Checking for HDD Faults"
        disk_fault_Status
        #FMA ILOM Check
        echo ""
        echo "Checking for FMA Faults"
        if [ $BMC_STATUS -eq 0 ]; then
            ilom_fault_FMA_Status
        else
            echo -e '\t' "#########Warning#########"
            echo -e '\t' "Unable to Check for FMA Faults due to BMC Driver Issue"
        fi
        #ILOM Hardware Faults
        echo ""
        echo "Checking for ILOM Hardware Faults"
        if [ $BMC_STATUS -eq 0 ]; then
            ilom_fault_Status
        else
            echo -e '\t' "#########Warning#########"
            echo -e '\t' "Unable to Check for ILOM Hardware Faults due to BMC Driver Issue"
        fi
        if [ $TESTFUNCTION == "TRUE" ]; then
            echo ""
            echo "Validating ASR Configuration with Validate SNMP"
            if [ $BMC_STATUS -eq 0 ]; then
                if [ $ASR_SETUP_STATUS = "Configured" ]; then
                    if [ $ASR_NET -eq "0" ]; then
                        ASR_TEST_VALUE="True"
                        #Send test event from DB Node
                        #Send test event from OS
                        echo ""
                        echo "Exadata OS Validation"
                        echo -e '\t' `$EXA_COMMAND -validate_snmp_subscriber -type asr`
                        ASR_TEST_VALUE_OS="True"
                        #Send test event from ILOM
                        echo ""
                        echo "Exadata ILOM Validation"
                        ilom_send_test
                    else
                        result=$(ASR_Return_7)
                        echo "$result"
                        ASR_TEST_VALUE="False"
                    fi        
                else
                    result=$(ASR_Return_8)
                    echo "$result"
                    ASR_TEST_VALUE="False"
                fi
            else
                echo -e '\t' "#########Warning#########"
                echo -e '\t' "Unable to Check SNMP for ILOM due to BMC Driver Issue"
                ASR_TEST_VALUE="False"
            fi
        fi
    else
        #Cell Only Side Status Process
        if [ $NODE_TYPE = "CELL" ]; then
            cell_validate_checks
        fi
    fi
fi
#End Exadata Methods
#########################################
#Start BDA Methods
if [ $METHOD_TYPE == "BDA" ]; then
    #########################################
    #Start Node type validation
    #/opt/oracle/bda/install/state/mammoth-saved.params
    #SETUP_ASR_SERVER=false
    #ASR_HOST=
    #ASR_PORT=162
    #ASR_ENABLED=false
    ASR_ENB=`grep -i "ASR_ENABLED" $INSTALL_INFO | /usr/bin/awk -F= '{ print $2 }'`
    if [ $ASR_ENB == "true" ]; then
        if [ -f $EXA_COMMAND ]; then
            if [ -f $EXADATA_MON/asrs.state ]; then
                if [ $? -eq 0 ]; then
                    ASR_SETUP_STATUS="Configured"
                    asrs_validate
                    ASR_MAN_IP_DB
                    if [ "$ASR_IP" != "N/A" ]; then
                        echo "ASR Manager IP: $ASR_IP"
                        SNMP_TRAP_DEST=`$EXA_COMMAND -get_snmp_subscribers -type asr | sed -e 's/^[ \t]*//'`
                        echo "SNMP Trap Destinations: $SNMP_TRAP_DEST"
                        echo $EXA_DB_IMAGE
                    else
                        echo "ASR Manager IP:"
                        result=$(ASR_Return_5)
                        echo "$result"
                        echo ""
                        ASR_SETUP_STATUS="Unconfigured"
                    fi
                fi
            else
                ASR_SETUP_STATUS="Unconfigured"
            fi
        fi
    else
       ASR_SETUP_STATUS="Unconfigured" 
    fi
    #END Node type validation
    #########################################
    #Start BDA Process Validation
    #Check to see if bda_mon_hw_asr.pl is running
    echo "Checking for ASR Process Running"
    ps -ef | grep bda_mon_hw_asr.pl | grep -v grep > /dev/null 2>&1
    if [ $? -ne 0 ]; then
        echo ""
        echo -e '\t' "#########Warning#########"
        echo -e '\t' "$METHOD_TYPE Monitoring Script is currently not running"
        echo -e '\t' "Please Contact ASR Support for furhter Assistance"
    else
        echo -e '\t' "$METHOD_TYPE Monitoring Script running as expected"
    fi
    #Check to see if ASR is configured
    if [ "$ASR_SETUP_STATUS" == "Unconfigured" ]; then
        echo ""
        echo -e '\t' "#########Warning#########"
        echo -e '\t' "ASR Is not configured on Node"
        echo -e '\t' "Please setup ASR per process from ASR BDA Installation Guide"
        echo -e '\t' "http://www.oracle.com/technetwork/server-storage/engineered-systems/bigdata-appliance/documentation/index.html"
    fi
    #End BDA Process Validation
    #########################################
    # Validation Process
    #########################################
    if [ "$ASR_SETUP_STATUS" == "Configured" ]; then
        #BDA Status process
        echo "Linux IP Interface Check"
        linux_ip_int_check
        #fromip check
        echo ""
        echo "Validating Fromip"
        fromip_validation
        #BMC State check
        echo ""
        echo "Checking the BMC Status"
        bmc_validation
        #check for prefaulted Devices and notify console screen
        echo ""
        echo "Checking for Pre-Existing Errors"
        #Check for prefaulted devices
        #Disk Fault check
        echo ""
        echo "Checking for HDD Faults"
        disk_fault_Status
        #FMA ILOM Check
        echo ""
        echo "Checking for FMA Faults"
        if [ $BMC_STATUS -eq 0 ]; then
            ilom_fault_FMA_Status
        else
            echo -e '\t' "#########Warning#########"
            echo -e '\t' "Unable to Check for FMA Faults due to BMC Driver Issue"
        fi
        #ILOM Hardware Faults
        echo ""
        echo "Checking for ILOM Hardware Faults"
        if [ $BMC_STATUS -eq 0 ]; then
            ilom_fault_Status
        else
            echo -e '\t' "#########Warning#########"
            echo -e '\t' "Unable to Check for ILOM Hardware Faults due to BMC Driver Issue"
        fi
        if [ $TESTFUNCTION == "TRUE" ]; then
            echo ""
            echo "Validating ASR Configuration with Validate SNMP"
            if [ $BMC_STATUS -eq 0 ]; then
                if [ $ASR_SETUP_STATUS = "Configured" ]; then
                    if [ $ASR_NET -eq "0" ]; then
                        ASR_TEST_VALUE="True"
                        #Send test event from DB Node
                        #Send test event from OS
                        echo ""
                        echo "OS Validation"
                        echo -e '\t' `$EXA_COMMAND -validate_snmp_subscriber -type asr`
                        ASR_TEST_VALUE_OS="True"
                        #Send test event from ILOM
                        echo ""
                        echo "ILOM Validation"
                        ilom_send_test
                    else
                        result=$(ASR_Return_7)
                        echo "$result"
                        ASR_TEST_VALUE="False"
                    fi        
                else
                    result=$(ASR_Return_8)
                    echo "$result"
                    ASR_TEST_VALUE="False"
                fi
            else
                echo -e '\t' "#########Warning#########"
                echo -e '\t' "Unable to Check SNMP for ILOM due to BMC Driver Issue"
                ASR_TEST_VALUE="False"
            fi
        fi
    fi
fi
#########################################
#End BDA Methods
#########################################
#Start Exalytics
if [ $METHOD_TYPE == "Exalytics" ]; then
    #########################################
    #Start Node type validation
    if [ -f $EXA_COMMAND ]; then
        if [ -f $EXADATA_MON/asrs.state ]; then
            if [ $? -eq 0 ]; then
                ASR_SETUP_STATUS="Configured"
                asrs_validate
                ASR_MAN_IP_DB
                if [ "$ASR_IP" != "N/A" ]; then
                    echo "ASR Manager IP: $ASR_IP"
                    SNMP_TRAP_DEST=`$EXA_COMMAND -get_snmp_subscribers -type asr | sed -e 's/^[ \t]*//'`
                    echo "SNMP Trap Destinations: $SNMP_TRAP_DEST"
                    echo $EXA_DB_IMAGE
                else
                    echo "ASR Manager IP:"
                    result=$(ASR_Return_5)
                    echo "$result"
                    echo ""
                fi
            fi
        else
            ASR_SETUP_STATUS="Unconfigured"
        fi
    fi

    #END Node type validation
    #########################################
    #Start Exalytics Process Validation
    #Check to see if bda_mon_hw_asr.pl is running
    echo "Checking for ASR Process Running"
    ps -ef | grep bda_mon_hw_asr.pl | grep -v grep > /dev/null 2>&1
    if [ $? -ne 0 ]; then
        grep "bda_mon_hw_asr.pl" /etc/inittab > /dev/null 2>&1
        if [ $? -eq 0 ]; then
            echo ""
            echo -e '\t' "#########Warning#########"
            echo -e '\t' "$METHOD_TYPE Monitoring Script is currently not running"
            echo -e '\t' "Please Contact ASR Support for furhter Assistance"
        else
            echo "" >> /etc/inittab
            echo "#ASR Service" >> /etc/inittab
            echo "emh1:345:respawn:/opt/exalytics/asr/bda_mon_hw_asr.pl -server" >> /etc/inittab
            init q
        fi
    else
        echo -e '\t' "$METHOD_TYPE Monitoring Script running as expected"
    fi
    #Check to see if ASR is configured
    if [ $ASR_SETUP_STATUS == "Unconfigured" ]; then
        echo ""
        echo -e '\t' "#########Warning#########"
        echo -e '\t' "ASR Is not configured on Node"
        echo -e '\t' "Please setup ASR per process from ASR Exalytics Installation Guide"
        echo -e '\t' "http://docs.oracle.com/cd/E27027_01/doc.1/e25369/asr.htm#sthref57"
    fi
    #End Exalytics Process Validation
    #########################################
    # Validation Process
    #########################################
    #BDA Status process
    echo "Linux IP Interface Check"
    linux_ip_int_check
    #fromip check
    echo ""
    echo "Validating Fromip"
    fromip_validation
    #BMC State check
    echo ""
    echo "Checking the BMC Status"
    bmc_validation
    #check for prefaulted Devices and notify console screen
    echo ""
    echo "Checking for Pre-Existing Errors"
    #Check for prefaulted devices
    #Disk Fault check
    echo ""
    echo "Checking for HDD Faults"
    disk_fault_Status
    #FMA ILOM Check
    echo ""
    echo "Checking for FMA Faults"
    if [ $BMC_STATUS -eq 0 ]; then
        ilom_fault_FMA_Status
    else
        echo -e '\t' "#########Warning#########"
        echo -e '\t' "Unable to Check for FMA Faults due to BMC Driver Issue"
    fi
    #ILOM Hardware Faults
    echo ""
    echo "Checking for ILOM Hardware Faults"
    if [ $BMC_STATUS -eq 0 ]; then
        ilom_fault_Status
    else
        echo -e '\t' "#########Warning#########"
        echo -e '\t' "Unable to Check for ILOM Hardware Faults due to BMC Driver Issue"
    fi
    if [ $TESTFUNCTION == "TRUE" ]; then
        echo ""
        echo "Validating ASR Configuration with Validate SNMP"
        if [ $BMC_STATUS -eq 0 ]; then
            if [ $ASR_SETUP_STATUS = "Configured" ]; then
                if [ $ASR_NET -eq "0" ]; then
                    ASR_TEST_VALUE="True"
                    #Send test event from DB Node
                    #Send test event from OS
                    echo ""
                    echo "OS Validation"
                    echo -e '\t' `$EXA_COMMAND -validate_snmp_subscriber -type asr`
                    ASR_TEST_VALUE_OS="True"
                    #Send test event from ILOM
                    echo ""
                    echo "ILOM Validation"
                    ilom_send_test
                else
                    result=$(ASR_Return_7)
                    echo "$result"
                    ASR_TEST_VALUE="False"
                fi        
            else
                result=$(ASR_Return_8)
                echo "$result"
                ASR_TEST_VALUE="False"
            fi
        else
            echo -e '\t' "#########Warning#########"
            echo -e '\t' "Unable to Check SNMP for ILOM due to BMC Driver Issue"
            ASR_TEST_VALUE="False"
        fi
    fi
fi
#########################################
#End Exalytics Methods
#########################################
#Start Exalogic Methods
if [ $METHOD_TYPE == "Exalogic" ]; then
#Check for ASR Value has been entered in
    if [ -s $EXADATA_MON/asrs.state ]; then
        echo -e 't' "Exalogic Node Previously Setup with ASREXACHK"
        ASR_IP=`cat $EXADATA_MON/asrs.state | /usr/bin/awk -F: '{ print $1}'`
    else
        #Create asrs.state file for future reference
        #Prompt for ASR Manager IP
        while true;
        do
            read -p "Enter ASR Manager IP: " exalogic_asr_ip
            if [[ $exalogic_asr_ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
                ASR_IP="$exalogic_asr_ip"
                break
            else
                echo "Please enter a valid IP Address"
            fi
        done
        #Prompt for ASR Manager Port
        while true;
        do
            read -p "Enter ASR Manager SNMP Port: " exalogic_asr_port
            if [[ $exalogic_asr_port =~ ^[0-9]{1,3}$ ]]; then
                ASR_PORT="$exalogic_asr_port"
                break
            else
                if [[ $exalogic_asr_port =~ ^[0-9]{1,4}$ ]]; then
                    ASR_PORT="$exalogic_asr_port"
                    break
                else
                    echo "Please enter a valid SNMP Port"
                fi
            fi
        done
        echo $ASR_IP:$ASR_PORT > $EXADATA_MON/asrs.state
    fi
#Start validation of Exalogic
echo $EXA_CELL_IMAGE
#BMC State check
    echo ""
    echo "Checking the BMC Status"
    bmc_validation
    #check for prefaulted Devices and notify console screen
    echo ""
    echo "Checking for Pre-Existing Errors"
    #Check for prefaulted devices
    #Disk Fault check
    echo ""
    echo "Checking for HDD Faults"
    disk_fault_Status
    #FMA ILOM Check
    echo ""
    echo "Checking for FMA Faults"
    if [ $BMC_STATUS -eq 0 ]; then
        ilom_fault_FMA_Status
    else
        echo -e '\t' "#########Warning#########"
        echo -e '\t' "Unable to Check for FMA Faults due to BMC Driver Issue"
    fi
    #ILOM Hardware Faults
    echo ""
    echo "Checking for ILOM Hardware Faults"
    if [ $BMC_STATUS -eq 0 ]; then
        ilom_fault_Status
    else
        echo -e '\t' "#########Warning#########"
        echo -e '\t' "Unable to Check for ILOM Hardware Faults due to BMC Driver Issue"
    fi
    echo ""
    if [ $TESTFUNCTION == "TRUE" ]; then
        echo "Validating ASR Configuration with Validate SNMP"
        if [ $BMC_STATUS -eq 0 ]; then
            #Send test event from ILOM
            echo ""
            echo "ILOM Validation"
            ilom_send_test

        else
            echo -e '\t' "#########Warning#########"
            echo -e '\t' "Unable to Check SNMP for ILOM due to BMC Driver Issue"
            ASR_TEST_VALUE="False"
        fi
    fi
fi
#########################################
#End Exalogic Methods
#########################################
#Validation Success messages
if [ $TESTFUNCTION == "TRUE" ]; then
    if [ $METHOD_TYPE != "Exalogic" ]; then
        #OS validation Success Message
        if [ "$ASR_TEST_VALUE" == "True" ]; then
            if [ "$ASR_TEST_VALUE_OS" == "True" ]; then
                if [ "$ASR_TEST_VALUE_ILOM" == "True" ]; then
                    echo ""
                    echo "Validation Complete"
                    echo -e '\t' "Based on the Status, the email account registered to the ASR Manager"
                    echo -e '\t' "should receive 2 emails. One from the OS Hostname, and the"
                    echo -e '\t' "second from the ILOM Hostname"
                    echo -e '\t' "If 2 emails has not been received, please work with the ASR Backline"
                    echo -e '\t' "Team for further troubleshooting of the issue"
                    echo "Send OS Test Successful" >> $LOG
                else
                    echo "Send ILOM Test Failure" >> $LOG
                fi
                echo "Send OS Test Successful" >> $LOG
            else
                echo "Send OS Test Failure" >> $LOG
            fi
        else
            echo "Configuration Failure" >> $LOG
        fi
    else
        if [ "$ASR_TEST_VALUE" == "True" ]; then
            if [ "$ASR_TEST_VALUE_ILOM" == "True" ]; then
                echo ""
                echo "Validation Complete"
                echo -e '\t' "Based on the Status, the email account registered to the ASR Manager"
                echo -e '\t' "should receive 2 emails. One from the OS Hostname, and the"
                echo -e '\t' "second from the ILOM Hostname"
                echo -e '\t' "If 2 emails has not been received, please work with the ASR Backline"
                echo -e '\t' "Team for further troubleshooting of the issue"
                echo "Send OS Test Successful" >> $LOG
            else
                echo "Send ILOM Test Failure" >> $LOG
            fi
        else
            echo "Configuration Failure" >> $LOG
        fi
    fi
fi
#End of Validation Container Validation process