add flag to explicitly enable per-peer metrics
This commit is contained in:
parent
c08b4202c9
commit
39b21226c4
2
LICENSE
2
LICENSE
|
@ -1,6 +1,6 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Martin Weinelt
|
||||
Copyright (c) 2017-2018 Martin Weinelt
|
||||
Copyright (c) 2017 Andreas Rammhold
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
|
|
|
@ -16,7 +16,7 @@ $ go get github.com/freifunk-darmstadt/fastd-exporter
|
|||
and
|
||||
|
||||
```
|
||||
$ ./fastd-exporter --instance ffda
|
||||
$ ./fastd-exporter --instance ffda --metrics.perpeer
|
||||
```
|
||||
|
||||
The exporter will need read access to both the instances `fastd.conf` and `status socket`, keep that in mind.
|
||||
|
|
|
@ -21,6 +21,7 @@ var (
|
|||
address = flag.String("web.listen-address", ":9281", "Address on which to expose metrics and web interface.")
|
||||
metricsPath = flag.String("web.telemetry-path", "/metrics", "Path under which to expose metrics.")
|
||||
instances = flag.String("instances", "", "Fastd instances to report metrics on, comma separated.")
|
||||
peerMetrics = flag.Bool("metrics.perpeer", false, "Expose detailed metrics on each peer.")
|
||||
)
|
||||
|
||||
// These are the structs necessary for unmarshalling the data that is being received on fastds unix socket.
|
||||
|
@ -192,6 +193,7 @@ func (e PrometheusExporter) Collect(c chan<- prometheus.Metric) {
|
|||
c <- prometheus.MustNewConstMetric(e.txDroppedPackets, prometheus.CounterValue, float64(data.Statistics.TX.Count))
|
||||
c <- prometheus.MustNewConstMetric(e.txDroppedBytes, prometheus.CounterValue, float64(data.Statistics.TX_Dropped.Bytes))
|
||||
|
||||
if *peerMetrics {
|
||||
for publicKey, peer := range data.Peers {
|
||||
if peer.Connection == nil {
|
||||
c <- prometheus.MustNewConstMetric(e.peerUp, prometheus.GaugeValue, float64(0), publicKey, peer.Name)
|
||||
|
@ -213,6 +215,7 @@ func (e PrometheusExporter) Collect(c chan<- prometheus.Metric) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func data_from_sock(sock string) (Message, error) {
|
||||
conn, err := net.DialTimeout("unix", sock, 2*time.Second)
|
||||
|
|
Loading…
Reference in a new issue