前幾天打算基於tcf實現一個lttng control程序,所以完成了tcf-agent service開發例子git
1. 下載tcf-agent:http://git.eclipse.org/c/tcf/org.eclipse.tcf.agent.gitapi
git://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git |
ssh://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git |
http://git.eclipse.org/gitroot/tcf/org.eclipse.tcf.agent.git |
2. 建立一個project目錄,放在tcf-agent源代碼目錄下,eclipse
例如,拷貝example目錄下的daytime項目,而後在上面進行修改。ssh
2.1 首先是項目名字:例如daytime --->hello_service函數
2.2 修改Makefile文件:TCF_AGENT_DIR=../../agent ---->TCF_AGENT_DIR=../agentip
2.3 修改hello_service/tcf/main/services-ext.h開發
#include <tcf/services/daytime.h>
static void ini_ext_services(Protocol * proto, TCFBroadcastGroup * bcg) {
ini_daytime_service(proto); ------> 修改或增長外部services
}get
2.4 增長外部的service源碼文件,參考daytime.c和daytime.h.源碼
2.4.1 增長command,調用tcf-agent api函數 add_command_handler()it
例如: add_command_handler(proto, DAYTIME, "getTimeOfDay", command_get_time_of_day);
proto是協議;DAYTIME是service名字,"getTimeOfDay"是命令,command_get_time_of_day是命令處理函數。
3 編譯
在hellow_service目錄下:make
會在hellow_service目錄下生成一個obj的目錄
4 運行: ./obj/GNU/Linux/i686/Debug/agent