2009-12-02 41 views
4

我正在尋找一種工具來監視定期運行的SQL查詢的結果,並根據查詢返回任何結果提出通知。 (歡迎任何其他過濾器)用於監視SQL查詢結果所需的工具

我需要觀察事務表中是否有錯誤,如果我的SQL查詢可以在後臺運行,定期刷新本身並在出現任何結果時顯示通知,那將非常好。

我需要連接到Oracle數據庫,我目前使用PL/SQL Developer或Oracle SQL Developer。

免費,OS和輕量化解決方案首選:)

UPDATE:

最好我想不創建/修改任何數據庫對象。我們也想在我們的客戶數據庫上使用它,並不是所有人都有許可修改其Oracle應用程序運行的數據庫。

謝謝您提前

+0

你想怎麼通知?電子郵件?短信?消息框在屏幕上? – APC 2009-12-02 10:56:15

+0

http://no0p.github.io/postgresql/2014/10/21/postgresql-monitoring-framework.html plus http://oss.oetiker.ch/rrdtool/gallery/index.en.html – 2016-02-08 10:56:24

+0

畢竟這些年,如果我可以問,你是如何最終解決它的? – kmonsoor 2018-01-24 16:35:09

回答

0

將查詢放入存儲過程。在那裏有你的監測/通知代碼。

3

如何使用DBMS_Scheduler運行查詢表的存儲過程,然後在發生問題時使用UTL_Mail發送電子郵件?

0

我使用這個,它工作得很好。

- 1.創建計劃:

BEGIN 
DBMS_SCHEDULER.CREATE_PROGRAM(
     program_name=>'user.TABLESPACE_MANAGEMENT', 
     program_action=>'begin 
     EXECUTE IMMEDIATE 
'CREATE TABLE IDLE_TIME_TABLE 
LOGGING 
NOCOMPRESS 
NOCACHE 
NOPARALLEL 
MONITORING 
AS 
SELECT DISTINCT 
      SID, 
      OSUSER, 
      USERNAME, 
      STATUS, 
      TO_CHAR(LOGON_TIME, ''DDth DAY HH24:MI:SS'') LOGON_TIME, 
      FLOOR(LAST_CALL_ET/3600)||'':''|| FLOOR(MOD(LAST_CALL_ET,3600)/60)||'':''||MOD(MOD(LAST_CALL_ET,3600),60) IDLE, 
      PROGRAM 
FROM V$SESSION 
WHERE USERNAME IS NOT NULL 
AND STATUS = ''INACTIVE'' 
ORDER BY IDLE DESC', 
     program_type=>'PLSQL_BLOCK', 
     number_of_arguments=>0, 
     comments=>'TABLESPACE MANAGEMENT CREATES A TABLE CALLED TABLESPACE_MANAGEMNT ON DAILY BASIS', 
     enabled=>TRUE); 
END; 

- 2.創建一個日程安排程序:

BEGIN 
    sys.dbms_scheduler.create_schedule( 
     repeat_interval => 
     'FREQ=DAILY; BYDAY=MON,TUE,WED,THU,FRI; BYHOUR=22; BYMINUTE=0; BYSECOND=0;', 
     start_date => 
     to_timestamp_tz('2011-07-26 US/Eastern', 'YYYY-MM-DD TZR'), 
     comments => 
     'Schedule for what ever u want', 
     schedule_name => '"user"."TABLESPACE_MANAGEMENT_SCHEDULE"'); 
END; 

--3。最後同時連結在一起,創建一個作業:

BEGIN 
    sys.dbms_scheduler.create_job( 
     job_name => '"user"."SPACE"', 
     program_name => 'user.TABLESPACE_MANAGEMENT', 
     schedule_name => 'user.TABLESPACE_MANAGEMENT_SCHEDULE', 
     job_class => 'DEFAULT_JOB_CLASS', 
     comments => 'TABLESPCE_MANAGEMENT', 
     auto_drop => FALSE, 
     enabled => TRUE); 
END; 

現在你可以使用類似utl_mail.send

begin 
UTL_MAIL.SEND_ATTACH_VARCHAR2 
(
     sender => '[email protected]' 
     ,recipients => '[email protected],[email protected],[email protected],[email protected]' 
     ,cc => NULL 
     ,bcc => NULL 
     ,subject => 'send_attach_varchar2' 
     ,message => 'here is a test of send_attach_varchar2' 
     ,mime_type => 'text/plain; charset=us-ascii' 
     ,priority => 3 
     ,attachment => '<html> 
             <head> 
              <title>Test HTML message</title> 
             </head> 
             <body> 
              <p>This is a <b>HTML</b> <i>version</i> of the test message.</p> 
              <p><img src="http://whatever/images/site_logo.gif" alt="Site Logo" /> 
             </body> 
             </html>' 
     ,att_inline => TRUE 
     ,att_mime_type=>'application/html' 
     ,att_filename => 'cartesien.html' 
    );