1

I am trying to create a script that checks the usage of each disk in an ASMDISK group. I have my script setup on one node in each RAC cluster. It works on several of the servers without issue, but on two of them it is returning the incorrect value.

In this case it is returning a value of 0 versus the expected value of 1.

# export ORACLE_HOME=/u01/app/oracle/product/12.1.0.2/db_1
# export ORACLE_SID=db1
# export PATH=$PATH:$ORACLE_HOME/bin
# sqlplus ****/****

SQL*Plus: Release 12.1.0.2.0 Production on Tue Dec 6 18:57:13 2016

SQL> select count(*) from  V$asm_disk_stat;

  COUNT(*)
----------
         0

When I run the exact same SQL from the oracle user account, but still using the same oracle db user, I get the correct result. DB_ENV source file has the exact same exports that were manually entered as the other user.

# su - oracle
$ source db_env 
$ sqlplus ****/****

SQL*Plus: Release 12.1.0.2.0 Production on Tue Dec 6 19:07:18 2016

SQL> select count(*) from  V$asm_disk_stat;

  COUNT(*)
----------
         1

I am not sure why this might be occurring. I have other scripts that use the exact same manner to connect and are able to get correct data from the oracle database.

As per roaima, I am explicitly stating the output:

when running as root:

# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/dell/srvadmin/bin:/opt/dell/srvadmin/sbin:/etc/opt/emcpower/bin:/root/bin:/u01/app/oracle/product/12.1.0.2/db_1/bin:/u01/app/oracle/product/12.1.0.2/db_1/bin

# echo $ORACLE_HOME
/u01/app/oracle/product/12.1.0.2/db_1

echo $ORACLE_SID
db1

When running as Oracle:

echo $PATH
/u01/app/oracle/product/12.1.0.2/db_1/bin:/usr/sbin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/dell/srvadmin/bin:/etc/opt/emcpower/bin:/home/oracle/bin

echo $ORACLE_HOME
/u01/app/oracle/product/12.1.0.2/db_1

echo $ORACLE_SID
db1
  • I have updated the original question with the information. Thanks! – StarKev2525 Dec 6 '16 at 19:58
  • If you explicitly set the PATH for the root user to match that of the normal user does that make the difference? – roaima Dec 6 '16 at 20:30
  • All of the oracle locations that are in the oracle user are set in the root user's path by doing the export. – StarKev2525 Dec 6 '16 at 21:17
  • No they're not: the order is different. – roaima Dec 6 '16 at 21:18
  • In the end, the order will only affect if the binary file that is being used is located in several locations that are in the path. In this case sqlplus is only located in a single location, and there is not an issue starting sqlplus. /u01/app/oracle/product/12.1.0.2/db_1/bin/sqlplus – StarKev2525 Dec 7 '16 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.