From fd66a86a3036cb1b2d24015624566e8be53a2026 Mon Sep 17 00:00:00 2001 From: Johannes 'fish' Ziemke Date: Fri, 9 Mar 2018 11:30:23 +0100 Subject: [PATCH] Remove gmond collector Signed-off-by: Johannes 'fish' Ziemke --- README.md | 8 --- collector/ganglia/format.go | 80 ----------------------- collector/gmond.go | 123 ------------------------------------ 3 files changed, 211 deletions(-) delete mode 100644 collector/ganglia/format.go delete mode 100644 collector/gmond.go diff --git a/README.md b/README.md index 19de9fd4..4485296d 100644 --- a/README.md +++ b/README.md @@ -74,14 +74,6 @@ supervisord | Exposes service status from [supervisord](http://supervisord.org/) systemd | Exposes service and system status from [systemd](http://www.freedesktop.org/wiki/Software/systemd/). | Linux 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 -### Deprecated - -*These collectors will be (re)moved in the future.* - -Name | Description | OS ----------|-------------|---- -gmond | Exposes statistics from Ganglia. | _any_ - ### Textfile Collector 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 89ec0440..00000000 --- a/collector/ganglia/format.go +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2015 The Prometheus Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package ganglia provides types for unmarshalling gmond's XML output. -// -// Not used elements in gmond's XML output are commented. -// In case you want to use them, please change the names so that one -// can understand without needing to know what the acronym stands for. -package ganglia - -import "encoding/xml" - -// ExtraElement describes EXTRA_ELEMENT elements. -type ExtraElement struct { - Name string `xml:"NAME,attr"` - Val string `xml:"VAL,attr"` -} - -// ExtraData describes EXTRA_DATA elements. -type ExtraData struct { - ExtraElements []ExtraElement `xml:"EXTRA_ELEMENT"` -} - -// Metric describes METRIC elements. -type Metric struct { - Name string `xml:"NAME,attr"` - Value float64 `xml:"VAL,attr"` - /* - Unit string `xml:"UNITS,attr"` - Slope string `xml:"SLOPE,attr"` - Tn int `xml:"TN,attr"` - Tmax int `xml:"TMAX,attr"` - Dmax int `xml:"DMAX,attr"` - */ - ExtraData ExtraData `xml:"EXTRA_DATA"` -} - -// Host describes HOST elements. -type Host struct { - Name string `xml:"NAME,attr"` - /* - Ip string `xml:"IP,attr"` - Tags string `xml:"TAGS,attr"` - Reported int `xml:"REPORTED,attr"` - Tn int `xml:"TN,attr"` - Tmax int `xml:"TMAX,attr"` - Dmax int `xml:"DMAX,attr"` - Location string `xml:"LOCATION,attr"` - GmondStarted int `xml:"GMOND_STARTED",attr"` - */ - Metrics []Metric `xml:"METRIC"` -} - -// Cluster describes CLUSTER elements. -type Cluster struct { - Name string `xml:"NAME,attr"` - /* - Owner string `xml:"OWNER,attr"` - LatLong string `xml:"LATLONG,attr"` - Url string `xml:"URL,attr"` - Localtime int `xml:"LOCALTIME,attr"` - */ - Hosts []Host `xml:"HOST"` -} - -// Ganglia describes the top-level XML structure. -type Ganglia struct { - XMLNAME xml.Name `xml:"GANGLIA_XML"` - Clusters []Cluster `xml:"CLUSTER"` -} diff --git a/collector/gmond.go b/collector/gmond.go deleted file mode 100644 index f0d4119b..00000000 --- a/collector/gmond.go +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright 2015 The Prometheus Authors -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build !nogmond - -package collector - -import ( - "bufio" - "encoding/xml" - "fmt" - "io" - "net" - "regexp" - "time" - - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/common/log" - "github.com/prometheus/node_exporter/collector/ganglia" -) - -const ( - gangliaAddress = "127.0.0.1:8649" - gangliaProto = "tcp" - gangliaTimeout = 30 * time.Second - gangliaNamespace = "ganglia" -) - -type gmondCollector struct { - metrics map[string]*prometheus.GaugeVec -} - -func init() { - registerCollector("gmond", defaultDisabled, NewGmondCollector) -} - -var illegalCharsRE = regexp.MustCompile(`[^a-zA-Z0-9_]`) - -// NewGmondCollector returns a new Collector scraping ganglia. -func NewGmondCollector() (Collector, error) { - warnDeprecated("gmond") - c := gmondCollector{ - metrics: map[string]*prometheus.GaugeVec{}, - } - - return &c, nil -} - -func (c *gmondCollector) Update(ch chan<- prometheus.Metric) error { - conn, err := net.Dial(gangliaProto, gangliaAddress) - log.Debugf("gmondCollector Update") - if err != nil { - return fmt.Errorf("can't connect to gmond: %s", err) - } - conn.SetDeadline(time.Now().Add(gangliaTimeout)) - - ganglia := ganglia.Ganglia{} - decoder := xml.NewDecoder(bufio.NewReader(conn)) - decoder.CharsetReader = toUtf8 - - err = decoder.Decode(&ganglia) - if err != nil { - return fmt.Errorf("couldn't parse xml: %s", err) - } - - for _, cluster := range ganglia.Clusters { - for _, host := range cluster.Hosts { - - for _, metric := range host.Metrics { - name := illegalCharsRE.ReplaceAllString(metric.Name, "_") - - c.setMetric(name, cluster.Name, metric) - } - } - } - for _, m := range c.metrics { - m.Collect(ch) - } - return err -} - -func (c *gmondCollector) setMetric(name, cluster string, metric ganglia.Metric) { - if _, ok := c.metrics[name]; !ok { - var desc string - var title string - for _, element := range metric.ExtraData.ExtraElements { - switch element.Name { - case "DESC": - desc = element.Val - case "TITLE": - title = element.Val - } - if title != "" && desc != "" { - break - } - } - log.Debugf("Register %s: %s", name, desc) - c.metrics[name] = prometheus.NewGaugeVec( - prometheus.GaugeOpts{ - Namespace: gangliaNamespace, - Name: name, - Help: desc, - }, - []string{"cluster"}, - ) - } - log.Debugf("Set %s{cluster=%q}: %f", name, cluster, metric.Value) - c.metrics[name].WithLabelValues(cluster).Set(metric.Value) -} - -func toUtf8(charset string, input io.Reader) (io.Reader, error) { - return input, nil //FIXME -}