mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-11 07:26:37 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dffc53eff8 | ||
|
|
9026bc02ff | ||
|
|
8f2a45d832 |
4
.github/workflows/pr-check.yaml
vendored
4
.github/workflows/pr-check.yaml
vendored
@@ -37,10 +37,10 @@ jobs:
|
|||||||
- name: check
|
- name: check
|
||||||
run: |
|
run: |
|
||||||
PR_TITLE_PREFIX=$(echo "$PR_TITLE" | cut -d':' -f1)
|
PR_TITLE_PREFIX=$(echo "$PR_TITLE" | cut -d':' -f1)
|
||||||
if [[ ! -d "pkg/collector/$PR_TITLE_PREFIX" ]] || [[ "$PR_TITLE_PREFIX" == "chore" ]] || [[ "$PR_TITLE_PREFIX" == "*" ]]; then
|
if [[ ! -d "pkg/collector/$PR_TITLE_PREFIX" ]] || [[ "$PR_TITLE_PREFIX" == "chore(deps)" ]] || [[ "$PR_TITLE_PREFIX" == "chore" ]] || [[ "$PR_TITLE_PREFIX" == "*" ]]; then
|
||||||
echo "PR title must start with an name of an collector package"
|
echo "PR title must start with an name of an collector package"
|
||||||
echo "Example: 'logical_disk: description'"
|
echo "Example: 'logical_disk: description'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
env:
|
env:
|
||||||
PR_TITLE: ${{ github.event.pull_request.title }}
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ var printerStatusMap = map[uint16]string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
printerInclude string `yaml:"printer_include"`
|
Include string `yaml:"printer_include"`
|
||||||
printerExclude string `yaml:"printer_exclude"`
|
Exclude string `yaml:"printer_exclude"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var ConfigDefaults = Config{
|
var ConfigDefaults = Config{
|
||||||
printerInclude: ".+",
|
Include: ".+",
|
||||||
printerExclude: "",
|
Exclude: "",
|
||||||
}
|
}
|
||||||
|
|
||||||
type collector struct {
|
type collector struct {
|
||||||
@@ -63,8 +63,8 @@ func New(logger log.Logger, config *Config) types.Collector {
|
|||||||
config = &ConfigDefaults
|
config = &ConfigDefaults
|
||||||
}
|
}
|
||||||
c := &collector{
|
c := &collector{
|
||||||
printerInclude: &config.printerInclude,
|
printerInclude: &config.Include,
|
||||||
printerExclude: &config.printerExclude,
|
printerExclude: &config.Exclude,
|
||||||
}
|
}
|
||||||
c.SetLogger(logger)
|
c.SetLogger(logger)
|
||||||
return c
|
return c
|
||||||
@@ -75,11 +75,11 @@ func NewWithFlags(app *kingpin.Application) types.Collector {
|
|||||||
printerInclude: app.Flag(
|
printerInclude: app.Flag(
|
||||||
FlagPrinterInclude,
|
FlagPrinterInclude,
|
||||||
"Regular expression to match printers to collect metrics for",
|
"Regular expression to match printers to collect metrics for",
|
||||||
).Default(ConfigDefaults.printerInclude).String(),
|
).Default(ConfigDefaults.Include).String(),
|
||||||
printerExclude: app.Flag(
|
printerExclude: app.Flag(
|
||||||
FlagPrinterExclude,
|
FlagPrinterExclude,
|
||||||
"Regular expression to match printers to exclude",
|
"Regular expression to match printers to exclude",
|
||||||
).Default(ConfigDefaults.printerExclude).String(),
|
).Default(ConfigDefaults.Exclude).String(),
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -138,13 +138,17 @@ func WTSCloseServer(server syscall.Handle) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func WTSFreeMemoryEx(class WTSTypeClass, pMemory uintptr, NumberOfEntries uint32) error {
|
func WTSFreeMemoryEx(class WTSTypeClass, pMemory uintptr, NumberOfEntries uint32) error {
|
||||||
_, _, err := procWTSFreeMemoryEx.Call(
|
r1, _, err := procWTSFreeMemoryEx.Call(
|
||||||
uintptr(class),
|
uintptr(class),
|
||||||
pMemory,
|
pMemory,
|
||||||
uintptr(NumberOfEntries),
|
uintptr(NumberOfEntries),
|
||||||
)
|
)
|
||||||
|
|
||||||
return err
|
if r1 != 1 {
|
||||||
|
return fmt.Errorf("failed to free memory: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func WTSEnumerateSessionsEx(server syscall.Handle, logger log.Logger) ([]WTSSession, error) {
|
func WTSEnumerateSessionsEx(server syscall.Handle, logger log.Logger) ([]WTSSession, error) {
|
||||||
@@ -168,7 +172,7 @@ func WTSEnumerateSessionsEx(server syscall.Handle, logger log.Logger) ([]WTSSess
|
|||||||
defer func(class WTSTypeClass, pMemory uintptr, NumberOfEntries uint32) {
|
defer func(class WTSTypeClass, pMemory uintptr, NumberOfEntries uint32) {
|
||||||
err := WTSFreeMemoryEx(class, pMemory, NumberOfEntries)
|
err := WTSFreeMemoryEx(class, pMemory, NumberOfEntries)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = level.Error(logger).Log("msg", "failed to free memory", "err", err)
|
_ = level.Error(logger).Log("msg", "failed to free memory", "err", fmt.Errorf("WTSEnumerateSessionsEx: %w", err))
|
||||||
}
|
}
|
||||||
}(WTSTypeSessionInfoLevel1, sessionInfoPointer, count)
|
}(WTSTypeSessionInfoLevel1, sessionInfoPointer, count)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user