自動生成ASH報告指令碼

shawnloong發表於2016-08-22

點選(此處)摺疊或開啟

  1. ###################################################################
  2. ## Script:genash.sh      ##
  3. ## Date:2016-08-22 ##
  4. ## Description:del gen ash report and sendport ##
  5. ###################################################################
  6. #!/bin/bash
  7. source /home/oracle/.bash_profile
  8. #if [ $# != 6 ]
  9. #then
  10. #!echo Syntax genash.sh dbid '01/30/11 11:00' duration credentials inst sid
  11. #exit 1
  12. #fi

  13. REMOTE_HOST=10.1.1.1
  14. REMOTE_DIR=/scripts/dbstatus/
  15. REMOTE_USER=access_user
  16. REMOTE_COMMAND="/scripts/sendash.py"
  17. l_dbid=1418194933
  18. l_start_time=`date -d '-3 hours' '+%m/%d/%y %H:%M'`
  19. #l_starttime_log=`echo $l_start_time|sed 's////g' | sed 's/ //'|sed 's/://'`
  20. l_duration=180
  21. l_credentials="dba_monitor/passwd"
  22. l_inst=1
  23. l_sid=$6
  24. l_logdir='/u01/script/awr'
  25. l_ash_log_file=${l_logdir}/ashrpt.html
  26.  
  27. sqlplus -s $l_credentials <<EOC > /tmp/ash.log
  28.  
  29. set head off
  30. set pages 0
  31. set lines 132
  32. set echo off
  33. set feedback off
  34. set termout off
  35.  
  36. define inst_num=${l_inst};
  37. define dbid=${l_dbid};
  38. define report_type='html';
  39. define report_name=${l_ash_log_file};
  40. define begin_time="${l_start_time}";
  41. define duration=${l_duration};
  42. --define target_session_id = ${l_sid};
  43. define target_session_id = '';
  44.  
  45. define slot_width = '';
  46. define target_sql_id     = '';
  47. define target_wait_class = '';
  48. define target_service_hash = '';
  49. define target_module_name = '';
  50. define target_action_name = '';
  51. define target_client_id    = '';
  52. define target_plsql_entry = '';
  53.  
  54. @$ORACLE_HOME/rdbms/admin/ashrpti
  55. EOC

  56. #send email to user
  57. scp ${l_logdir}/ashrpt.html "$REMOTE_USER"@"$REMOTE_HOST":$REMOTE_DIR
  58. ssh $REMOTE_USER@$REMOTE_HOST $REMOTE_COMMAND

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24486203/viewspace-2123809/,如需轉載,請註明出處,否則將追究法律責任。

相關文章