From 6081a1671b4d060a5e78d1608d6c93f45ac6469e Mon Sep 17 00:00:00 2001 From: David O'Rourke Date: Tue, 1 May 2018 12:04:02 +0100 Subject: [PATCH] Add status_path label to connected_clients server metric. This fixes an issue where the exporter would fail to work if a user attempted to monitor multiple OpenVPN processes in server mode as the metrics would clash without the status_path label. --- openvpn_exporter.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openvpn_exporter.go b/openvpn_exporter.go index 067b7da..371153d 100644 --- a/openvpn_exporter.go +++ b/openvpn_exporter.go @@ -55,7 +55,8 @@ var ( // Metrics specific to OpenVPN servers. openvpnConnectedClientsDesc = prometheus.NewDesc( prometheus.BuildFQName("openvpn", "", "openvpn_server_connected_clients"), - "Number Of Connected Clients", nil, nil) + "Number Of Connected Clients", + []string{"status_path"}, nil) openvpnServerHeaders = map[string]OpenvpnServerHeader{ "CLIENT_LIST": { @@ -248,7 +249,8 @@ func CollectServerStatusFromReader(statusPath string, file io.Reader, ch chan<- ch <- prometheus.MustNewConstMetric( openvpnConnectedClientsDesc, prometheus.GaugeValue, - float64(numberConnectedClient)) + float64(numberConnectedClient), + statusPath) return scanner.Err() }