mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-03-02 16:46:35 +00:00
*: cleanup collector API 1 (#1547)
This commit is contained in:
@@ -17,8 +17,8 @@ type Config struct{}
|
||||
|
||||
var ConfigDefaults = Config{}
|
||||
|
||||
// collector is a Prometheus collector for WMI Win32_PerfRawData_IAS_NPSAuthenticationServer and Win32_PerfRawData_IAS_NPSAccountingServer metrics
|
||||
type collector struct {
|
||||
// Collector is a Prometheus Collector for WMI Win32_PerfRawData_IAS_NPSAuthenticationServer and Win32_PerfRawData_IAS_NPSAccountingServer metrics
|
||||
type Collector struct {
|
||||
logger log.Logger
|
||||
|
||||
AccessAccepts *prometheus.Desc
|
||||
@@ -49,29 +49,34 @@ type collector struct {
|
||||
AccountingUnknownType *prometheus.Desc
|
||||
}
|
||||
|
||||
func New(logger log.Logger, _ *Config) types.Collector {
|
||||
c := &collector{}
|
||||
func New(logger log.Logger, _ *Config) *Collector {
|
||||
c := &Collector{}
|
||||
c.SetLogger(logger)
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
func NewWithFlags(_ *kingpin.Application) types.Collector {
|
||||
return &collector{}
|
||||
func NewWithFlags(_ *kingpin.Application) *Collector {
|
||||
return &Collector{}
|
||||
}
|
||||
|
||||
func (c *collector) GetName() string {
|
||||
func (c *Collector) GetName() string {
|
||||
return Name
|
||||
}
|
||||
|
||||
func (c *collector) SetLogger(logger log.Logger) {
|
||||
func (c *Collector) SetLogger(logger log.Logger) {
|
||||
c.logger = log.With(logger, "collector", Name)
|
||||
}
|
||||
|
||||
func (c *collector) GetPerfCounter() ([]string, error) {
|
||||
func (c *Collector) GetPerfCounter() ([]string, error) {
|
||||
return []string{}, nil
|
||||
}
|
||||
|
||||
func (c *collector) Build() error {
|
||||
func (c *Collector) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Collector) Build() error {
|
||||
c.AccessAccepts = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "access_accepts"),
|
||||
"(AccessAccepts)",
|
||||
@@ -228,7 +233,7 @@ func (c *collector) Build() error {
|
||||
|
||||
// Collect sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *collector) Collect(_ *types.ScrapeContext, ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) Collect(_ *types.ScrapeContext, ch chan<- prometheus.Metric) error {
|
||||
if err := c.CollectAccept(ch); err != nil {
|
||||
_ = level.Error(c.logger).Log("msg", fmt.Sprintf("failed collecting NPS accept data: %s", err))
|
||||
return err
|
||||
@@ -279,7 +284,7 @@ type Win32_PerfRawData_IAS_NPSAccountingServer struct {
|
||||
|
||||
// CollectAccept sends the metric values for each metric
|
||||
// to the provided prometheus Metric channel.
|
||||
func (c *collector) CollectAccept(ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) CollectAccept(ch chan<- prometheus.Metric) error {
|
||||
var dst []Win32_PerfRawData_IAS_NPSAuthenticationServer
|
||||
q := wmi.QueryAll(&dst, c.logger)
|
||||
if err := wmi.Query(q, &dst); err != nil {
|
||||
@@ -367,7 +372,7 @@ func (c *collector) CollectAccept(ch chan<- prometheus.Metric) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *collector) CollectAccounting(ch chan<- prometheus.Metric) error {
|
||||
func (c *Collector) CollectAccounting(ch chan<- prometheus.Metric) error {
|
||||
var dst []Win32_PerfRawData_IAS_NPSAccountingServer
|
||||
q := wmi.QueryAll(&dst, c.logger)
|
||||
if err := wmi.Query(q, &dst); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user