码迷,mamicode.com
首页 > 其他好文 > 详细

TCollector

时间:2014-10-15 01:22:09      阅读:378      评论:0      收藏:0      [点我收藏+]

标签:des   blog   http   io   os   使用   ar   for   strong   

TCollector

tcollector is a client-side process that gathers data from local collectors and pushes the data to OpenTSDB. You run it on all your hosts, and it does the work of sending each host‘s data to the TSD.

tcollector是client-side(客户端)进程,收集本地数据,然后推送OPenTSDB。在所有的主机上运行,然后把主机上的数据发送给TSD。

 

OpenTSDB is designed to make it easy to collect and write data to it. It has a simple protocol, simple enough for even a shell script to start sending data. However, to do so reliably and consistently is a bit harder. What do you do when your TSD server is down? How do you make sure your collectors stay running? This is where tcollector comes in.

OpenTSDB的设计目标是让数据采集以及数据存储变得更容易。其拥有简单的协议,简单得可以支持shell脚本发送数据。但是,如何做到可靠性和一致性是个比较难的事情。当TSD server故障的时候如何处理?如何确保你的collectors保持持续运行?tcollector可以做到这些。

 

Tcollector does several things for you:

  • Runs all of your data collectors and gathers their data
  • Does all of the connection management work of sending data to the TSD
  • You don‘t have to embed all of this code in every collector you write
  • Does de-duplication of repeated values
  • Handles all of the wire protocol work for you, as well as future enhancements
 Tcollector做的几件事情:
  • 运行所有的数据采集程序,并将数据收集起来
  • 做所有发送数据到TSD的连接管理工作
  • 在你自己实现的collector中无需实现这个功能
  • 对于重复的数据会做删除工作
  • 可以处理各种传输协议,包括一些增强版本

 

Deduplication

Typically you want to gather data about everything in your system. This generates a lot of datapoints, the majority of which don‘t change very often over time (if ever). However, you want fine-grained resolution when they do change. Tcollector remembers the last value and timestamp that was sent for all of the time series for all of the collectors it manages. If the value doesn‘t change between sample intervals, it suppresses sending that datapoint. Once the value does change (or 10 minutes have passed), it sends the last suppressed value and timestamp, plus the current value and timestamp. In this way all of your graphs and such are correct. Deduplication typically reduces the number of datapoints TSD needs to collect by a large fraction. This reduces network load and storage in the backend. A future OpenTSDB release however will improve on the storage format by using RLE (among other things), making it essentially free to store repeated values.

 通常情况下,你想采集系统内所有的数据。这将会产生很多的数据点,大部分的数据点在一段时间内是不会变化的。但是,当有变化的时候,你期望平滑(fine-grained solution)的解决方案。Tcollector在一次采集周期内会记录为每个collector记录最后一次值以及采集时间。如果在相同的时间间隔内,值没有变化的话,它会这个数据点暂时保存起来,不发送。一旦数据发送变化(10分钟时间过去),它将发送最后的值以及时间戳,加上当前的值和时间戳。这样的话,你的数据图就是正确的。重复数据删除会减少TSD中数据点的个数,而这些数据点是需要采集的。这样的话,会减少后端的网络开销以及存储。OpenTSD将使用RLE改善存储的格式,使更本质地解决重复数据存储问题。
 

Collecting lots of metrics with tcollector

Collectors in tcollector can be written in any language. They just need to be executable and output the data to stdout. Tcollector will handle the rest. The collectors are placed in the collectors directory. Tcollector iterates over every directory named with a number in that directory and runs all the collectors in each directory. If you name the directory 60, then tcollector will try to run every collector in that directory every 60 seconds. Use the directory 0 for any collectors that are long-lived and run continuously. Tcollector will read their output and respawn them if they die. Generally you want to write long-lived collectors since that has less overhead. OpenTSDB is designed to have lots of datapoints for each metric (for most metrics we send datapoints every 15 seconds).

If there any non-numeric named directories in the collectors directory, then they are ignored. We‘ve included a lib and etc directory for library and config data used by all collectors.

在tcollector中的Collectors可以支持任何语言。只需要它们是可执行的,并且将输出结果输出到标准输出中。Tcollector会处理这些结果。

这些collectors放在collectors目录下。Tcolletor遍历每个以数字命名的目录,然后运行每个目录下所有的collectors。如果你的目录命名为60,tcollcetor将每60s运行这个目录下每个collector。使用目录0表示是一个常住的进行,一直运行。Tcollector将读取它们的输出,如果进程挂了,tcollector将重启它。通常情况下,你想写一个常住的collecotrs,因为这样开销相对比较小。OpenTSDB设计是针对每个metric有很多数据点,对于大部分的metrics每15s发送一次数据。

如果在collectors中有不是数据命名的目录,将被忽略。同时还包括collectors使用到的lib和etc目录。

 

Installation of tcollector

You need to clone tcollector from GitHub:

git clone git://github.com/OpenTSDB/tcollector.git

and edit ‘tcollector/startstop‘ script to set following variable: TSD_HOST=dns.name.of.tsd

To avoid having to run mkmetric for every metric that tcollector tracks you can to start TSD with the --auto-metric flag. This is useful to get started quickly, but it‘s not recommended to keep this flag in the long term, to avoid accidental metric creation.

在GitHub上下载相关代码:

git clone git://github.com/OpenTSDB/tcollector.git

 

 

【参考资料】

1、http://opentsdb.net/docs/build/html/user_guide/utilities/tcollector.html

2、http://en.wikipedia.org/wiki/Wire_protocol

TCollector

标签:des   blog   http   io   os   使用   ar   for   strong   

原文地址:http://www.cnblogs.com/gsblog/p/4025482.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!