DataDog/dd-agent — pull request #281 by clutchski (2012-11-27 22:45:08+00:00)
Title: Status

This pull request is a first pass at an agent info command. Here's an example of the output it produces:

```
Collector
=========
Status date: 2012-11-27 23:36:03 (4s ago)
Version: 3.4.0
Pid: 11507
Platform: linux2
Python Version: 2.6.5

Checks
------
postgres
- instance #0 [OK]
- Collected 1 metrics & 0 events
redisdb
- instance #0 [ERROR]: ConnectionError('Error 61 connecting localhost:6379. Connection refused.',)
- instance #1 [ERROR]: ConnectionError('Error 61 connecting localhost:6380. Connection refused.',)
- Collected 0 metrics & 0 events

Emitters
------
- http_emitter [OK]

Dogstatsd
=========
Status date: 2012-11-27 23:35:58 (9s ago)
Version: 3.4.0
Pid: 11495
Platform: linux2
Python Version: 2.6.5

Flush count: 4
Packet Count: 0
Packets per second: 0.0
Metric count: 1

Forwarder
===========
Status date: 2012-11-27 23:36:03 (4s ago)
Version: 3.4.0
Pid: 11496
Platform: linux2
Python Version: 2.6.5

Queue Size: 2534
Queue Length: 1
Flush Count: 11
```

How it works:

- writes a status object on the filesystem on every flush (usually every 10-15 seconds)
- adds sigterm handlers to each process so we can exit gracefully and clean this up when we go
- adds another command called `info` that prints out a status message.
- adds an overall `info` command to `/etc/init.d/datadog-agent` that calls each process in turn.

To do:

- Oli wanted a prettier layout (colors, tables, etc) but I haven't gotten to it yet
- Add log locations once Matt has added good logging
- Add windows output.