Skip to content

Commit

Permalink
Applying PR feedback
Browse files Browse the repository at this point in the history
- Linked to varnish in input README
- Updated README/CHANGELOG
- Cleaned up sampleConfig to remove formatting
- Shorted lines to 80 chars (except where test input requires long strings)
- Using internal.RunTimeout to wrap call to varnishtat
- Added dummy file for windows
  • Loading branch information
robinpercy-xm committed May 22, 2016
1 parent cd4dbf6 commit 895987f
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 20 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Features

- [#1173](https://github.com/influxdata/telegraf/pull/1173): varnish input plugin. Thanks @sfox-xmatters!
- [#1138](https://github.com/influxdata/telegraf/pull/1138): nstat input plugin. Thanks @Maksadbek!
- [#1139](https://github.com/influxdata/telegraf/pull/1139): instrumental output plugin. Thanks @jasonroelofs!
- [#1172](https://github.com/influxdata/telegraf/pull/1172): Ceph storage stats. Thanks @robinpercy!
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ Currently implemented sources:
* [snmp](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/snmp)
* [sql server](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/sqlserver) (microsoft)
* [twemproxy](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/twemproxy)
* [varnish](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/varnish)
* [zfs](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/zfs)
* [zookeeper](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/zookeeper)
* [win_perf_counters ](https://github.com/influxdata/telegraf/tree/master/plugins/inputs/win_perf_counters) (windows performance counters)
Expand Down
20 changes: 10 additions & 10 deletions plugins/inputs/varnish/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Varnish Input Plugin

This plugin gathers stats from Varnish HTTP Cache
This plugin gathers stats from [Varnish HTTP Cache](https://varnish-cache.org/)

### Configuration:

```toml
# # A plugin to collect stats from Varnish HTTP Cache
# [[inputs.varnish]]
# ## The default location of the varnishstat binary can be overridden with:
# binary = "/usr/bin/varnishstat"
#
# ## By default, telegraf gather stats for 3 metric points.
# ## Setting stats will override the defaults (["MAIN.cache_hit","MAIN.cache_miss","MAIN.uptime"]).
# ## stats may also be set to ["all"], which will collect all stats
# stats = ["MAIN.cache_hit","MAIN.cache_miss","MAIN.uptime"]
# A plugin to collect stats from Varnish HTTP Cache
[[inputs.varnish]]
## The default location of the varnishstat binary can be overridden with:
binary = "/usr/bin/varnishstat"

## By default, telegraf gathers stats for 3 metric points.
## Setting stats will override the defaults shown below.
## stats may also be set to ["all"], which will collect all stats
stats = ["MAIN.cache_hit", "MAIN.cache_miss", "MAIN.uptime"]
```

### Measurements & Fields:
Expand Down
12 changes: 7 additions & 5 deletions plugins/inputs/varnish/varnish.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package varnish
// +build !windows

// varnish.go
package varnish

import (
"bufio"
Expand All @@ -13,6 +13,8 @@ import (

"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs"
"github.com/influxdata/telegraf/internal"
"time"
)

const (
Expand All @@ -33,9 +35,9 @@ var varnishSampleConfig = `
binary = "/usr/bin/varnishstat"
## By default, telegraf gather stats for 3 metric points.
## Setting stats will override the defaults (["%s"]).
## Setting stats will override the defaults shown below.
## stats may also be set to ["all"], which will collect all stats
stats = ["%[1]s"]
stats = ["MAIN.cache_hit", "MAIN.cache_miss", "MAIN.uptime"]
`

func (s *Varnish) Description() string {
Expand Down Expand Up @@ -87,7 +89,7 @@ var varnishStat = func(cmdName string) (*bytes.Buffer, error) {
cmd := exec.Command(cmdName, cmdArgs...)
var out bytes.Buffer
cmd.Stdout = &out
err := cmd.Run()
err := internal.RunTimeout(cmd, time.Millisecond*200)
if err != nil {
return &out, fmt.Errorf("error running varnishstat: %s", err)
}
Expand Down
12 changes: 7 additions & 5 deletions plugins/inputs/varnish/varnish_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// +build !windows

package varnish

import (
Expand Down Expand Up @@ -119,11 +121,11 @@ var smOutput = `
MAIN.uptime 895 1.00 Child process uptime
MAIN.cache_hit 95 0.00 Cache hits
MAIN.cache_miss 5 0.00 Cache misses
MGT.uptime 896 1.00 Management process uptime
MGT.child_start 1 0.00 Child process started
MEMPOOL.vbc.live 0 . In use
MEMPOOL.vbc.pool 10 . In Pool
MEMPOOL.vbc.sz_wanted 88 . Size requested
MGT.uptime 896 1.00 Management process uptime
MGT.child_start 1 0.00 Child process started
MEMPOOL.vbc.live 0 . In use
MEMPOOL.vbc.pool 10 . In Pool
MEMPOOL.vbc.sz_wanted 88 . Size requested
`

var parsedSmOutput = map[string]map[string]interface{}{
Expand Down
3 changes: 3 additions & 0 deletions plugins/inputs/varnish/varnish_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// +build windows

package varnish

0 comments on commit 895987f

Please sign in to comment.