This is a module for monitoring the MySQL SQL database server error log (latest versions in the 4 series).

On UNIX type platforms, it requires the mysqltcl package (at http://www.xdobry.de/mysqltcl/) for connection via the native MySQL protocol, or the tclodbc package (at http://tclodbc.sourceforge.net/) for connection via ODBC (Open DataBase Connectivity).
On Windows platforms, please read the install.txt file.

Data is displayed in 1 table with the following columns:

- message type: new for messages that occurred during the last poll, old for messages that occurred before the last poll, top being for the most important message among the new.
- importance level of the message, the higher the value the more important the message, according to the following standard classification (from UNIX syslog): 0 (debug), 1 (info), 2 (notice), 3 (warning), 4 (error), 5 (critical), 6 (alert), 7 (emergency).
- date of latest message occurrence of its sort.
- time of latest message occurrence of its sort.
- number of occurrences of this sort of message since this module was launched.
- text of the latest message of its sort (may be empty for the top type row if there were no new messages).

Behavior:

When the module is launched, a few MySQL variables, such as the data directory, are retrieved from the server using a query. Then the server error log file is monitored for new messages, which when they appear are sorted according to their importance level and their time of occurrence. Note that all messages are regrouped according to their format and their number of occurrences displayed.

The latest messages are marked as new, with older messages from previous polls displayed with the type old, up to the maximum number of rows (see --rows option). Note that there always is a message of type top, which is the most important message among the new. This particular message row may be empty if there were no new messages during the last poll interval, which allows the administrator to set a threshold on the presence of text in the message column of the top row, in order for example to be warned by an email message containing the most important error message when it occurs.

Monitoring remote server requires remote shell functionality (using rsh or the recommended ssh), since the error log, by its nature, cannot be accessed using a SQL query.

Module options:

- --debug-file
  If you see messages with an unknown importance level (displayed as ?), please contact the author (jfontain@free.fr) so that they can be integrated in the next module release. You can use this option to specify a file (that you have rights to create) where these messages will be automatically stored. You can then attach this file to your email message to make a complete report.
  If you use this option, please also use the --whole option so that the error log file is completely scanned for unknown messsages.
- --dsn
  ODBC Data Source Name (see your database/system administrator if in doubt). In this case, the tclodbc package is used for connecting to the database. This option is incompatible with the --p (--port) option.
- -f (--file)
  The MySQL error log file path. Can be used for example on Windows platform when the database server is not local but its error log file is shared (as a network accessible file, see examples).
- -p (--port)
  Port used by the database server. 3306 is used internally if not specified.
- --user
  Database user name (defaults to current user).
- --password
  Database password for user (no default).
- -r (--remote) [[rsh|ssh]://][user@]host
  Must be specified if the database server is not running on the local host.
  There are 2 cases:
  - The -f(--file) option is used (see above), in which case only the host part is used along with the --user and --password options for connecting to the database (the protocol and user parts are ignored).
  - The -f(--file) option is not used, in which case remote login using user as logname on remote host host is used (rsh or ssh facilities must be properly setup). If user is not specified, current user is used as logname on remote host. The protocol is either ssh or rsh (used by default).
  Note: do not confuse this remote file access with the database user and password options.
- --rows
  Limits the number of rows displayed in the module table. Defaults to 10. Using a 0 value removes that limitation, which may be useful if one wants to get a summary of the database server error log (see also the --whole option).
- --whole
  If specified, the whole MySQL error log will be read and parsed initially so that all messages (up to the limit imposed by the --rows option) will be displayed when the module is launched. Be warned that using this option may result in very long start up times, depending on your processor speed and eventually the bandwidth to the remote database server.

Examples:

- View all the sorted error messages on the local server:

      $ moodss myerrorlog --whole --rows 0

- Monitor a remote UNIX server from UNIX using a secure channel:

      $ moodss myerrorlog -r ssh://dbserver.company.com --user status --password xxx

  Note that you should first check that ssh is properly configured first, so that the following command, for example, works:

      $ ssh dbserver.company.com cat /var/lib/mysql/dbserver.company.com.err

- Monitor a remote UNIX server from Windows (the dbserver value of the -r option is a putty saved configuration):

      $ moodss myerrorlog -r dbserver --user status --password xxx

  Note that you should first check that putty is properly configured first, so that the following command, for example, works:

      C:\> putty dbserver cat /var/lib/mysql/dbserver.company.com.err

- Monitor a remote Windows server from Windows using a shared error log directory:

      C:\> moodss myerrorlog --remote 192.168.0.10 --file "\\Server\mysql\data\mysql.err"

- Monitor a remote Windows server from UNIX using a shared error log directory:

      $ moodss myerrorlog --remote 192.168.0.10 --file "/mnt/mysql/mysql.err"

- Monitor a server using ODBC and rsh:

      $ moodss myerrorlog --dsn mydb --remote 192.168.0.10

You may set a threshold on the importance level column of the top row, in order for example to be warned with an email message when a critical message arrives (level greater or equal to 5).