Pages

Wednesday, May 29, 2024

crontab to monitor sar

crontab -e
59 23 * * * /software/oracle/oracle/.scripts/monitor/sar/sar_monitor.sh

sar_monitor.sh
WORK_DIR=/software/oracle/oracle/.scripts/monitor/sar
RUN_DATE=`date +"%Y%m%d"_"%H%M%S"`
DELIMITER="================="

#swap
echo ${DELIMITER} >> ${WORK_DIR}/sar_swap_usage.txt
echo "Run Date: ${RUN_DATE}" >> ${WORK_DIR}/sar_swap_usage.txt
sar -S >> ${WORK_DIR}/sar_swap_usage.txt

#memory
echo ${DELIMITER} >> ${WORK_DIR}/sar_memory_usage.txt
echo "Run Date: ${RUN_DATE}" >> ${WORK_DIR}/sar_memory_usage.txt
sar -r >> ${WORK_DIR}/sar_memory_usage.txt

#cpu
echo ${DELIMITER} >> ${WORK_DIR}/sar_cpu_usage.txt
echo "Run Date: ${RUN_DATE}" >> ${WORK_DIR}/sar_cpu_usage.txt
sar -p >> ${WORK_DIR}/sar_cpu_usage.txt

Tuesday, May 28, 2024

View Partition High value - Avoid ORA-00932: inconsistent datatypes

SELECT partition_name, TO_CHAR(high_value) 
  FROM USER_TAB_PARTITIONS
 WHERE table_name = 'SOME_PARTITIONED_TABLE';
ORA-00932: inconsistent datatypes: expected CHAR got LONG

SELECT partition_name, TO_CHAR(TO_LOB(high_value))
  FROM USER_TAB_PARTITIONS
 WHERE table_name = '
SOME_PARTITIONED_TABLE';
ORA-00932: inconsistent datatypes: expected - got LONG

The Solution would be to create a temporary table.

CREATE TABLE TEMP_PARTITION_NAMES AS 
SELECT partition_name, TO_LOB(high_value) high_value
  FROM USER_TAB_PARTITIONS
 WHERE table_name = 'SOME_PARTITIONED_TABLE';

SELECT partition_name, TO_CHAR(high_value)
  FROM TEMP_PARTITION_NAMES 
 ORDER BY TO_CHAR(high_value);

DROP TABLE TEMP_PARTITION_NAMES;