aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes 'fish' Ziemke <github@freigeist.org>2018-03-09 11:30:23 +0100
committerJohannes 'fish' Ziemke <github@freigeist.org>2018-04-17 20:20:24 +0200
commitfd66a86a3036cb1b2d24015624566e8be53a2026 (patch)
tree04df9fe99d54146714df52dded44bd0cad5e92d7
parent7b720df1c5ded45ce17e5b37515c032f6ec1c4ff (diff)
downloadprometheus_node_collector-fd66a86a3036cb1b2d24015624566e8be53a2026.tar.bz2
prometheus_node_collector-fd66a86a3036cb1b2d24015624566e8be53a2026.tar.xz
prometheus_node_collector-fd66a86a3036cb1b2d24015624566e8be53a2026.zip
Remove gmond collector
Signed-off-by: Johannes 'fish' Ziemke <github@freigeist.org>
-rw-r--r--README.md8
-rw-r--r--collector/ganglia/format.go80
-rw-r--r--collector/gmond.go123
3 files changed, 0 insertions, 211 deletions
diff --git a/README.md b/README.md
index 19de9fd..4485296 100644
--- a/README.md
+++ b/README.md
@@ -74,14 +74,6 @@ supervisord | Exposes service status from [supervisord](http://supervisord.org/)
74systemd | Exposes service and system status from [systemd](http://www.freedesktop.org/wiki/Software/systemd/). | Linux 74systemd | Exposes service and system status from [systemd](http://www.freedesktop.org/wiki/Software/systemd/). | Linux
75tcpstat | 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 75tcpstat | 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 76
77### Deprecated
78
79*These collectors will be (re)moved in the future.*
80
81Name | Description | OS
82---------|-------------|----
83gmond | Exposes statistics from Ganglia. | _any_
84
85### Textfile Collector 77### Textfile Collector
86 78
87The textfile collector is similar to the [Pushgateway](https://github.com/prometheus/pushgateway), 79The 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.
19package ganglia
20
21import "encoding/xml"
22
23// ExtraElement describes EXTRA_ELEMENT elements.
24type ExtraElement struct {
25 Name string `xml:"NAME,attr"`
26 Val string `xml:"VAL,attr"`
27}
28
29// ExtraData describes EXTRA_DATA elements.
30type ExtraData struct {
31 ExtraElements []ExtraElement `xml:"EXTRA_ELEMENT"`
32}
33
34// Metric describes METRIC elements.
35type 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.
49type 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.
65type 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.
77type 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
16package collector
17
18import (
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
32const (
33 gangliaAddress = "127.0.0.1:8649"
34 gangliaProto = "tcp"
35 gangliaTimeout = 30 * time.Second
36 gangliaNamespace = "ganglia"
37)
38
39type gmondCollector struct {
40 metrics map[string]*prometheus.GaugeVec
41}
42
43func init() {
44 registerCollector("gmond", defaultDisabled, NewGmondCollector)
45}
46
47var illegalCharsRE = regexp.MustCompile(`[^a-zA-Z0-9_]`)
48
49// NewGmondCollector returns a new Collector scraping ganglia.
50func NewGmondCollector() (Collector, error) {
51 warnDeprecated("gmond")
52 c := gmondCollector{
53 metrics: map[string]*prometheus.GaugeVec{},
54 }
55
56 return &c, nil
57}
58
59func (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
92func (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
121func toUtf8(charset string, input io.Reader) (io.Reader, error) {
122 return input, nil //FIXME
123}