Description:
The logrotate sample below seems to suggest that sending the agent a HUP will make it close and reopen the log file:
http://dev.mysql.com/doc/mysql-monitor/2.2/en/mem-agent-log-and-pid-files.html
However, the agent will only create the new file when it has something to write to it. With less verbose log-level (the default) this can take a while, leaving the user wondering what happened to mysql-monitor-agent.log
How to repeat:
shell> mv /opt/mysql/enterprise/agent/mysql-monitor-agent.log /opt/mysql/enterprise/agent/mysql-monitor-agent.OLD
shell> ll /opt/mysql/enterprise/agent/
drwxr-xr-x 2 root root 4.0K May 31 21:02 bin
-rw------- 1 root root 2.6K May 31 21:02 configuration_report.txt
drwxr-xr-x 4 root root 4.0K Jul 21 18:26 etc
drwxr-xr-x 2 root root 4.0K May 31 21:02 include
drwxr-xr-x 6 root root 4.0K May 31 21:02 lib
drwxr-xr-x 2 root root 4.0K May 31 21:02 libexec
drwxrwxr-x 2 root root 4.0K May 31 21:02 licenses
-rw-r----- 1 root root 346 Aug 3 13:25 mysql-monitor-agent.OLD
-rw------- 1 root root 4 Aug 3 13:25 mysql-monitor-agent.pid
drwxr-xr-x 9 root root 4.0K May 31 21:02 patchbackup
-rw-r--r-- 1 root root 0 Jun 16 19:27 ram
drwxr-xr-x 4 root root 4.0K May 31 21:02 share
-rwx------ 1 root root 3.8M May 31 21:02 uninstall
shell> kill -HUP $(cat /opt/mysql/enterprise/agent/mysql-monitor-agent.pid)
I would expect a new ysql-monitor-agent.log file to exist, even if it's size was zero:
shell> ll /opt/mysql/enterprise/agent/
drwxr-xr-x 2 root root 4.0K May 31 21:02 bin
-rw------- 1 root root 2.6K May 31 21:02 configuration_report.txt
drwxr-xr-x 4 root root 4.0K Jul 21 18:26 etc
drwxr-xr-x 2 root root 4.0K May 31 21:02 include
drwxr-xr-x 6 root root 4.0K May 31 21:02 lib
drwxr-xr-x 2 root root 4.0K May 31 21:02 libexec
drwxrwxr-x 2 root root 4.0K May 31 21:02 licenses
-rw-r----- 1 root root 346 Aug 3 13:25 mysql-monitor-agent.OLD
-rw------- 1 root root 4 Aug 3 13:25 mysql-monitor-agent.pid
drwxr-xr-x 9 root root 4.0K May 31 21:02 patchbackup
-rw-r--r-- 1 root root 0 Jun 16 19:27 ram
drwxr-xr-x 4 root root 4.0K May 31 21:02 share
-rwx------ 1 root root 3.8M May 31 21:02 uninstall
This works fine if I set log-level=debug in the agent .ini file as it immediately grows to a few hundred Kb.
Suggested fix:
Create the new mysql-monitor-agent.log after receiving the HUP without needing to wait on the first log entry, avoiding confusing users, who think it never reopened the file.