Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
cmd/scollector: change HTTPUnit.Freq to duration string
  • Loading branch information
gbrayut committed Mar 1, 2016
1 parent 0370518 commit 51a6929
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
3 changes: 0 additions & 3 deletions cmd/scollector/collectors/httpunit.go
Expand Up @@ -29,9 +29,6 @@ func HTTPUnitHiera(filename string, freq time.Duration) error {
}

func HTTPUnitPlans(name string, plans *httpunit.Plans, freq time.Duration) {
if freq < time.Second {
freq = time.Minute * 5
}
collectors = append(collectors, &IntervalCollector{
F: func() (opentsdb.MultiDataPoint, error) {
return cHTTPUnit(plans)
Expand Down
2 changes: 1 addition & 1 deletion cmd/scollector/conf/conf.go
Expand Up @@ -157,7 +157,7 @@ type ProcessDotNet struct {
type HTTPUnit struct {
TOML string
Hiera string
Freq int
Freq string
}

type Riak struct {
Expand Down
4 changes: 2 additions & 2 deletions cmd/scollector/doc.go
Expand Up @@ -217,14 +217,14 @@ ProcessDotNet.
HTTPUnit (array of table, keys are TOML, Hiera): httpunit TOML and Hiera
files to read and monitor. See https://github.com/StackExchange/httpunit
for documentation about the toml file. TOML and Hiera may both be specified,
or just one. Freq is collector frequency in seconds.
or just one. Freq is collector frequency as a duration string (default 5m).
[[HTTPUnit]]
TOML = "/path/to/httpunit.toml"
Hiera = "/path/to/listeners.json"
[[HTTPUnit]]
TOML = "/some/other.toml"
Freq = 15
Freq = "30s"
Riak (array of table, keys are URL): Riak hosts to poll.
Expand Down
14 changes: 13 additions & 1 deletion cmd/scollector/main.go
Expand Up @@ -125,7 +125,19 @@ func main() {
check(collectors.AddProcessDotNetConfig(p))
}
for _, h := range conf.HTTPUnit {
freq := time.Second * time.Duration(h.Freq)
var freq time.Duration
var parseerr error
if h.Freq == "" {
freq = time.Minute * 5
} else {
freq, parseerr = time.ParseDuration(h.Freq)
if parseerr != nil {
slog.Fatal(parseerr)
}
if freq < time.Second {
slog.Fatalf("Invalid HTTPUnit frequency %s, cannot be less than 1 second.", h.Freq)
}
}
if h.TOML != "" {
check(collectors.HTTPUnitTOML(h.TOML, freq))
}
Expand Down

0 comments on commit 51a6929

Please sign in to comment.