# 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**
**简介**
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是运行在你主机上的一款轻量级软件。它的作用就是忠心耿耿的为你收集event和metrics,传到Datadog中,以便你可以利用这些监控和运行数据来做点什么。
The source code for the Datadog Agent can be [foundhere](https://github.com/DataDog/dd-agent).
[戳这里](https://github.com/DataDog/dd-agent)获得DatadogAgent的源代码。
![enter image description here](http://help.datadoghq.com/hc/en-us/article_attachments/202186415/Agent_Architecture_-_B.jpg)
**Agent Architecture**
**Datadog Agent的架构**
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主要由四个用Python编写的组件构成,每个组件都是单独运行的进程。
- Collector(agent.py)--无论你的agent是如何组建的,Collector都会去检查当前运行的机器,抓取系统metrics,如内存和CPU数据。
-Dogstatsd(dogstatsd.py)--这是StatsD的后台服务器,它致力于收集从你代码中发送出去的本地metrics。
- Forwarder(ddagent.py)--Forwarder负责把Dogstatsd和Collector收集到的数据推到一个队列中,这些数据将会被发往Datadog。
- SupervisorD --由一个单独的[管理进程](http://supervisord.org/)控制。我们把它与其他的组件分隔开来,因此如果你因为担心资源消耗而不想运行所有组件的话(虽然我们建议你这么做),那么你可以单独运行它。
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-).
学习如何在现有基础上,扩展agent的检查内容,或者编写一套自己的版本,[请戳这里](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的资源消耗大致如下:
-常驻内存:50MB
- CPU时间:平均小于1%
-硬盘空间:
Linux:120MB
Windows:60MB
-带宽占用:每分钟10-50 KB
The stats listed above are based on an EC2 m1.large instancerunning for 10+ days.
上述数据基于一个运行了十多天的EC2 m1.large实例。
Supervision, Privileges and Network Ports
监控、权限和网络端口
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作为一个主控根进程运行,可以fork所有的子进程如userdd-agent,其配置文件在/etc/dd-agent/datadog.conf和/etc/dd-agent/conf.d下可以找到。所有的配置对dd-agent来说都必须可读。推荐使用权限0600,因为配置文件中包含你的APIkey,以及其它访问metrics(如mysql,postgresqlmetrics)所需的证书。
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
以下端口对一般操作开放:
-为一般操作提供的forwarder tcp/17123端口和启用了graphite服务时的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或以上版本中,所有监听进程都默认绑定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.
关于如果通过代理运行agent,[请戳这里](http://help.datadoghq.com/hc/en-us/articles/203765295);关于允许的范围,[请看这里](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也支持运行基于python的用户定义的检查内容。这些内容应存储于/etc/dd-agent/checks.d下。用户定义的检查内容必须从抽象类AgentCheck继承,这个类定义在[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监听并缓存进来的HTTP请求,接着通过HTTPS转发到Datadog中心。缓存请求使得网络可以一分为二,不影响metrics的上报。Metrics将被缓存在内存中,直到达到必须发送的大小或数目。接着,最老的数据包就会被丢弃,以此确保forwarder有足够的存储空间。
**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实现的[estystatsD](https://github.com/etsy/statsd) metric整合进程,用于通过UDP协议接收和积累任意的metrics,这样我们就可以度量自定义代码,而不会增加延迟。
Learn more about[dogstatsd](http://help.datadoghq.com/hc/en-us/articles/203765485-How-do-I-submit-custom-metrics-What-s-their-overhead-).
关于dgostatsd的更多信息[请看这里](http://help.datadoghq.com/hc/en-us/articles/203765485-How-do-I-submit-custom-metrics-What-s-their-overhead-)。
**Agent Benefits**
**Agent的优点**
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��