Skip to content

Commit 32eb104

Browse files
authored
Merge branch 'main' into feature-idle-time-in-cpu-utilization
2 parents bbd3a74 + 322d1e8 commit 32eb104

File tree

12 files changed

+326
-85
lines changed

12 files changed

+326
-85
lines changed

.golangci.yml

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ linters:
5858
lll:
5959
line-length: 200
6060
exclusions:
61+
#warn-unused: true
6162
generated: lax
6263
presets:
6364
- comments
@@ -73,14 +74,10 @@ linters:
7374
- linters:
7475
- nolintlint
7576
path: (check_tcp|check_dns|nameserver.*)\.go
76-
- path: (.+)\.go$
77-
text: '`noCopy` is unused'
7877
- path: (.+)\.go$
7978
text: 'Magic number: 0.1, in'
8079
- path: (.+)\.go$
8180
text: 'Magic number: 0.01, in'
82-
- path: (.+)\.go$
83-
text: 'Magic number: 0.001, in'
8481
- path: (.+)\.go$
8582
text: 'Magic number: 2, in'
8683
- path: (.+)\.go$
@@ -109,8 +106,6 @@ linters:
109106
text: 'Magic number: 22, in'
110107
- path: (.+)\.go$
111108
text: 'Magic number: 23, in'
112-
- path: (.+)\.go$
113-
text: 'Magic number: 24, in'
114109
- path: (.+)\.go$
115110
text: 'Magic number: 31, in'
116111
- path: (.+)\.go$
@@ -121,8 +116,6 @@ linters:
121116
text: 'Magic number: 59, in'
122117
- path: (.+)\.go$
123118
text: 'Magic number: 60, in'
124-
- path: (.+)\.go$
125-
text: 'Magic number: 64, in'
126119
- path: (.+)\.go$
127120
text: 'Magic number: 100, in'
128121
- path: (.+)\.go$
@@ -133,8 +126,6 @@ linters:
133126
text: 'Magic number: 365, in'
134127
- path: (.+)\.go$
135128
text: 'Magic number: 500, in'
136-
- path: (.+)\.go$
137-
text: 'Magic number: 512, in'
138129
- path: (.+)\.go$
139130
text: 'Magic number: 600, in'
140131
- path: (.+)\.go$
@@ -151,40 +142,16 @@ linters:
151142
text: 'Magic number: 1e6, in'
152143
- path: (.+)\.go$
153144
text: 'Magic number: 1e7, in'
154-
- path: (.+)\.go$
155-
text: 'Magic number: 1e9, in'
156-
- path: (.+)\.go$
157-
text: 'Magic number: 1e12, in'
158-
- path: (.+)\.go$
159-
text: 'Magic number: 1e15, in'
160145
- path: (.+)\.go$
161146
text: 'Magic number: 0o600, in'
162147
- path: (.+)\.go$
163148
text: 'Magic number: 0o700, in'
164-
- path: (.+)\.go$
165-
text: noCopy is missing in
166149
- path: (.+)\.go$
167150
text: variable name 'ok' is too short
168151
- path: (.+)\.go$
169152
text: Function 'setListenTLSConfig' has too many statements
170-
- path: (.+)\.go$
171-
text: Function 'parseAnyArg' has too many statements
172-
- path: (.+)\.go$
173-
text: complexity.*setListenTLSConfig
174-
- path: (.+)\.go$
175-
text: complexity.*checkFlags
176-
- path: (.+)\.go$
177-
text: Function 'readConfiguration' has too many statements
178-
- path: (.+)\.go$
179-
text: complexity.*readConfiguration
180-
- path: (.+)\.go$
181-
text: Function 'Check' has too many statements
182153
- path: (.+)\.go$
183154
text: Function 'Check' is too long
184-
- path: (.+)\.go$
185-
text: Function 'fetchProcs' is too long
186-
- path: (.+)\.go$
187-
text: Function 'buildListMacros' is too long
188155
- path: (.+)\.go$
189156
text: Function 'fetchProcs' has too many statements
190157
- path: (.+)\.go$
@@ -195,8 +162,6 @@ linters:
195162
text: cognitive complexity .* of func .*conditionAdd
196163
- path: (.+)\.go$
197164
text: cognitive complexity .* of func .*.matchSingle
198-
- path: (.+)\.go$
199-
text: cognitive complexity .* of func .*splitToken
200165
- path: (.+)\.go$
201166
text: cognitive complexity .* of func .*ReplaceConditionals
202167
- path: (.+)\.go$
@@ -223,8 +188,6 @@ linters:
223188
text: parameter name 'a' is too short for the scope of its usage
224189
- path: (.+)\.go$
225190
text: parameter name 'b' is too short for the scope of its usage
226-
- path: (.+)\.go$
227-
text: .execCommand` - `timeout` always receives `DefaultCmdTimeout
228191
- path: (.+)\.go$
229192
text: 'fieldalignment: struct'
230193
- path: (.+)(utils|utils_test|fieldsn|asciiTable)\.go$
@@ -241,11 +204,10 @@ linters:
241204
text: 'string literal contains rune in Han script'
242205
- path: (.+)condition\.go$
243206
text: 'stringscutprefix:'
207+
- path: (.+)/(check_files|check_tasksched)\.go$
208+
text: 'SA4023'
244209
paths:
245210
- pkg/pdh/pdh.go
246-
- third_party$
247-
- builtin$
248-
- examples$
249211
issues:
250212
max-issues-per-linter: 0
251213
max-same-issues: 0
@@ -255,8 +217,3 @@ formatters:
255217
- goimports
256218
exclusions:
257219
generated: lax
258-
paths:
259-
- pkg/pdh/pdh.go
260-
- third_party$
261-
- builtin$
262-
- examples$

Changes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
This file documents the revision history for the SNClient agent.
22

3-
next:
3+
0.41 Fri Dec 19 19:16:59 CET 2025
44
- fix windows disk/mount checks showing only the first drive
55

66
0.40 Wed Dec 17 14:07:35 CET 2025

docs/configuration/_index.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,15 +210,26 @@ Supported macro variants:
210210
- `%(macro name)`
211211
- all variants of `$` / `%` and `{}` / `()` are interchangeable
212212
213-
Available macros are:
214-
215-
- `${exe-path}`
216-
- `${shared-path}`
217-
- `${scripts}`
218-
- `${certificate-path}`
219-
- `${hostname}`
220-
221-
Basically the values from the `[/paths]` section and the hostname.
213+
### Available Macros
214+
215+
Basically all the values from the `[/paths]` section are available as macros
216+
plus some more.
217+
218+
List of available macros:
219+
220+
| Suffix | Example | Description |
221+
| --------------------- | ------------------------------------------ | ------------------------------------------------|
222+
| `${certificate-path}` | usually `${shared-path}` | Directory of certificates (set by snclient.ini) |
223+
| `${exe-file}` | snclient or snclient.exe | Basename of executable |
224+
| `${exe-full}` | /usr/bin/snclient | Full path to executable |
225+
| `${exe-path}` | /usr/bin or c:\Program Files\snclient | Directory of executable |
226+
| `${file-ext}` | .exe or empty | File extension of agents executable file |
227+
| `${goarch}` | x86_64, aarch64, i386, ... | The value of Golangs runtime.GOARCH |
228+
| `${goos}` | linux, windows, darwin, ... | The value of Golangs runtime.GOOS |
229+
| `${hostname}` | machine.local | Name of the host running the agent |
230+
| `${pkgarch}` | amd64, arm64, 386, ... | Architecture as used in package file names |
231+
| `${scripts}` | usually `${shared-path}/scripts` | Directory of script files (set by snclient.ini) |
232+
| `${shared-path}` | /etc/snclient or c:\Program Files\snclient | Directory of shared files (set by snclient.ini) |
222233
223234
## On Demand Macros
224235

pkg/pdh/pdh.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build windows
6-
// +build windows
76

87
package pdh
98

pkg/snclient/check_drivesize_windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,14 @@ func (l *CheckDrivesize) setDeviceInfo(drive map[string]string) {
251251
drive["removable"] = "1"
252252
}
253253

254-
volumeName := make([]uint16, 512)
254+
volumeName := make([]uint16, windows.MAX_PATH+1)
255255
volumeNameLen, err := convert.UInt32E(len(volumeName))
256256
if err != nil {
257257
drive["_error"] = fmt.Sprintf("cannot set length of volume name: %s", err.Error())
258258

259259
return
260260
}
261-
fileSystemName := make([]uint16, 512)
261+
fileSystemName := make([]uint16, windows.MAX_PATH+1)
262262
fileSystemNameLen, err := convert.UInt32E(len(fileSystemName))
263263
if err != nil {
264264
drive["_error"] = fmt.Sprintf("cannot set length of filesystem name: %s", err.Error())

pkg/snclient/check_files.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,9 +418,12 @@ func (l *CheckFiles) normalizePath(path string) string {
418418
// Files directly under the drive do not have seperators, e.g: C:pagefile.sys
419419
// This confuses the depth calculation
420420
if runtime.GOOS == "windows" {
421+
// C: -> C:\
422+
if len(path) == 2 && unicode.IsUpper(rune(path[0])) && path[1] == ':' {
423+
// Ensure drive letters always have a backslash: "C:" -> "C:\"
424+
return path + string(os.PathSeparator)
425+
}
421426
// "C:example" -> "C:\example".
422-
// Do not change if its just the drive letter. D: -> D:
423-
// Otherwise 'D:\' and 'D:\example' would have the same number of seperators, even though the file is under the D: "directory" and should have increased depth
424427
if len(path) >= 3 && unicode.IsUpper(rune(path[0])) && path[1] == ':' && path[2] != '\\' {
425428
winBasePath := path[:2] + string('\\') + path[2:]
426429

@@ -434,6 +437,7 @@ func (l *CheckFiles) normalizePath(path string) string {
434437
// getDepth returns path depth starting at 0 with for the basePath
435438
func (l *CheckFiles) getDepth(path, basePath string) int64 {
436439
// both the path and BasePath are normalized once according to CheckFiles.normalizePath()
440+
437441
// Windows example:
438442
// basePath: C:\foo
439443
// path: C:\foo -> 0
@@ -452,9 +456,21 @@ func (l *CheckFiles) getDepth(path, basePath string) int64 {
452456

453457
subPath := strings.TrimPrefix(path, basePath)
454458
seperatorCount := int64(strings.Count(subPath, string(os.PathSeparator)))
455-
depth := seperatorCount
459+
depthCorrection := 0
460+
461+
// On Windows specifically, the paths have a problem when basePath is a drive letter.
462+
// basePath: C:\
463+
// path: C:\pagefile.sys -> 0 seperators , even though it is under the drive.
464+
// path: C:\Windows\notepad.exe -> 1 seperators, even though it is under the Windows folder.
465+
// If you consider the drive itself as a folder, stuff under it should have depth
466+
if runtime.GOOS == "windows" && len(basePath) == 3 && unicode.IsUpper(rune(path[0])) && path[1] == ':' && path[2] == '\\' {
467+
depthCorrection++
468+
}
469+
// Implement something similar in Unixes?
470+
471+
depth := seperatorCount + int64(depthCorrection)
456472

457-
log.Tracef("path: %s, basePath: %s, subPath: %s, seperatorCount: %d, depth: %d", path, basePath, subPath, seperatorCount, depth)
473+
log.Tracef("path: %s, basePath: %s, subPath: %s, seperatorCount: %d, depthCorrection: %d, depth: %d", path, basePath, subPath, seperatorCount, depthCorrection, depth)
458474

459475
return depth
460476
}
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
//go:build linux
2-
31
package snclient
42

53
import (

0 commit comments

Comments
 (0)