mirror of
https://github.com/prometheus-community/windows_exporter
synced 2025-02-17 04:27:06 +00:00
Merge pull request #86 from martinlindhe/iis-wp-and-cache
Implement IIS worker process and server cache classes
This commit is contained in:
commit
88271ddf14
1179
collector/iis.go
1179
collector/iis.go
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,12 @@
|
||||
package collector
|
||||
|
||||
import "github.com/prometheus/client_golang/prometheus"
|
||||
import (
|
||||
"bytes"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
// ...
|
||||
const (
|
||||
@ -18,3 +24,30 @@ type Collector interface {
|
||||
// Get new metrics and expose them via prometheus registry.
|
||||
Collect(ch chan<- prometheus.Metric) (err error)
|
||||
}
|
||||
|
||||
// This is adapted from StackExchange/wmi/wmi.go, and lets us change the class
|
||||
// name being queried for:
|
||||
// CreateQuery returns a WQL query string that queries all columns of src. where
|
||||
// is an optional string that is appended to the query, to be used with WHERE
|
||||
// clauses. In such a case, the "WHERE" string should appear at the beginning.
|
||||
func createQuery(src interface{}, class, where string) string {
|
||||
var b bytes.Buffer
|
||||
b.WriteString("SELECT ")
|
||||
s := reflect.Indirect(reflect.ValueOf(src))
|
||||
t := s.Type()
|
||||
if s.Kind() == reflect.Slice {
|
||||
t = t.Elem()
|
||||
}
|
||||
if t.Kind() != reflect.Struct {
|
||||
return ""
|
||||
}
|
||||
var fields []string
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
fields = append(fields, t.Field(i).Name)
|
||||
}
|
||||
b.WriteString(strings.Join(fields, ", "))
|
||||
b.WriteString(" FROM ")
|
||||
b.WriteString(class)
|
||||
b.WriteString(" " + where)
|
||||
return b.String()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user