You can use an event handler to monitor disk space usage and notify you when available space is running low. The example in this section is especially useful for monitoring space during loads. You can enable the event handler before you start the load and disable the event handler after the load completes.
The following is sample event handler code. You can modify this code to perform other types of monitoring.
-- This event handler sends email to the database -- administrator whenever the IQ Main DBSpace is more than -- 95 percent full. -- This event handler runs every minute. The event handler uses -- sp_iqspaceused to sample the space usage. If the space is -- more than 95 percent full, a file that contains the date and -- time is created in the directory where asiqsrv12 is -- running. The file contents are then mailed to the database -- administrator and the file is removed. -- This event can be enabled before a load and be used -- to monitor disk space usage during loading. The event can -- then be disabled after the load. create event out_of_space schedule start time '1:00AM' every 1 minutes handler begin declare mt unsigned bigint; declare mu unsigned bigint; declare tt unsigned bigint; declare tu unsigned bigint; call sp_iqspaceused(mt, mu, tt, tu); if mu*100/mt > 95 then call xp_cmdshell('date > ./temp_m_file'); call xp_cmdshell('mailx -s add_main_dbspace iqdba@iqdemo.com < ./temp_m_file'); call xp_cmdshell('/bin/rm -rf ./temp_m_file'); end if if tu*100/tt > 95 then call xp_cmdshell('date > ./temp_file'); call xp_cmdshell('mailx -s add_temp_dbspace iqdba@iqdemo.com < ./temp_file'); call xp_cmdshell('/bin/rm -rf ./temp_file'); end if end
For more information on using events, see Chapter 18, “Automating Tasks Using Schedules and Events” in the Sybase IQ System Administration Guide. For details on the SQL statements that create, modify, and control events, see “CREATE EVENT statement”, “ALTER EVENT statement”, and “TRIGGER EVENT statement” in Chapter 6, “SQL Statements” of the Sybase IQ Reference Manual.