From 2461407277aa2d4de86852228633d3ef7ed42ca2 Mon Sep 17 00:00:00 2001 From: Calle Pettersson Date: Sun, 25 Mar 2018 09:50:37 +0200 Subject: [PATCH] Use kingpin for iis and msmq --- collector/iis.go | 10 +++++----- collector/msmq.go | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/collector/iis.go b/collector/iis.go index 70102e8f..136cb2f0 100644 --- a/collector/iis.go +++ b/collector/iis.go @@ -7,7 +7,6 @@ package collector import ( - "flag" "fmt" "log" "regexp" @@ -16,6 +15,7 @@ import ( "github.com/StackExchange/wmi" "github.com/prometheus/client_golang/prometheus" + "gopkg.in/alecthomas/kingpin.v2" ) func init() { @@ -56,10 +56,10 @@ func getIISVersion() simple_version { } var ( - siteWhitelist = flag.String("collector.iis.site-whitelist", ".+", "Regexp of sites to whitelist. Site name must both match whitelist and not match blacklist to be included.") - siteBlacklist = flag.String("collector.iis.site-blacklist", "", "Regexp of sites to blacklist. Site name must both match whitelist and not match blacklist to be included.") - appWhitelist = flag.String("collector.iis.app-whitelist", ".+", "Regexp of apps to whitelist. App name must both match whitelist and not match blacklist to be included.") - appBlacklist = flag.String("collector.iis.app-blacklist", "", "Regexp of apps to blacklist. App name must both match whitelist and not match blacklist to be included.") + siteWhitelist = kingpin.Flag("collector.iis.site-whitelist", "Regexp of sites to whitelist. Site name must both match whitelist and not match blacklist to be included.").Default(".+").String() + siteBlacklist = kingpin.Flag("collector.iis.site-blacklist", "Regexp of sites to blacklist. Site name must both match whitelist and not match blacklist to be included.").String() + appWhitelist = kingpin.Flag("collector.iis.app-whitelist", "Regexp of apps to whitelist. App name must both match whitelist and not match blacklist to be included.").Default(".+").String() + appBlacklist = kingpin.Flag("collector.iis.app-blacklist", "Regexp of apps to blacklist. App name must both match whitelist and not match blacklist to be included.").String() iis_version = simple_version{} ) diff --git a/collector/msmq.go b/collector/msmq.go index 31b32abb..2ad133f4 100644 --- a/collector/msmq.go +++ b/collector/msmq.go @@ -3,12 +3,13 @@ package collector import ( - "log" - "flag" "bytes" + "log" "strings" + "github.com/StackExchange/wmi" "github.com/prometheus/client_golang/prometheus" + "gopkg.in/alecthomas/kingpin.v2" ) func init() { @@ -16,7 +17,7 @@ func init() { } var ( - msmqWhereClause = flag.String("collector.msmq.msmq-where", "", "WQL 'where' clause to use in WMI metrics query. Limits the response to the msmqs you specify and reduces the size of the response.") + msmqWhereClause = kingpin.Flag("collector.msmq.msmq-where", "WQL 'where' clause to use in WMI metrics query. Limits the response to the msmqs you specify and reduces the size of the response.").String() ) // A Win32_PerfRawData_MSMQ_MSMQQueueCollector is a Prometheus collector for WMI Win32_PerfRawData_MSMQ_MSMQQueue metrics