Skip to content

Instantly share code, notes, and snippets.

@yoshikaw
Last active August 29, 2015 14:05
Show Gist options
  • Save yoshikaw/8f1b359485ec11174e5a to your computer and use it in GitHub Desktop.
Save yoshikaw/8f1b359485ec11174e5a to your computer and use it in GitHub Desktop.
#!/bin/bash
#
(
echo "conn scott/tiger"
echo "set timi off time off sqlp \"\" feed off lines 9999 trims on tab off"
echo "set numformat 999999999999999999999999999999"
while :
do
t=$(date +'%DT%T')
echo "SELECT '${t:0:8}' as logged_date, '${t:9}' as logged_time,db_time,db_cpu,bg_time,bg_cpu FROM (SELECT stat_name,value FROM v\$sys
_time_model) PIVOT (MAX(value) FOR stat_name IN ('DB time' AS db_time,'DB CPU' AS db_cpu,'background elapsed time' AS bg_time,'backgroun
d cpu time' AS bg_cpu));"
echo "set head off newp none"
sleep ${SLEEP:-10}
done
) | sqlplus /nolog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment