This topic describes how to use the ocp_agent_ctl.py script.
Environment
After you install the software packages of OCP-Agent and OCP-Server, you can find the ocp_agent_ctl.py script in the following directories:
OCP-Server:
/home/admin/ocp-server/libOCP-Agent:
/home/admin/ocp_agentTo run the
ocp_agent_ctl.pyscript, you must have Python V2.7.5 and thepos.pyscript. Thepos.pyscript is used to perform host operations. It is included in the software packages of OCP-Agent and OCP-Server. Therefore, you can runocp_agent_ctl.pydirectly in/home/admin/ocp-server/libor/home/admin/ocp_agent.Note
- If you need to copy
ocp_agent_ctl.pyto another directory for running, you must copy/home/admin/ocp-server/lib/pos.pyor/home/admin/ocp_agent/agent/pos.pyto the same directory. - The script execution logs will be recorded in the
ocp_agent_ctl.logfile of the same directory. - This script can be used for the O&M of OCP-Agent on the local host. At present, it does not support remote O&M.
- If you need to copy
Command line format
python ocp_agent_ctl.py [COMMAND] [OBJECT] [OPTIONS]
COMMAND specifies an operation command, for example, start or stop.
OBJECT specifies an object to be operated on, for example, ocp_agent.
OPTIONS specifies additional options, including:
-help: This option can be simplified as "-h" and is used to query the usage help of a script.
-debug: This option prints debugging logs during script running.
Examples
Query the usage help
Run the following command to query the usage help of the script.
python ocp_agent_ctl.py -hThe usage of this script and supported operation commands are returned.
Run the following command to query the usage help of a specific command.
python ocp_agent_ctl.py start -hThe usage of the start command and applicable objects are returned.
Install OCP-Agent
Run the following command to install the OCP-Agent software package.
python ocp_agent_ctl.py install /home/admin/t-oceanbase-ocp-agent-2.4.3-1234567.alios7.x86_64.rpmRun the following command to query the installation information.
python ocp_agent_ctl.py infoThe name, version, architecture, and description of the OCP-Agent are returned.
Note
The output on Debian or Ubuntu is different from that on other operating systems.
Start OCP-Agent
Run the following command to start the ocp_agent process.
python ocp_agent_ctl.py start ocp_agentAfter you start OCP-Agent, pos_proxy, node_exporter, and ocp_exporter are also started.
Run the following command to start all service samples of OCP-Agent.
python ocp_agent_ctl.py start ocp_agent ob_monitor obproxy_monitor --ocp_site_url http://localhost:8080 --cluster_name cluster1
Stop OCP-Agent
Run the following command to stop the ocp_agent process.
python ocp_agent_ctl.py stop ocp_agentAfter you stop the ocp_agent process, pos_proxy, node_exporter, and ocp_exporter are also stopped. The host status is changed to offline and some OCP monitoring metrics will be missing.
Run the following command to stop the ob_monitor process.
python ocp_agent_ctl.py stop ob_monitorAfter you stop the ob_monitor process, obstat2, ob_logtailer, and ob_cleaner are also stopped. Top SQL, plan cache monitoring, and OceanBase log alerts will be unavailable.
Uninstall OCP-Agent
The following command is used to uninstall the OCP-Agent application and does not stop the ocp_agent process. To completely uninstall OCP-Agent, you need to manually stop the ocp_agent process.
python ocp_agent_ctl.py uninstall