Quantcast
Channel: Informix Fun Facts
Viewing all articles
Browse latest Browse all 15

Ensuring logical logs do not get to old.

$
0
0

If a user wants to ensure a log is closed after a specific duration, the following procedure and database scheduler task will accomplish this task.

  1. Check to see how old the current logical logs is
  2. If older than a specified interval then
  3. Switch to a new logical log
  4. Put a message in the alert system
DROP FUNCTION IF EXISTS max_log_duration(INTEGER, INTEGER);
CREATE FUNCTION informix.max_log_duration(task_id INTEGER, task_seq INTEGER)
   RETURNING INTEGER
 DEFINE value    INTEGER;
 DEFINE ret      INTEGER;

    LET ret = 0;
    SELECT CASE 
        WHEN dbinfo('UTC_TO_DATETIME',filltime) < CURRENT - tk_frequency                  THEN uniqid                  ELSE 0                  END          INTO value          FROM sysmaster:syslogfil L, sysadmin:ph_task          WHERE tk_name = "max_log_duration"          AND uniqid = (SELECT MAX(uniqid) FROM sysmaster:syslogfil                        WHERE bitand(flags, '0x2') = 0);    IF value > 0 THEN
       LET ret = sysadmin:admin('onmode','l');
       INSERT INTO ph_alert
              (ID, alert_task_id,alert_task_seq,alert_type,
               alert_color, alert_object_type,
               alert_object_name, alert_message,alert_action)
       VALUES
              (0,task_id, task_seq, "INFO", "GREEN",
              "SERVER","Logical Logs", 
              "Logical log "||value||" was idle too long, "||
              "switch to new log. command_id = "||ret,
                NULL);
   END IF

  return ret;

END FUNCTION;
DATABASE sysadmin;

DELETE FROM ph_task where tk_name = "max_log_duration";
INSERT INTO ph_task
(
tk_name,
tk_type,
tk_group,
tk_description,
tk_execute,
tk_start_time,
tk_stop_time,
tk_frequency
)
VALUES
(
"max_log_duration",
"TASK",
"TABLES",
"Ensure a logical log can not be current for more than a duration",
"max_log_duration",
NULL,
NULL,
INTERVAL ( 15 ) MINUTE TO MINUTE
);

Viewing all articles
Browse latest Browse all 15

Trending Articles