Compare commits

..

7 Commits

Author SHA1 Message Date
Jan-Otto Kröpke
dffc53eff8 terminal_services: Fix "The operation completed successfully." error (#1548) 2024-08-05 15:31:29 +02:00
Jan-Otto Kröpke
9026bc02ff Update pr-check.yaml
Signed-off-by: Jan-Otto Kröpke <github@jkroepke.de>
2024-08-05 13:28:39 +02:00
Jan-Otto Kröpke
8f2a45d832 printer: expose config struct properties (#1545) 2024-07-31 18:02:21 +02:00
Jan-Otto Kröpke
6cecc735df logical_disk: Fix failed to get disk ID for dynamic volumes (#1544) 2024-07-31 15:02:29 +02:00
Jan-Otto Kröpke
4635be8c0c fix: CPU Collector % Cx Time mismatch (#1542) 2024-07-29 20:19:03 +02:00
dependabot[bot]
4cc7d108e3 chore(deps): bump actions/stale from 8 to 9 (#1541)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-29 18:11:13 +02:00
Jan-Otto Kröpke
d878423cb6 chore: Add label configuration (#1540) 2024-07-29 18:04:08 +02:00
12 changed files with 256 additions and 21 deletions

71
.github/ISSUE_TEMPLATE/bug_report.yaml vendored Normal file
View File

@@ -0,0 +1,71 @@
name: 🐞 Bug
description: Something is not working as indended.
labels: [ 🐞 bug ]
body:
- type: markdown
attributes:
value: Thanks for taking the time to fill out this bug report!
- type: textarea
attributes:
label: Current Behavior
description: A concise description of what you're experiencing.
placeholder: |
When I do <X>, <Y> happens and I see the error message attached below:
```...```
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: A concise description of what you expected to happen.
placeholder: When I do <X>, <Z> should happen instead.
validations:
required: true
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
placeholder: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
render: Markdown
validations:
required: false
- type: textarea
attributes:
label: Environment
description: |
examples:
- **windows_exporter Version**: 0.26
- **Windows Server Version**: 2019
value: |
- windows_exporter Version:
- Windows Server Version:
validations:
required: true
- type: textarea
attributes:
label: windows_exporter logs
description: |
Log of windows_exporter.
⚠️ Without proving logs, we unable to assist here. ⚠️
render: shell
validations:
required: true
- type: textarea
attributes:
label: Anything else?
description: |
Links? References? Anything that will give us more context about the issue you are encountering!
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
validations:
required: false

1
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View File

@@ -0,0 +1 @@
blank_issues_enabled: false

41
.github/ISSUE_TEMPLATE/enhancement.yaml vendored Normal file
View File

@@ -0,0 +1,41 @@
name: ✨ Enhancement / Feature / Task
description: Some feature is missing or incomplete.
labels: [ ✨ enhancement ]
body:
- type: textarea
attributes:
label: Problem Statement
description: Without specifying a solution, describe what the project is missing today.
placeholder: |
The rotating project logo has a fixed size and color.
There is no way to make it larger and more shiny.
validations:
required: false
- type: textarea
attributes:
label: Proposed Solution
description: Describe the proposed solution to the problem above.
placeholder: |
- Implement 2 new flags CLI: ```--logo-color=FFD700``` and ```--logo-size=100```
- Let these flags control the size of the rotating project logo.
validations:
required: false
- type: textarea
attributes:
label: Additional information
placeholder: |
We considered adjusting the logo size to the phase of the moon, but there was no
reliable data source in air-gapped environments.
validations:
required: false
- type: textarea
attributes:
label: Acceptance Criteria
placeholder: |
- [ ] As a user, I can control the size of the rotating logo using a CLI flag.
- [ ] As a user, I can control the color of the rotating logo using a CLI flag.
- [ ] Defaults are reasonably set.
- [ ] New settings are appropriately documented.
- [ ] No breaking change for current users of the rotating logo feature.
validations:
required: false

27
.github/ISSUE_TEMPLATE/question.yaml vendored Normal file
View File

@@ -0,0 +1,27 @@
name: ❓ Question
description: Something is not clear.
labels: [ ❓ question ]
body:
- type: textarea
attributes:
label: Problem Statement
description: Without specifying a solution, describe what the project is missing today.
placeholder: |
The rotating project logo has a fixed size and color.
There is no way to make it larger and more shiny.
validations:
required: false
- type: textarea
attributes:
label: Environment
description: |
examples:
- **windows_exporter Version**: 0.26
- **Windows Server Version**: 2019
value: |
- windows_exporter Version:
- Windows Server Version:
validations:
required: true

View File

@@ -1,6 +1,15 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
labels:
- "🛠️ dependencies"
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "weekly"
labels:
- "🛠️ dependencies"

23
.github/release.yml vendored Normal file
View File

@@ -0,0 +1,23 @@
changelog:
exclude:
labels:
- chore
categories:
- title: 💥 Breaking Changes
labels:
- 💥 breaking-change
- title: ✨ Exciting New Features
labels:
- ✨ enhancement
- title: 🐞 Bug Fixes
labels:
- 🐞 bug
- title: 🛠️ Dependencies
labels:
- 🛠️ dependencies
- title: 📖 Documentation
labels:
- 📖 docs
- title: Other Changes
labels:
- "*"

46
.github/workflows/pr-check.yaml vendored Normal file
View File

@@ -0,0 +1,46 @@
name: Validate Pull Request
on:
pull_request:
types:
- opened
- reopened
- synchronize
- labeled
- unlabeled
jobs:
required-labels-missing:
name: required labels missing
runs-on: ubuntu-latest
steps:
- name: check
if: >-
!contains(github.event.pull_request.labels.*.name, '💥 breaking-change')
&& !contains(github.event.pull_request.labels.*.name, '✨ enhancement')
&& !contains(github.event.pull_request.labels.*.name, '🐞 bug')
&& !contains(github.event.pull_request.labels.*.name, '📖 docs')
&& !contains(github.event.pull_request.labels.*.name, 'chore')
&& !contains(github.event.pull_request.labels.*.name, '🛠️ dependencies')
run: >-
echo One of the following labels is missing on this PR:
breaking-change
enhancement
bug
docs
chore
&& exit 1
title:
name: check title prefix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: check
run: |
PR_TITLE_PREFIX=$(echo "$PR_TITLE" | cut -d':' -f1)
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 "Example: 'logical_disk: description'"
exit 1
fi
env:
PR_TITLE: ${{ github.event.pull_request.title }}

View File

@@ -11,7 +11,7 @@ jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
- uses: actions/stale@v9
with:
stale-issue-message: 'This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.'
exempt-issue-labels: 'lifecycle/frozen'

View File

@@ -198,9 +198,9 @@ type perflibProcessor struct {
DPCRate float64 `perflib:"DPC Rate"`
DPCsQueued float64 `perflib:"DPCs Queued/sec"`
Interrupts float64 `perflib:"Interrupts/sec"`
PercentC2Time float64 `perflib:"% C1 Time"`
PercentC3Time float64 `perflib:"% C2 Time"`
PercentC1Time float64 `perflib:"% C3 Time"`
PercentC1Time float64 `perflib:"% C1 Time"`
PercentC2Time float64 `perflib:"% C2 Time"`
PercentC3Time float64 `perflib:"% C3 Time"`
PercentDPCTime float64 `perflib:"% DPC Time"`
PercentIdleTime float64 `perflib:"% Idle Time"`
PercentInterruptTime float64 `perflib:"% Interrupt Time"`

View File

@@ -5,11 +5,13 @@ package logical_disk
import (
"encoding/binary"
"fmt"
"golang.org/x/sys/windows"
"regexp"
"slices"
"strconv"
"strings"
"golang.org/x/sys/windows"
"github.com/alecthomas/kingpin/v2"
"github.com/go-kit/log"
"github.com/go-kit/log/level"
@@ -463,6 +465,9 @@ func getDriveType(driveType uint32) string {
}
}
// diskExtentSize Size of the DiskExtent structure in bytes.
const diskExtentSize = 24
// getDiskIDByVolume returns the disk ID for a given volume.
func getDiskIDByVolume(rootDrive string) (string, error) {
// Open a volume handle to the Disk Root.
@@ -488,16 +493,24 @@ func getDiskIDByVolume(rootDrive string) (string, error) {
var bytesReturned uint32
err = windows.DeviceIoControl(f, controlCode, nil, 0, &volumeDiskExtents[0], uint32(len(volumeDiskExtents)), &bytesReturned, nil)
if err != nil {
return "", err
return "", fmt.Errorf("could not identify physical drive for %s: %w", rootDrive, err)
}
if uint(binary.LittleEndian.Uint32(volumeDiskExtents)) != 1 {
return "", fmt.Errorf("could not identify physical drive for %s", rootDrive)
numDiskIDs := uint(binary.LittleEndian.Uint32(volumeDiskExtents))
if numDiskIDs < 1 {
return "", fmt.Errorf("could not identify physical drive for %s: no disk IDs returned", rootDrive)
}
diskId := strconv.FormatUint(uint64(binary.LittleEndian.Uint32(volumeDiskExtents[8:])), 10)
diskIDs := make([]string, numDiskIDs)
return diskId, nil
for i := range numDiskIDs {
diskIDs[i] = strconv.FormatUint(uint64(binary.LittleEndian.Uint32(volumeDiskExtents[8+i*diskExtentSize:])), 10)
}
slices.Sort(diskIDs)
diskIDs = slices.Compact(diskIDs)
return strings.Join(diskIDs, ";"), nil
}
func getVolumeInfo(rootDrive string) (volumeInfo, error) {

View File

@@ -35,13 +35,13 @@ var printerStatusMap = map[uint16]string{
}
type Config struct {
printerInclude string `yaml:"printer_include"`
printerExclude string `yaml:"printer_exclude"`
Include string `yaml:"printer_include"`
Exclude string `yaml:"printer_exclude"`
}
var ConfigDefaults = Config{
printerInclude: ".+",
printerExclude: "",
Include: ".+",
Exclude: "",
}
type collector struct {
@@ -63,8 +63,8 @@ func New(logger log.Logger, config *Config) types.Collector {
config = &ConfigDefaults
}
c := &collector{
printerInclude: &config.printerInclude,
printerExclude: &config.printerExclude,
printerInclude: &config.Include,
printerExclude: &config.Exclude,
}
c.SetLogger(logger)
return c
@@ -75,11 +75,11 @@ func NewWithFlags(app *kingpin.Application) types.Collector {
printerInclude: app.Flag(
FlagPrinterInclude,
"Regular expression to match printers to collect metrics for",
).Default(ConfigDefaults.printerInclude).String(),
).Default(ConfigDefaults.Include).String(),
printerExclude: app.Flag(
FlagPrinterExclude,
"Regular expression to match printers to exclude",
).Default(ConfigDefaults.printerExclude).String(),
).Default(ConfigDefaults.Exclude).String(),
}
return c
}

View File

@@ -138,13 +138,17 @@ func WTSCloseServer(server syscall.Handle) error {
}
func WTSFreeMemoryEx(class WTSTypeClass, pMemory uintptr, NumberOfEntries uint32) error {
_, _, err := procWTSFreeMemoryEx.Call(
r1, _, err := procWTSFreeMemoryEx.Call(
uintptr(class),
pMemory,
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) {
@@ -168,7 +172,7 @@ func WTSEnumerateSessionsEx(server syscall.Handle, logger log.Logger) ([]WTSSess
defer func(class WTSTypeClass, pMemory uintptr, NumberOfEntries uint32) {
err := WTSFreeMemoryEx(class, pMemory, NumberOfEntries)
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)
}