# third-party-push-example **Repository Path**: gunsluo/third-party-push-example ## Basic Information - **Project Name**: third-party-push-example - **Description**: open-hawkeye open-falcon agent push example golang - **Primary Language**: Go - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2016-08-24 - **Last Updated**: 2020-12-18 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README #第三方上报采集数据Golang代码示例 ###示例代码 ```Go func main() { cfg := flag.String("c", "cfg.json", "configuration file") version := flag.Bool("v", false, "show version") flag.Parse() if *version { fmt.Println(g.VERSION) os.Exit(0) } // 获取文件的配置 2016/08/25 Add by jerrylou // 可以使用g.Init设置配置,从而不操作文件 2016/08/25 Add by jerrylou g.InitWithCfgFile(*cfg) // 开发者实现数据采集,这里是个示例 2016/08/25 Add by jerrylou funcs.BuildMappers() // 定时将采集数据发送到agent 2016/08/25 Add by jerrylou cron.Collect() select {} } ``` ###说明 - 使用[第三方公共库](http://git.oschina.net/gunsluo/hawkeye-common)方便完成采集数据上报。 - 实现自己业务的监控数据采集**funcs**模块,无需多做其他工作 - 提供了配置文件及相应的文件解析,如果你已有自己的配置文件使用g.Init() - 提供了上报采集数据定时器(**cron**),你也可以重写自己的定时器 - 提供了上报采集数据客户端(**client**),你也可以重写自己的客户端 ###数据结构 - [参考](http://git.oschina.net/gunsluo/hawkeye-common#hawkeye-common_1)