Skip to content
This repository has been archived by the owner on Feb 13, 2025. It is now read-only.

Commit

Permalink
cmd/scollector: modify according to review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
noblehng authored and gbrayut committed Mar 15, 2016
1 parent 2a0cbd0 commit db69b5a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/scollector/collectors/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func c_oracle(name string, inst conf.OracleInstance) (opentsdb.MultiDataPoint, e
},
}

args := []string{"-S", inst.ConnectString}
args := []string{"-S", inst.ConnectionString}
if role := inst.Role; role != "" {
args = append(args, "as")
args = append(args, role)
Expand Down
30 changes: 26 additions & 4 deletions cmd/scollector/collectors/varnish_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package collectors
import (
"encoding/json"
"os/exec"
"strings"
"time"

"bosun.org/metadata"
Expand Down Expand Up @@ -42,9 +43,30 @@ func c_varnish_unix() (opentsdb.MultiDataPoint, error) {
continue
}

ts := opentsdb.TagSet{"type": v.Type}
if v.SubType != "" {
ts.Merge(opentsdb.TagSet{"subtype": v.SubType})
ts := opentsdb.TagSet{}

// special case for backend stats. extract backend name, host and port, put
// them in tags and remove them in name.
// the format is like "name(host,,port)" for the "ident" field of "VBE" type
if v.Type == "VBE" {
subtype := v.SubType

name = strings.Replace(name, "."+subtype, "", -1)

idx := strings.Index(subtype, "(")
if idx < 0 || len(subtype)-idx < 4 {
// output format changed, ignore
continue
}

ss := strings.Split(subtype[idx+1:len(subtype)-1], ",")
if len(ss) != 3 {
// output format changed, ignore
continue
}

ts.Merge(opentsdb.TagSet{"backend": subtype[:idx]})
ts.Merge(opentsdb.TagSet{"endpoint": ss[0] + "_" + ss[2]})
}

rate := metadata.RateType(metadata.Gauge)
Expand All @@ -57,7 +79,7 @@ func c_varnish_unix() (opentsdb.MultiDataPoint, error) {
unit = metadata.Bytes
}

Add(&md, metric+name, v.Value, ts, rate, unit, v.Desc)
Add(&md, metric+strings.ToLower(name), v.Value, ts, rate, unit, v.Desc)
}
return md, nil
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/scollector/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,6 @@ type Oracle struct {
}

type OracleInstance struct {
ConnectString string
Role string
ConnectionString string
Role string
}

0 comments on commit db69b5a

Please sign in to comment.