# What is the Datadog Agent? What resources does it consume?
# Datadog Agent是啥牺荠?它消耗什么資源?
原文地址:http://help.datadoghq.com/hc/en-us/articles/203034929-What-is-the-Datadog-Agent-What-resources-does-it-consume
Dustin Lawler
2015年04月18日
**Introduction**
**簡(jiǎn)介**
The Datadog Agent is lightweight piece of software that runson your hosts. Its job is to faithfully collect events and metrics and bringthem to Datadog on your behalf so that you can do something useful with yourmonitoring and performance data.
Datadog Agent是運(yùn)行在你主機(jī)上的一款輕量級(jí)軟件驴一。它的作用就是忠心耿耿的為你收集event和metrics休雌,傳到Datadog中,以便你可以利用這些監(jiān)控和運(yùn)行數(shù)據(jù)來(lái)做點(diǎn)什么蛔趴。
The source code for the Datadog Agent can be [foundhere](https://github.com/DataDog/dd-agent).
[戳這里](https://github.com/DataDog/dd-agent)獲得DatadogAgent的源代碼挑辆。

**Agent Architecture**
**Datadog Agent的架構(gòu)**
The agent is composed of 4 major components, each written inPython running as a separate process:
- Collector (agent.py) - The collector runs checks on thecurrent machine for whatever integrations you have, it captures system metricslike memory and CPU.
- Dogstatsd (dogstatsd.py) - This is a StatsD backendserver, it's responsible for aggregating local metrics sent [from yourcode](http://help.datadoghq.com/hc/en-us/articles/203765485-How-do-I-submit-custom-metrics-What-s-their-overhead-)
- Forwarder (ddagent.py) - The forwader is pushed data fromboth dogstatsd and the collector and queues it up to be sent to Datadog.
- SupervisorD This is all controlled by a single [supervisorprocess](http://supervisord.org/). We keep this separate so you don’t have tohave the overhead of each application if you don’t want to run all parts(though we generally recommend you do).
Datadog Agent主要由四個(gè)用Python編寫(xiě)的組件構(gòu)成,每個(gè)組件都是單獨(dú)運(yùn)行的進(jìn)程孝情。
- Collector(agent.py)--無(wú)論你的agent是如何組建的鱼蝉,Collector都會(huì)去檢查當(dāng)前運(yùn)行的機(jī)器,抓取系統(tǒng)metrics箫荡,如內(nèi)存和CPU數(shù)據(jù)魁亦。
-Dogstatsd(dogstatsd.py)--這是StatsD的后臺(tái)服務(wù)器,它致力于收集從你代碼中發(fā)送出去的本地metrics羔挡。
- Forwarder(ddagent.py)--Forwarder負(fù)責(zé)把Dogstatsd和Collector收集到的數(shù)據(jù)推到一個(gè)隊(duì)列中洁奈,這些數(shù)據(jù)將會(huì)被發(fā)往Datadog。
- SupervisorD --由一個(gè)單獨(dú)的[管理進(jìn)程](http://supervisord.org/)控制绞灼。我們把它與其他的組件分隔開(kāi)來(lái)利术,因此如果你因?yàn)閾?dān)心資源消耗而不想運(yùn)行所有組件的話(雖然我們建議你這么做),那么你可以單獨(dú)運(yùn)行它低矮。
To learn about extending agent checks or writing your own[see here](http://help.datadoghq.com/hc/en-us/articles/204679545-I-d-like-to-write-my-own-extend-one-of-your-integrations-to-include-additional-metrics-Is-this-possible-).
學(xué)習(xí)如何在現(xiàn)有基礎(chǔ)上印叁,擴(kuò)展agent的檢查內(nèi)容,或者編寫(xiě)一套自己的版本军掂,[請(qǐng)戳這里](http://help.datadoghq.com/hc/en-us/articles/204679545-I-d-like-to-write-my-own-extend-one-of-your-integrations-to-include-additional-metrics-Is-this-possible-)轮蜕。
**Agent Overhead**
**Datadog Agent消耗的資源**
In terms of resource consumption the Datadog agent consumesroughly:
- Resident memory (actual RAM used): 50MB
- CPU Runtime: less than 1% of averaged runtime
- Disk:
- Linux 120MB
- Windows: 60MB
- Network: 10-50 KB of bandwidth per minute
Datadog Agent的資源消耗大致如下:
-常駐內(nèi)存:50MB
- CPU時(shí)間:平均小于1%
-硬盤空間:
Linux:120MB
Windows:60MB
-帶寬占用:每分鐘10-50 KB
The stats listed above are based on an EC2 m1.large instancerunning for 10+ days.
上述數(shù)據(jù)基于一個(gè)運(yùn)行了十多天的EC2 m1.large實(shí)例。
Supervision, Privileges and Network Ports
監(jiān)控蝗锥、權(quán)限和網(wǎng)絡(luò)端口
Supervisord runs a master process as root and forks allsubprocesses as the user dd-agent. The agent configuration resides at/etc/dd-agent/datadog.conf and /etc/dd-agent/conf.d. All configuration must bereadable by dd-agent. The recommended permissions are 0600 since configurationfiles contain your API key and other credentials needed to access metrics (e.g.mysql, postgresql metrics).
Supervisord作為一個(gè)主控根進(jìn)程運(yùn)行跃洛,可以fork所有的子進(jìn)程如userdd-agent,其配置文件在/etc/dd-agent/datadog.conf和/etc/dd-agent/conf.d下可以找到终议。所有的配置對(duì)dd-agent來(lái)說(shuō)都必須可讀汇竭。推薦使用權(quán)限0600,因?yàn)榕渲梦募邪愕腁PIkey穴张,以及其它訪問(wèn)metrics(如mysql细燎,postgresqlmetrics)所需的證書(shū)。
The following ports are open for normal operations:
- forwarder tcp/17123for normal operations and tcp/17124 if graphite support is turned on
- dogstatsd udp/8125
以下端口對(duì)一般操作開(kāi)放:
-為一般操作提供的forwarder tcp/17123端口和啟用了graphite服務(wù)時(shí)的tcp/17124端口
- dogstatsd udp/8125
All listening processes are bound by default to 127.0.0.1and/or ::1 on v 3.4.1 and greater of the agent. In earlier versions, they werebound to 0.0.0.0 (i.e. all interfaces).
在3.4.1或以上版本中陆馁,所有監(jiān)聽(tīng)進(jìn)程都默認(rèn)綁定127.0.0.1和/或者::1找颓。而早期版本中合愈,他們則綁定0.0.0.0(例如所有的接口)叮贩。
For information on running the Agent through a proxy pleasesee here; for which ranges to allow, see here.
關(guān)于如果通過(guò)代理運(yùn)行agent击狮,[請(qǐng)戳這里](http://help.datadoghq.com/hc/en-us/articles/203765295);關(guān)于允許的范圍益老,[請(qǐng)看這里](http://help.datadoghq.com/hc/en-us/articles/203037979)彪蓬。
**The Collector**
This is where all standard metrics are gathered, every 15seconds.
The collector also supports the execution of python-based,user-provided checks, stored in /etc/dd-agent/checks.d. User-provided checksmust inherit from the AgentCheck abstract class defined inc[hecks/init.py](https://github.com/DataDog/dd-agent/blob/master/checks/__init__.py).
**Collector**
這是收集所有metrics的地方,每十五秒收集一次捺萌。
Collector也支持運(yùn)行基于python的用戶定義的檢查內(nèi)容档冬。這些內(nèi)容應(yīng)存儲(chǔ)于/etc/dd-agent/checks.d下。用戶定義的檢查內(nèi)容必須從抽象類AgentCheck繼承桃纯,這個(gè)類定義在[checks/init.py](https://github.com/DataDog/dd-agent/blob/master/checks/__init__.py)中酷誓。
**The Forwarder**
The forwarder listens over HTTP for incoming requests tobuffer and forward over HTTPS to Datadog HQ. Bufferring allows for networksplits to not affect metric reporting. Metrics will be buffered in memory untila limit in size or number of outstanding requests to send is reached.Afterwards the oldest metrics will be discarded to keep the forwarder's memoryfootprint manageable.
**Forwarder**
Forwarder監(jiān)聽(tīng)并緩存進(jìn)來(lái)的HTTP請(qǐng)求,接著通過(guò)HTTPS轉(zhuǎn)發(fā)到Datadog中心态坦。緩存請(qǐng)求使得網(wǎng)絡(luò)可以一分為二盐数,不影響metrics的上報(bào)。Metrics將被緩存在內(nèi)存中伞梯,直到達(dá)到必須發(fā)送的大小或數(shù)目玫氢。接著,最老的數(shù)據(jù)包就會(huì)被丟棄谜诫,以此確保forwarder有足夠的存儲(chǔ)空間漾峡。
**DogStatsD**
DogStatsD is a python implementation of [etsy'sstatsD](https://github.com/etsy/statsd) metric aggregation daemon. It is usedto receive and roll up arbitrary metrics over UDP, thus allowing custom code tobe instrumented without adding latency to the mix.
Learn more about dogstatsd.
**DogStatsD**
DogStatsD是用python實(shí)現(xiàn)的[estystatsD](https://github.com/etsy/statsd) metric整合進(jìn)程,用于通過(guò)UDP協(xié)議接收和積累任意的metrics喻旷,這樣我們就可以度量自定義代碼生逸,而不會(huì)增加延遲。
Learn more about[dogstatsd](http://help.datadoghq.com/hc/en-us/articles/203765485-How-do-I-submit-custom-metrics-What-s-their-overhead-).
關(guān)于dgostatsd的更多信息[請(qǐng)看這里](http://help.datadoghq.com/hc/en-us/articles/203765485-How-do-I-submit-custom-metrics-What-s-their-overhead-)掰邢。
**Agent Benefits**
**Agent的優(yōu)點(diǎn)**
To understand the value of using the Datadog agent,reference the following articles:
- https://www.datadoghq.com/2013/10/dont-fear-the-agent/
- http://dtdg.co/1J03U0V
想要了解使用Datadog agent究竟有什么好處牺陶,可以參考下面的兩篇文章:
- https://www.datadoghq.com/2013/10/dont-fear-the-agent/
- http://dtdg.co/1J03U0V
???s??