newrelic / newrelic-unix-monitor

Monitoring service for Unix (AIX, Linux, HP-UX, MacOS, Solaris) systems
https://docs.newrelic.com/docs/infrastructure/host-integrations/host-integrations-list/unix-monitoring-integration/
Other
31 stars 24 forks source link

Oracle Database monitoring in AIX is not reporting to New relic #58

Closed Ssreelsadm closed 1 year ago

Ssreelsadm commented 1 year ago

Hi All,

We are working on the Oracle Database monitoring in AIX machine . Data is not reporting for Oracle database even though the AIX machine is reporting to new relic. Please find below the logs for reference. (vix01)(oracle)(CASPROD)/tech/newrelic> /tech/newrelic/newrelic_ora_mon.sh New Relic Oracle Plug-in Instance 1 is NOT running Attempt to start Oracle Plug-in Instance 1

Change Record:

!/bin/sh

usage() { echo "Usage: $0 start | all " echo " $0 stop | all " echo " $0 status | all " }

datestr=date

javaexe='/usr/java8_64/jre/bin/java'

This is to avoid using /opt/freeware on some server

PATH=/usr/bin:$PATH

action=$1

for nrinst in $nrinstlist do nrcfgdir="$nrhome/${nrapp}${nrinst}/config" nrlibdir="$nrhome/${nrapp}${nrinst}/lib"

# check exisitence of config directory
if [ ! -d "$nrcfgdir" ] ; then
    echo "New Relic Plug-in config directory does not exist for Instance ${nrinst}"
    continue
fi

# check exisitence of lib directory
if [ ! -d "$nrlibdir" ] ; then
    echo "New Relic Plug-in lib directory does not exist for Instance ${nrinst}"
    continue
fi

case "$action" in
start)
     nrpid=`ps -uoracle -o "%p %a" | grep "com.newrelic.infra.db.Main" |  grep "${nrapp}_${nrinst}" | grep -v grep |  awk '{printf("%s\n",$1)}' `
     if [ -z "$nrpid" ]; then
        echo "Starting New Relic Oracle Plug-in at $datestr for Instance ${nrinst}"
        echo " "
        CLASSPATH=$nrlibdir/nri-db-2.1.0.jar:$nrlibdir/slf4j-jdk14-1.7.30.jar:$nrlibdir/infra_publish-2.3.1.jar:$nrlibdir/insights_client-1.0.9.jar:$nrlibdir/slf4j-api-1.7.30.jar:$nrlibdir/gson-2.8.6.jar:$nrlibdir/jasypt-1.9.3.jar:$nrlibdir/commons-lang3-3.12.0.jar:$nrlibdir/postgresql-42.2.19.jar:$nrlibdir/hsqldb-2.5.1.jar:$nrlibdir/jackson-databind-2.6.7.1.jar:$nrlibdir/checker-qual-3.5.0.jar:$nrlibdir/jackson-annotations-2.6.0.jar:$nrlibdir/jackson-core-2.6.7.jar:$nrlibdir/httpclient-4.5.6.jar:$nrlibdir/httpcore-4.4.10.jar:$nrlibdir/commons-logging-1.2.jar:$nrlibdir/commons-codec-1.10.jar:$nrhome/ojdbc8.jar
        export CLASSPATH

        DEFAULT_JVM_OPTS="-Djava.util.logging.config.file=$nrcfgdir/logging.properties"

       ## must change the directory where .nridbrc exists
        cd $nrhome/${nrapp}_${nrinst}
        nohup $javaexe  -Xms16m -Xmx128m -classpath "$CLASSPATH" $DEFAULT_JVM_OPTS com.newrelic.infra.db.Main   >/dev/null 2>&1 &
        nrpid=$!
        echo "New Relic Oracle Plug-in started with pid $nrpid for Instance ${nrinst}"
     else
        echo "New Relic Oracle Plug-in is already running as $nrpid for Instance ${nrinst}"
        echo " "
        echo "Stop the running New Relic Oracle Plug-in first"
     fi
     ;;
stop)
     echo "Stopping New Relic Oracle Plug-in at $datestr for Instance ${nrinst}"
     echo " "
     cd $nrhome
     nrpid=`ps -uoracle -o "%p %a" | grep "com.newrelic.infra.db.Main" |  grep "${nrapp}_${nrinst}" | grep -v grep |  awk '{printf("%s\n",$1)}' `
     if [ -z "$nrpid" ]; then
        echo "New Relic Oracle Plug-in is not running. No Plug-in is stopped"
     else
        kill -9 $nrpid
        echo "New Relic Oracle Plug-in with pid $nrpid is terminated with kill -9 for Instance ${nrinst}"
     fi
     ;;
status)
     echo "Checking Status of New Relic Oracle Plug-in at $datestr for Instance ${nrinst}"
     echo " "
     cd $nrhome
     nrpid=`ps -uoracle -o "%p %a" | grep "com.newrelic.infra.db.Main" |  grep "${nrapp}_${nrinst}" | grep -v grep |  awk '{printf("%s\n",$1)}' `
     if [ -z "$nrpid" ]; then
        echo "New Relic Oracle Plug-in is not running for Instance ${nrinst}"
     else
        echo "New Relic Oracle Plug-in running with pid $nrpid for Instance ${nrinst}"
     fi
     ;;
*)
     usage
     ;;
esac

done

exit 0

usage() { echo "Usage: $0 start | all " echo " $0 stop | all " echo " $0 status | all " }

datestr=date

javaexe='/usr/java8_64/jre/bin/java'

This is to avoid using /opt/freeware on some server

PATH=/usr/bin:$PATH

action=$1

for nrinst in $nrinstlist do nrcfgdir="$nrhome/${nrapp}${nrinst}/config" nrlibdir="$nrhome/${nrapp}${nrinst}/lib"

# check exisitence of config directory
if [ ! -d "$nrcfgdir" ] ; then
    echo "New Relic Plug-in config directory does not exist for Instance ${nrinst}"
    continue
fi

# check exisitence of lib directory
if [ ! -d "$nrlibdir" ] ; then
    echo "New Relic Plug-in lib directory does not exist for Instance ${nrinst}"
    continue
fi

case "$action" in
start)
     nrpid=`ps -uoracle -o "%p %a" | grep "com.newrelic.infra.db.Main" |  grep "${nrapp}_${nrinst}" | grep -v grep |  awk '{printf("%s\n",$1)}' `
     if [ -z "$nrpid" ]; then
        echo "Starting New Relic Oracle Plug-in at $datestr for Instance ${nrinst}"
        echo " "
        CLASSPATH=$nrlibdir/nri-db-2.1.0.jar:$nrlibdir/slf4j-jdk14-1.7.30.jar:$nrlibdir/infra_publish-2.3.1.jar:$nrlibdir/insights_client-1.0.9.jar:$nrlibdir/slf4j-api-1.7.30.jar:$nrlibdir/gson-2.8.6.jar:$nrlibdir/jasypt-1.9.3.jar:$nrlibdir/commons-lang3-3.12.0.jar:$nrlibdir/postgresql-42.2.19.jar:$nrlibdir/hsqldb-2.5.1.jar:$nrlibdir/jackson-databind-2.6.7.1.jar:$nrlibdir/checker-qual-3.5.0.jar:$nrlibdir/jackson-annotations-2.6.0.jar:$nrlibdir/jackson-core-2.6.7.jar:$nrlibdir/httpclient-4.5.6.jar:$nrlibdir/httpcore-4.4.10.jar:$nrlibdir/commons-logging-1.2.jar:$nrlibdir/commons-codec-1.10.jar:$nrhome/ojdbc8.jar
        export CLASSPATH

        DEFAULT_JVM_OPTS="-Djava.util.logging.config.file=$nrcfgdir/logging.properties"

       ## must change the directory where .nridbrc exists
        cd $nrhome/${nrapp}_${nrinst}
        nohup $javaexe  -Xms16m -Xmx128m -classpath "$CLASSPATH" $DEFAULT_JVM_OPTS com.newrelic.infra.db.Main   >/dev/null 2>&1 &
        nrpid=$!
        echo "New Relic Oracle Plug-in started with pid $nrpid for Instance ${nrinst}"
     else
        echo "New Relic Oracle Plug-in is already running as $nrpid for Instance ${nrinst}"
        echo " "
        echo "Stop the running New Relic Oracle Plug-in first"
     fi
     ;;
stop)
     echo "Stopping New Relic Oracle Plug-in at $datestr for Instance ${nrinst}"
     echo " "
     cd $nrhome
     nrpid=`ps -uoracle -o "%p %a" | grep "com.newrelic.infra.db.Main" |  grep "${nrapp}_${nrinst}" | grep -v grep |  awk '{printf("%s\n",$1)}' `
     if [ -z "$nrpid" ]; then
        echo "New Relic Oracle Plug-in is not running. No Plug-in is stopped"
     else
        kill -9 $nrpid
        echo "New Relic Oracle Plug-in with pid $nrpid is terminated with kill -9 for Instance ${nrinst}"
     fi
     ;;
status)
     echo "Checking Status of New Relic Oracle Plug-in at $datestr for Instance ${nrinst}"
     echo " "
     cd $nrhome
     nrpid=`ps -uoracle -o "%p %a" | grep "com.newrelic.infra.db.Main" |  grep "${nrapp}_${nrinst}" | grep -v grep |  awk '{printf("%s\n",$1)}' `
     if [ -z "$nrpid" ]; then
        echo "New Relic Oracle Plug-in is not running for Instance ${nrinst}"
     else
        echo "New Relic Oracle Plug-in running with pid $nrpid for Instance ${nrinst}"
     fi
     ;;
*)
     usage
     ;;
esac

done

exit 0

Regards, Sreelekshmi

Steve24by7 commented 1 year ago

Hello @Ssreelsadm This repository is for code that monitors the Operating System, not a database. New Relic does indeed have an Oracle database integration, you can find it here, which is fully supported by NR Support and does not need to be on the AIX server where the DB server is so you can locate it on a supported O/S. You can find related solutions by searching https://discuss.newrelic.com