diff options
-rw-r--r-- | README.md | 8 | ||||
-rw-r--r-- | collector/ganglia/format.go | 80 | ||||
-rw-r--r-- | collector/gmond.go | 123 |
3 files changed, 0 insertions, 211 deletions
@@ -75,14 +75,6 @@ supervisord | Exposes service status from [supervisord](http://supervisord.org/) | |||
75 | systemd | Exposes service and system status from [systemd](http://www.freedesktop.org/wiki/Software/systemd/). | Linux | 75 | systemd | Exposes service and system status from [systemd](http://www.freedesktop.org/wiki/Software/systemd/). | Linux |
76 | tcpstat | Exposes TCP connection status information from `/proc/net/tcp` and `/proc/net/tcp6`. (Warning: the current version has potential performance issues in high load situations.) | Linux | 76 | tcpstat | Exposes TCP connection status information from `/proc/net/tcp` and `/proc/net/tcp6`. (Warning: the current version has potential performance issues in high load situations.) | Linux |
77 | 77 | ||
78 | ### Deprecated | ||
79 | |||
80 | *These collectors will be (re)moved in the future.* | ||
81 | |||
82 | Name | Description | OS | ||
83 | ---------|-------------|---- | ||
84 | gmond | Exposes statistics from Ganglia. | _any_ | ||
85 | |||
86 | ### Textfile Collector | 78 | ### Textfile Collector |
87 | 79 | ||
88 | The textfile collector is similar to the [Pushgateway](https://github.com/prometheus/pushgateway), | 80 | The textfile collector is similar to the [Pushgateway](https://github.com/prometheus/pushgateway), |
diff --git a/collector/ganglia/format.go b/collector/ganglia/format.go deleted file mode 100644 index 89ec044..0000000 --- a/collector/ganglia/format.go +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
1 | // Copyright 2015 The Prometheus Authors | ||
2 | // Licensed under the Apache License, Version 2.0 (the "License"); | ||
3 | // you may not use this file except in compliance with the License. | ||
4 | // You may obtain a copy of the License at | ||
5 | // | ||
6 | // http://www.apache.org/licenses/LICENSE-2.0 | ||
7 | // | ||
8 | // Unless required by applicable law or agreed to in writing, software | ||
9 | // distributed under the License is distributed on an "AS IS" BASIS, | ||
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
11 | // See the License for the specific language governing permissions and | ||
12 | // limitations under the License. | ||
13 | |||
14 | // Package ganglia provides types for unmarshalling gmond's XML output. | ||
15 | // | ||
16 | // Not used elements in gmond's XML output are commented. | ||
17 | // In case you want to use them, please change the names so that one | ||
18 | // can understand without needing to know what the acronym stands for. | ||
19 | package ganglia | ||
20 | |||
21 | import "encoding/xml" | ||
22 | |||
23 | // ExtraElement describes EXTRA_ELEMENT elements. | ||
24 | type ExtraElement struct { | ||
25 | Name string `xml:"NAME,attr"` | ||
26 | Val string `xml:"VAL,attr"` | ||
27 | } | ||
28 | |||
29 | // ExtraData describes EXTRA_DATA elements. | ||
30 | type ExtraData struct { | ||
31 | ExtraElements []ExtraElement `xml:"EXTRA_ELEMENT"` | ||
32 | } | ||
33 | |||
34 | // Metric describes METRIC elements. | ||
35 | type Metric struct { | ||
36 | Name string `xml:"NAME,attr"` | ||
37 | Value float64 `xml:"VAL,attr"` | ||
38 | /* | ||
39 | Unit string `xml:"UNITS,attr"` | ||
40 | Slope string `xml:"SLOPE,attr"` | ||
41 | Tn int `xml:"TN,attr"` | ||
42 | Tmax int `xml:"TMAX,attr"` | ||
43 | Dmax int `xml:"DMAX,attr"` | ||
44 | */ | ||
45 | ExtraData ExtraData `xml:"EXTRA_DATA"` | ||
46 | } | ||
47 | |||
48 | // Host describes HOST elements. | ||
49 | type Host struct { | ||
50 | Name string `xml:"NAME,attr"` | ||
51 | /* | ||
52 | Ip string `xml:"IP,attr"` | ||
53 | Tags string `xml:"TAGS,attr"` | ||
54 | Reported int `xml:"REPORTED,attr"` | ||
55 | Tn int `xml:"TN,attr"` | ||
56 | Tmax int `xml:"TMAX,attr"` | ||
57 | Dmax int `xml:"DMAX,attr"` | ||
58 | Location string `xml:"LOCATION,attr"` | ||
59 | GmondStarted int `xml:"GMOND_STARTED",attr"` | ||
60 | */ | ||
61 | Metrics []Metric `xml:"METRIC"` | ||
62 | } | ||
63 | |||
64 | // Cluster describes CLUSTER elements. | ||
65 | type Cluster struct { | ||
66 | Name string `xml:"NAME,attr"` | ||
67 | /* | ||
68 | Owner string `xml:"OWNER,attr"` | ||
69 | LatLong string `xml:"LATLONG,attr"` | ||
70 | Url string `xml:"URL,attr"` | ||
71 | Localtime int `xml:"LOCALTIME,attr"` | ||
72 | */ | ||
73 | Hosts []Host `xml:"HOST"` | ||
74 | } | ||
75 | |||
76 | // Ganglia describes the top-level XML structure. | ||
77 | type Ganglia struct { | ||
78 | XMLNAME xml.Name `xml:"GANGLIA_XML"` | ||
79 | Clusters []Cluster `xml:"CLUSTER"` | ||
80 | } | ||
diff --git a/collector/gmond.go b/collector/gmond.go deleted file mode 100644 index f0d4119..0000000 --- a/collector/gmond.go +++ /dev/null | |||
@@ -1,123 +0,0 @@ | |||
1 | // Copyright 2015 The Prometheus Authors | ||
2 | // Licensed under the Apache License, Version 2.0 (the "License"); | ||
3 | // you may not use this file except in compliance with the License. | ||
4 | // You may obtain a copy of the License at | ||
5 | // | ||
6 | // http://www.apache.org/licenses/LICENSE-2.0 | ||
7 | // | ||
8 | // Unless required by applicable law or agreed to in writing, software | ||
9 | // distributed under the License is distributed on an "AS IS" BASIS, | ||
10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
11 | // See the License for the specific language governing permissions and | ||
12 | // limitations under the License. | ||
13 | |||
14 | // +build !nogmond | ||
15 | |||
16 | package collector | ||
17 | |||
18 | import ( | ||
19 | "bufio" | ||
20 | "encoding/xml" | ||
21 | "fmt" | ||
22 | "io" | ||
23 | "net" | ||
24 | "regexp" | ||
25 | "time" | ||
26 | |||
27 | "github.com/prometheus/client_golang/prometheus" | ||
28 | "github.com/prometheus/common/log" | ||
29 | "github.com/prometheus/node_exporter/collector/ganglia" | ||
30 | ) | ||
31 | |||
32 | const ( | ||
33 | gangliaAddress = "127.0.0.1:8649" | ||
34 | gangliaProto = "tcp" | ||
35 | gangliaTimeout = 30 * time.Second | ||
36 | gangliaNamespace = "ganglia" | ||
37 | ) | ||
38 | |||
39 | type gmondCollector struct { | ||
40 | metrics map[string]*prometheus.GaugeVec | ||
41 | } | ||
42 | |||
43 | func init() { | ||
44 | registerCollector("gmond", defaultDisabled, NewGmondCollector) | ||
45 | } | ||
46 | |||
47 | var illegalCharsRE = regexp.MustCompile(`[^a-zA-Z0-9_]`) | ||
48 | |||
49 | // NewGmondCollector returns a new Collector scraping ganglia. | ||
50 | func NewGmondCollector() (Collector, error) { | ||
51 | warnDeprecated("gmond") | ||
52 | c := gmondCollector{ | ||
53 | metrics: map[string]*prometheus.GaugeVec{}, | ||
54 | } | ||
55 | |||
56 | return &c, nil | ||
57 | } | ||
58 | |||
59 | func (c *gmondCollector) Update(ch chan<- prometheus.Metric) error { | ||
60 | conn, err := net.Dial(gangliaProto, gangliaAddress) | ||
61 | log.Debugf("gmondCollector Update") | ||
62 | if err != nil { | ||
63 | return fmt.Errorf("can't connect to gmond: %s", err) | ||
64 | } | ||
65 | conn.SetDeadline(time.Now().Add(gangliaTimeout)) | ||
66 | |||
67 | ganglia := ganglia.Ganglia{} | ||
68 | decoder := xml.NewDecoder(bufio.NewReader(conn)) | ||
69 | decoder.CharsetReader = toUtf8 | ||
70 | |||
71 | err = decoder.Decode(&ganglia) | ||
72 | if err != nil { | ||
73 | return fmt.Errorf("couldn't parse xml: %s", err) | ||
74 | } | ||
75 | |||
76 | for _, cluster := range ganglia.Clusters { | ||
77 | for _, host := range cluster.Hosts { | ||
78 | |||
79 | for _, metric := range host.Metrics { | ||
80 | name := illegalCharsRE.ReplaceAllString(metric.Name, "_") | ||
81 | |||
82 | c.setMetric(name, cluster.Name, metric) | ||
83 | } | ||
84 | } | ||
85 | } | ||
86 | for _, m := range c.metrics { | ||
87 | m.Collect(ch) | ||
88 | } | ||
89 | return err | ||
90 | } | ||
91 | |||
92 | func (c *gmondCollector) setMetric(name, cluster string, metric ganglia.Metric) { | ||
93 | if _, ok := c.metrics[name]; !ok { | ||
94 | var desc string | ||
95 | var title string | ||
96 | for _, element := range metric.ExtraData.ExtraElements { | ||
97 | switch element.Name { | ||
98 | case "DESC": | ||
99 | desc = element.Val | ||
100 | case "TITLE": | ||
101 | title = element.Val | ||
102 | } | ||
103 | if title != "" && desc != "" { | ||
104 | break | ||
105 | } | ||
106 | } | ||
107 | log.Debugf("Register %s: %s", name, desc) | ||
108 | c.metrics[name] = prometheus.NewGaugeVec( | ||
109 | prometheus.GaugeOpts{ | ||
110 | Namespace: gangliaNamespace, | ||
111 | Name: name, | ||
112 | Help: desc, | ||
113 | }, | ||
114 | []string{"cluster"}, | ||
115 | ) | ||
116 | } | ||
117 | log.Debugf("Set %s{cluster=%q}: %f", name, cluster, metric.Value) | ||
118 | c.metrics[name].WithLabelValues(cluster).Set(metric.Value) | ||
119 | } | ||
120 | |||
121 | func toUtf8(charset string, input io.Reader) (io.Reader, error) { | ||
122 | return input, nil //FIXME | ||
123 | } | ||