Don't worry...
No problem man. I can wait. Sorry if I'm boring you.
No problem man. I can wait. Sorry if I'm boring you.


i'm happy that my explanation was clear 


ALTER SESSION SET NLS_NUMERIC_CHARACTERS=".,"; SELECT a.tablespace_name AS name, ROUND(100* b.bytes / a.bytes,1) AS percent_free FROM (SELECT tablespace_name, sum(bytes) bytes from SYS.DBA_DATA_FILES GROUP BY tablespace_name) a, (SELECT tablespace_name, sum(bytes) bytes from SYS.DBA_FREE_SPACE GROUP BY tablespace_name) b WHERE a.tablespace_name = b.tablespace_name;
2009.Dec.17 11:57:20 SYSTEM 20.1 INDEX 66.7 USERS 19.1 SYSAUX 23.4 UNDOTBS1 97.6
ALTER SESSION SET NLS_NUMERIC_CHARACTERS=".,"; SELECT a.tablespace_name AS name, ROUND(100* b.bytes / a.bytes,1) AS percent_free FROM (SELECT tablespace_name, sum(bytes) bytes from SYS.DBA_DATA_FILES GROUP BY tablespace_name) a, (SELECT tablespace_name, sum(bytes) bytes from SYS.DBA_FREE_SPACE GROUP BY tablespace_name) b WHERE a.tablespace_name = b.tablespace_name;
SELECT
/* for debug purpose :
a.tablespace_name AS name, */
ROUND(100* b.bytes / a.bytes,1) AS percent_free
FROM
(SELECT tablespace_name, sum(bytes) bytes from SYS.DBA_DATA_FILES
GROUP BY tablespace_name) a,
(SELECT tablespace_name, sum(bytes) bytes from SYS.DBA_FREE_SPACE
GROUP BY tablespace_name) b
WHERE a.tablespace_name = b.tablespace_name
/* name of tablespace in argument */
AND a.tablespace_name = '&1';
exit;
#!/bin/sh
# Oracle environment variables
export PATH=$PATH:/home/oracle/bin:/home/oracle/oracle/product/10.2.0/db_1/bin
export ORACLE_HOME=/home/oracle/oracle/product/10.2.0/db_1
SQLPLUS=/home/oracle/oracle/product/10.2.0/db_1/bin/sqlplus
IP=
INSTANCE=
QUERY=
ARGS=
# Display help
printhelp() {
echo "query_oracle.sh - an Oracle query for zabbix"
echo "Usage: query_oracle.sh hostname instance query [parameters] [help]"
echo " ip ip adress of oracle server"
echo " instance to retrieve credentials from credentials file (must be the same with tnsnames.ora"
echo " query execute a query and return just only the output"
echo " parameters for extrat arguments"
}
execquery() {
# `echo "Running $SQLPLUS -S $INSTANCE $QUERY $ARGS query " >> /opt/zabbix1/var/log/zabbix/zabbix_server.log`
RES=$($SQLPLUS -S $INSTANCE $QUERY $ARGS)
RET=$?
if [ $RET -ne 0 ]
then
echo "Error while querying $INSTANCE"
fi
echo $RES
}
# testing args
if [ $# -lt 2 ]
then
printhelp
exit 1
fi
# better way to "shift"
IP=$1
INSTANCE=zabbix/zabbix@$2
QUERY=@/opt/zabbix1/etc/zabbix/externalscripts/$3
ARGS=$4 $5 $6 $7 $8 $9 # need improvment
execquery
Comment