This is a short tutorial on the features implemented in HoneyMonitor for the use and administration of Scheduled Events . It could be useful for Users who are new to the product and want to get start with it or to whom want to learn the basis of Scheduled Events in MySQL? 5.1
More details on the HoneyMonitor Reference Manual at http://www.honeysoftware.com/honeymonitor/doc.
Scheduled Events have been added in MySQL? v.5.1.6.
An Event is a named database object containing one or more SQL statements to be executed at one or more regular intervals, beginning and ending at a specific date and time. Scheduled tasks of this type are also sometimes known as ?temporal triggers?, implying that these are objects that are triggered by the passage of time.
An Event can be enabled or disabled (there is also a third state: disabled on slave); if disabled the event is still present in the database but it is not executed.
For more information about Events, please visit http://dev.mysql.com/doc/refman/5.1/en/events.html
In HoneyMonitor, Events of a specific database are listed in the Server Objects List (Fig. 1)
Fig. 1: Server Objects List - Events
For more information about the Server Objects List, please refer to this post.
HoneyMonitor includes a Scheduled Event Editor (Fig. 2) that allow you to create, alter, rename and drop your Events.
Fig. 2: The Scheduled Event Editor
Let’s see how to use it.
No special privileges are required to use this Editor as HoneyMonitor retrieves the data it need from the information_schema database (it is not necessary that users have privileges on the mysql database). By the way, note that there is a privilege that govern the creation, modification, and deletion of events, the EVENT privilege.
I used some queries similar to the following to create a database and a user to test the Scheduled Event Editor:
CREATE DATABASE `sleto`;
CREATE USER ’sleto’@'localhost’;
FLUSH PRIVILEGES;
GRANT USAGE ON *.* TO ’sleto’@'localhost’ REQUIRE NONE;
FLUSH PRIVILEGES;
GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,REFERENCES,INDEX,ALTER,CREATE TEMPORARY TABLES,LOCK TABLES,CREATE VIEW,SHOW VIEW,CREATE ROUTINE,ALTER ROUTINE,EXECUTE,EVENT,TRIGGER ON `sleto`.* TO ’sleto’@'localhost’;
FLUSH PRIVILEGES;
Events are executed by a special event scheduler thread; the global event_scheduler system variable determines whether the Event Scheduler is enabled and running on the server. If you don’t know the value of this variable ? or if you don’t know that such a variable exists ? don’t worry: look at the status-bar of the Editor, and click on it to enable the Event Scheduler (Fig. 3).
Fig. 3: Event Scheduler - ON | OFF
Try to ask your system administration if you haven’t the right privileges to perform this operation.
Let’s suppose that the Event Scheduler is running (ON) and let’s create our first Event by filling the required information on the Editor’s Tabs and clicking on the ‘Save’ button.
The ”Performed Action” Tab (Fig. 4) allows you to edit the event statement, i.e. the specific action performed by the event.
Fig. 4: Event Editor - Performed Action
The ”Advanced” Tab (Fig. 5) allows you to set the event properties.
Fig. 5: Event Editor - Advanced
There are two type of event:
The ”Schedule details” frame changes according to the type of the event that is opened in the Events Editor (you can choose the event type using the ”Schedule form” combo).
When creating a new event, you may click on the ”if not exist” check to prevent an error if the event already exists.
The ”Comment” Tab (Fig. 6) allows you to set the event comment.
Fig. 6: Event Editor - Comment
The ”SQL” Tab (Fig. 7) contains the SQL syntax for recreating the current event. This tab will be enabled only after the Event creation.
Fig. 7: Event Editor - SQL
There are other ways to create an Event in HoneyMonitor. For instance, you can open the Script Editor and create the Event writing and executing a SQL query. You can also use the command builder if you don’t remember exactly the syntax (Fig. 8)
Fig. 8: Script Editor - Writing the syntax for Event’s creation
You can open an Event in the Event Editor to enable / disable it or change some of its properties (and rename it as well). You can see also some metadata like the creation date (Fig 9).
Fig. 9: Event Editor - Editing an Event
Is there a way to know if an event has been executed successfully?
Sure. You can check the Server Error Log. To do this in HoneyMonitor, open the Server Logs Management Window. You can also click on the button ?Print Debug Information? to get more info - but make sure you have the right privileges to perform this operation - (Fig. 10).
Fig. 10: Server Logs Management - Error Log
HoneyMonitor allows you to choose your preferred way to perform a particular task: you choose the way you prefer.
Below you find some possible solutions:
Open the Server Properties Window and go to the Tab ?Variables?;
Use the Metadata Catalog (Global Variables visualization);
Open the Performance Tuning Monitor and go to the Tab ?Variables?;
Open the Event Editor and check its status bar;
Open the Script Editor and create and execute a one-line script which contains the query ?SHOW VARIABLES LIKE ‘event_scheduler’;?
Click on the Utility / MySQL Command Line Client menu to open a command line client and execute the query ?SHOW VARIABLES LIKE ‘event_scheduler’?;
Do you want to know/edit the value of the variable event_scheduler (or other variable) but you don’t remember the Type, the Handle and the Description of that variable?
Open the Server Properties Window and go to the Tab ?Variables? (Fig. 11) to see those information!
Fig. 11: Server Properties Window - Variables’ List
The source of metadata for a Scheduled Event is the table information_schema.events (Fig. 12).
Fig. 12: Event Metadata
If you want to learn more on HoneyMonitor please visit the Project Home Page, at http://www.honeysoftware.com/honeymonitor, or check out one of the following resources:
Santo Leto is a two years experience MySQL? DBA and Developer.
Leader and main programmer of the HoneyMonitor Project, he graduated in physics and he lives in Italy, where he works from home.