5.3.5.2 Starting/Stopping the Agent on Mac OS X

Using launchd

The preferred method is to use launchd to load the agent as a service. Enabling the service during the agent installation will automatically add the mysql-monitor-agent service at startup via launchd, but the following commands also work:

To start (load) the agent:

shell> sudo launchctl load /Library/LaunchDaemons/mysql.monitor.agent.plist

To stop (unload) the agent:

shell> sudo launchctl unload /Library/LaunchDaemons/mysql.monitor.agent.plist
Using init

The script to start the agent on Mac OS X is located in the /Applications/mysql/enterprise/agent/etc/init.d directory. To start the agent navigate to this directory and at the command line type:

shell> ./mysql-monitor-agent start

To stop the agent, use the stop command:

shell> ./mysql-monitor-agent stop

If the agent cannot be stopped because the pid file that contains the agent's process ID cannot be found, you can use kill to send a TERM signal to the running process:

shell> kill -TERM PID

If you run more than one agent on a specific machine, you must also specify the path to the ini file when you stop the agent. Executing mysql-monitor-agent stop without an ini file only stops the agent associated with the default ini file.

To verify that the agent is running, use the following command:

shell> ./mysql-monitor-agent status

The resulting message indicates whether the agent is running. If the agent is not running, use the following command to view the last ten entries in the agent log file:

shell> tail /Applications/mysql/enterprise/agent/log/mysql-monitor-agent.log

For further information on troubleshooting the agent, see Section 5.3.10, “Troubleshooting the Agent”.

Installation creates the directory /Applications/mysql/enterprise/agent with the settings stored in the mysql-monitor-agent.ini file located directly below this directory in the etc directory. The log directory is also located immediately below the agent directory.

To see all the command-line options available when running the monitor agent, navigate to the /Applications/mysql/enterprise/agent/etc/init.d directory and execute mysql-monitor-agent help, which displays the usage message:

Usage: ./mysql-monitor-agent {start|stop|restart|status} [ini-file-name]

The ini-file-name option is only needed if the ini file is installed somewhere other than the default location, or you renamed the ini file. Use this option if you are installing more than one agent on the same machine. Pass the full path to the ini file. For example, after navigating to the /Applications/mysql/enterprise/agent/etc/init.d directory, issue the command:

shell> ./mysql-monitor-agent start /Applications/mysql/enterprise/agent/etc/new-mysql-monitor-agent.ini

If you installed the agent as root, on reboot the mysql-monitor-agent daemon starts up automatically. If you installed the agent as an unprivileged user, you must manually start the agent on reboot or write a script to perform this task. Likewise, if you have added an additional agent as described in Section C.2.2, “MySQL Server (agent-instance.ini) Configuration”, to start this agent on reboot, create a system initialization script appropriate to your operating system. To determine whether the agent is running, navigate to the init.d directory and issue the command ./mysql-monitor-agent status.

Warning

To report its findings, the agent connects to the dashboard through the port specified during installation. The default value for this port is 18080; ensure that this port is not blocked. To troubleshoot the agent installation, see Section 5.3.10, “Troubleshooting the Agent”.