Skip to content

Commit

Permalink
Code formatted, Readme updated based on example
Browse files Browse the repository at this point in the history
closes #695
  • Loading branch information
Andrei Burd authored and sparrc committed Feb 14, 2016
1 parent dd086c7 commit 0b72612
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ they would like to output. Currently supports: "influx" and "graphite"
- [#683](https://github.com/influxdata/telegraf/pull/683): PostGRES input plugin: add pg_stat_bgwriter. Thanks @menardorama!
- [#679](https://github.com/influxdata/telegraf/pull/679): File/stdout output plugin.
- [#679](https://github.com/influxdata/telegraf/pull/679): Support for arbitrary output data formats.
- [#695](https://github.com/influxdata/telegraf/pull/695): raindrops input plugin. Thanks @burdandrei!

### Bugfixes
- [#443](https://github.com/influxdata/telegraf/issues/443): Fix Ping command timeout parameter on Linux.
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ which would take some time to replicate.
To overcome this situation we've decided to use docker containers to provide a
fast and reproducible environment to test those services which require it.
For other situations
(i.e: https://github.com/influxdata/telegraf/blob/master/plugins/redis/redis_test.go)
(i.e: https://github.com/influxdata/telegraf/blob/master/plugins/inputs/redis/redis_test.go)
a simple mock will suffice.

To execute Telegraf tests follow these simple steps:
Expand Down
40 changes: 37 additions & 3 deletions plugins/inputs/raindrops/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,49 @@
# Raindrops Input Plugin

The [raindrops](http://raindrops.bogomips.org/) plugin reads from
specified raindops middleware URI and adds stats to InfluxDB.
specified raindops [middleware](http://raindrops.bogomips.org/Raindrops/Middleware.html) URI and adds stats to InfluxDB.

### Configuration:

```toml
# Read raindrops stats
[[inputs.raindrops]]
urls = ["http://localhost/_raindrops"]
urls = ["http://localhost:8080/_raindrops"]
```

### Measurements & Fields:

- raindrops
- calling (integer, count)
- writing (integer, count)
- raindrops_listen
- active (integer, bytes)
- queued (integer, bytes)

### Tags:

- Multiple listeners are tagged with IP:Port/Socket, ie `0.0.0.0:8080` or `/tmp/unicorn`
- Raindops calling/writing of all the workers:
- server
- port

- raindrops_listen (ip:port):
- ip
- port

- raindrops_listen (Unix Socket):
- socket

### Example Output:

```
$ ./telegraf -config telegraf.conf -input-filter raindrops -test
* Plugin: raindrops, Collection 1
> raindrops,port=8080,server=localhost calling=0i,writing=0i 1455479896806238204
> raindrops_listen,ip=0.0.0.0,port=8080 active=0i,queued=0i 1455479896806561938
> raindrops_listen,ip=0.0.0.0,port=8081 active=1i,queued=0i 1455479896806605749
> raindrops_listen,ip=127.0.0.1,port=8082 active=0i,queued=0i 1455479896806646315
> raindrops_listen,ip=0.0.0.0,port=8083 active=0i,queued=0i 1455479896806683252
> raindrops_listen,ip=0.0.0.0,port=8084 active=0i,queued=0i 1455479896806712025
> raindrops_listen,ip=0.0.0.0,port=3000 active=0i,queued=0i 1455479896806779197
> raindrops_listen,socket=/tmp/listen.me active=0i,queued=0i 1455479896806813907
```
7 changes: 3 additions & 4 deletions plugins/inputs/raindrops/raindrops.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Raindrops struct {

var sampleConfig = `
### An array of raindrops middleware URI to gather stats.
urls = ["http://localhost/_raindrops"]
urls = ["http://localhost:8080/_raindrops"]
`

func (r *Raindrops) SampleConfig() string {
Expand Down Expand Up @@ -119,7 +119,7 @@ func (r *Raindrops) gatherUrl(addr *url.URL, acc telegraf.Accumulator) error {
iterate = false
break
}
if strings.Compare(active_line_str, "\n") == 0{
if strings.Compare(active_line_str, "\n") == 0 {
break
}
queued_line_str, queued_err = buf.ReadString('\n')
Expand Down Expand Up @@ -153,8 +153,7 @@ func (r *Raindrops) gatherUrl(addr *url.URL, acc telegraf.Accumulator) error {
"socket": listen_name,
}
}
fmt.Println("raindropssock", lis, tags)
acc.AddFields("raindropssock", lis, tags)
acc.AddFields("raindrops_listen", lis, tags)
}
return nil
}
Expand Down
11 changes: 5 additions & 6 deletions plugins/inputs/raindrops/raindrops_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ func TestRaindropsGeneratesMetrics(t *testing.T) {
require.NoError(t, err)

fields := map[string]interface{}{
"calling": uint64(100),
"writing": uint64(200),
"calling": uint64(100),
"writing": uint64(200),
}
addr, err := url.Parse(ts.URL)
if err != nil {
Expand All @@ -97,12 +97,11 @@ func TestRaindropsGeneratesMetrics(t *testing.T) {

tags = map[string]string{
"port": "8081",
"ip": "0.0.0.0",
"ip": "0.0.0.0",
}
fields = map[string]interface {} {
fields = map[string]interface{}{
"active": uint64(3),
"queued": uint64(4),
}
fmt.Println("raindropssock_test", fields, tags)
acc.AssertContainsTaggedFields(t, "raindropssock", fields, tags)
acc.AssertContainsTaggedFields(t, "raindrops_listen", fields, tags)
}

0 comments on commit 0b72612

Please sign in to comment.