这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions cmd/scollector/collectors/riak.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"net/url"
"strings"

"bosun.org/metadata"
Expand Down Expand Up @@ -460,16 +461,35 @@ func init() {
}

const (
riakURL string = "http://localhost:8098/stats"
localRiakURL string = "http://localhost:8098/stats"
)

func Riak(s string) error {
u, err := url.Parse(s)
if err != nil {
return err
}
collectors = append(collectors,
&IntervalCollector{
F: func() (opentsdb.MultiDataPoint, error) {
return riak(s)
},
name: fmt.Sprintf("riak-%s", u.Host),
})
return nil
}

func enableRiak() bool {
return enableURL(riakURL)()
return enableURL(localRiakURL)()
}

func c_riak() (opentsdb.MultiDataPoint, error) {
return riak(localRiakURL)
}

func riak(s string) (opentsdb.MultiDataPoint, error) {
var md opentsdb.MultiDataPoint
res, err := http.Get(riakURL)
res, err := http.Get(s)
if err != nil {
return nil, err
}
Expand Down
5 changes: 5 additions & 0 deletions cmd/scollector/conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Conf struct {
Process []ProcessParams
ProcessDotNet []ProcessDotNet
HTTPUnit []HTTPUnit
Riak []Riak
}

type HAProxy struct {
Expand Down Expand Up @@ -112,3 +113,7 @@ type HTTPUnit struct {
TOML string
Hiera string
}

type Riak struct {
URL string
}
6 changes: 6 additions & 0 deletions cmd/scollector/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ AWS (array of table, keys are AccessKey, SecretKey, Region): AWS hosts to poll.
SecretKey = "snch0d"
Region = "somewhere"


Process (array of table, keys are Command, Name, Args for Linux, and Name
for Windows): processes to monitor. Name is optional, and defaults to Command.

Expand Down Expand Up @@ -238,6 +239,11 @@ or just one.
[[HTTPUnit]]
TOML = "/some/other.toml"

Riak (array of table, keys are URL): Riak hosts to poll.

[[Riak]]
URL = "http://localhost:8098/stats"

Windows

scollector has full Windows support. It can be run standalone, or installed as a
Expand Down
3 changes: 3 additions & 0 deletions cmd/scollector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ func main() {
check(collectors.HTTPUnitHiera(h.Hiera))
}
}
for _, r := range conf.Riak {
check(collectors.Riak(r.URL))
}
if err != nil {
slog.Fatal(err)
}
Expand Down