From 3df964dadfa1cc62f3dbf4d18c8927260322fc06 Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Thu, 6 Aug 2026 10:41:43 +0200 Subject: [PATCH 1/7] check_mount: support checking multiple drives change the argument to be an []string and adjust loops in the code relating to mount checks --- pkg/snclient/check_mount.go | 66 +++++++++++++++++------------ pkg/snclient/check_mount_windows.go | 9 ++-- 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/pkg/snclient/check_mount.go b/pkg/snclient/check_mount.go index 48e68bd0..51a772d7 100644 --- a/pkg/snclient/check_mount.go +++ b/pkg/snclient/check_mount.go @@ -16,7 +16,7 @@ func init() { } type CheckMount struct { - mountPoint string + mountPoints []string expectOptions string expectFSType string } @@ -35,7 +35,7 @@ func (l *CheckMount) Build() *CheckData { State: CheckExitOK, }, args: map[string]CheckArgument{ - "mount": {value: &l.mountPoint, description: "The mount point to check"}, + "mount": {value: &l.mountPoints, description: "The mount point to check"}, "options": {value: &l.expectOptions, description: "The mount options to expect"}, "fstype": {value: &l.expectFSType, description: "The fstype to expect"}, }, @@ -61,10 +61,12 @@ func (l *CheckMount) Build() *CheckData { } } +//nolint:funlen // no need to split this up func (l *CheckMount) Check(ctx context.Context, _ *Agent, check *CheckData, _ []Argument) (*CheckResult, error) { - if len(l.mountPoint) > 1 { - l.mountPoint = strings.TrimSuffix(l.mountPoint, string(os.PathSeparator)) + for idx := range l.mountPoints { + l.mountPoints[idx] = trimTrailingSeparator(l.mountPoints[idx]) } + partitionMap := map[string]bool{} partitions, err := l.getDrives(ctx, partitionMap) if err != nil { @@ -121,16 +123,18 @@ func (l *CheckMount) Check(ctx context.Context, _ *Agent, check *CheckData, _ [] } // check if a mountpoint was supplied but not yet found - if l.mountPoint != "" { - if _, ok := partitionMap[l.mountPoint]; !ok { - entry := map[string]string{ - "mount": l.mountPoint, - "device": "", - "fstype": "", - "options": "", - "issues": "not mounted", + if len(l.mountPoints) > 0 { + for _, mountPoint := range l.mountPoints { + if _, ok := partitionMap[mountPoint]; !ok { + entry := map[string]string{ + "mount": mountPoint, + "device": "", + "fstype": "", + "options": "", + "issues": "not mounted", + } + check.listData = append(check.listData, entry) } - check.listData = append(check.listData, entry) } } @@ -147,42 +151,43 @@ func (l *CheckMount) getDrives(ctx context.Context, partitionMap map[string]bool for i := range partitions { partition := partitions[i] - partitionMap[partition.Mountpoint] = true - if l.mountPoint != "" { - if partition.Mountpoint != l.mountPoint { - log.Tracef("skipped mountpoint: %s - not matching mount argument", partition.Mountpoint) + mountpoint := trimTrailingSeparator(partition.Mountpoint) + partitionMap[mountpoint] = true + if len(l.mountPoints) > 0 { + if !slices.Contains(l.mountPoints, mountpoint) { + log.Tracef("skipped mountpoint: %s - not matching mount argument", mountpoint) continue } } else { // skip internal filesystems if slices.Contains(excludes, partition.Fstype) { - log.Tracef("skipped mountpoint: %s - fstype %s is excluded", partition.Mountpoint, partition.Fstype) + log.Tracef("skipped mountpoint: %s - fstype %s is excluded", mountpoint, partition.Fstype) continue } // skip some know internal locations switch { - case strings.HasPrefix(partition.Mountpoint, "/run"), - strings.HasPrefix(partition.Mountpoint, "/proc"), - strings.HasPrefix(partition.Mountpoint, "/sys"), - strings.HasPrefix(partition.Mountpoint, "/dev"): + case strings.HasPrefix(mountpoint, "/run"), + strings.HasPrefix(mountpoint, "/proc"), + strings.HasPrefix(mountpoint, "/sys"), + strings.HasPrefix(mountpoint, "/dev"): - log.Tracef("skipped mountpoint: %s - prefix matched internal system mounts", partition.Mountpoint) + log.Tracef("skipped mountpoint: %s - prefix matched internal system mounts", mountpoint) continue } } - if partition.Fstype == "" && partition.Device == "" && partition.Mountpoint == "" { - log.Tracef("skipped mountpoint: %s - empty device, fstype and mountpoint", partition.Mountpoint) + if partition.Fstype == "" && partition.Device == "" && mountpoint == "" { + log.Tracef("skipped mountpoint: %s - empty device, fstype and mountpoint", mountpoint) continue } device := utils.ReplaceCommonPasswordPattern(partition.Device) entry := map[string]string{ - "mount": partition.Mountpoint, + "mount": mountpoint, "device": device, "fstype": partition.Fstype, "options": strings.Join(partition.Opts, ","), @@ -193,3 +198,12 @@ func (l *CheckMount) getDrives(ctx context.Context, partitionMap map[string]bool return drives, nil } + +// trimTrailingSeparator removes a trailing path separator, but keeps a single-character mountpoint like "/" or "C:" intact so that it stays a valid root path. +func trimTrailingSeparator(path string) string { + if len(path) > 1 { + return strings.TrimSuffix(path, string(os.PathSeparator)) + } + + return path +} diff --git a/pkg/snclient/check_mount_windows.go b/pkg/snclient/check_mount_windows.go index bc205369..20966736 100644 --- a/pkg/snclient/check_mount_windows.go +++ b/pkg/snclient/check_mount_windows.go @@ -2,9 +2,7 @@ package snclient import ( "context" - "os" "slices" - "strings" ) // getVolumes retrieves volumes and their details, excluding specified partitions, and returns a list of drives and any potential errors. @@ -26,16 +24,19 @@ func (l *CheckMount) getVolumes(ctx context.Context, check *CheckData, partition continue } } - mountPoint := strings.TrimSuffix(partition["drive_or_id"], string(os.PathSeparator)) + + mountPoint := trimTrailingSeparator(partition["drive_or_name"]) if _, ok := partitionMap[mountPoint]; ok { continue } + partitionMap[mountPoint] = true - if l.mountPoint != "" && mountPoint != l.mountPoint { + if len(l.mountPoints) > 0 && !slices.Contains(l.mountPoints, mountPoint) { log.Tracef("skipped mountpoint: %s - not matching mount argument", mountPoint) continue } + // skip internal filesystems if slices.Contains(excludes, partition["fstype"]) { log.Tracef("skipped mountpoint: %s - fstype %s is excluded", mountPoint, partition["fstype"]) From 4df87ee3d6e8dac253509f6a228688c30b2ba15d Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Thu, 6 Aug 2026 10:43:10 +0200 Subject: [PATCH 2/7] check_mount: ai assisted , add tests for multiple mounts --- pkg/snclient/check_mount_test.go | 63 ++++++++++++++++++++++++ pkg/snclient/check_mount_windows_test.go | 38 ++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 pkg/snclient/check_mount_windows_test.go diff --git a/pkg/snclient/check_mount_test.go b/pkg/snclient/check_mount_test.go index 69c50976..9f427548 100644 --- a/pkg/snclient/check_mount_test.go +++ b/pkg/snclient/check_mount_test.go @@ -32,3 +32,66 @@ func TestMount(t *testing.T) { StopTestAgent(t, snc) } + +func TestMountNoMountArgument(t *testing.T) { + snc := StartTestAgent(t, "") + + // mount= left empty means all mounts are checked + res := snc.RunCheck("check_mount", []string{}) + assert.Equalf(t, CheckExitOK, res.State, "state OK") + assert.Contains(t, string(res.BuildPluginOutput()), "OK - mounts are as expected", "output matches") + + StopTestAgent(t, snc) +} + +func TestMountMultipleMounts(t *testing.T) { + snc := StartTestAgent(t, "") + + inv, err := snc.getInventoryEntry(t.Context(), "check_mount") + require.NoError(t, err) + require.NotEmptyf(t, inv, "expected mounts list to be non-empty") + + realMounts := []string{} + for _, entry := range inv { + if entry["mount"] != "" { + realMounts = append(realMounts, entry["mount"]) + } + } + require.NotEmptyf(t, realMounts, "expected at least one mount") + + // checking multiple existing mounts at once must be ok + args := make([]string, 0, min(len(realMounts), 3)+1) + for _, mount := range realMounts[:min(len(realMounts), 3)] { + args = append(args, "mount="+mount) + } + res := snc.RunCheck("check_mount", args) + assert.Equalf(t, CheckExitOK, res.State, "state OK") + assert.Contains(t, string(res.BuildPluginOutput()), "OK - mounts are as expected", "output matches") + + // if one of them is missing, the whole check must raise critical + missing := "not_mounted_xyz" + if runtime.GOOS == "windows" { + missing = `\\?\Volume{ffffffff-ffff-ffff-ffff-ffffffffffff}` + } + res = snc.RunCheck("check_mount", append(args, "mount="+missing)) + assert.Equalf(t, CheckExitCritical, res.State, "state Critical") + assert.Contains(t, string(res.BuildPluginOutput()), "mount "+missing+" not mounted", "output matches") + + StopTestAgent(t, snc) +} + +func TestMountSingleSpecifiedMount(t *testing.T) { + snc := StartTestAgent(t, "") + + if runtime.GOOS == "windows" { + res := snc.RunCheck("check_mount", []string{"mount=C:\\"}) + assert.Equalf(t, CheckExitOK, res.State, "state OK") + assert.Contains(t, string(res.BuildPluginOutput()), "OK - mounts are as expected", "output matches") + } else { + res := snc.RunCheck("check_mount", []string{"mount=/"}) + assert.Equalf(t, CheckExitOK, res.State, "state OK") + assert.Contains(t, string(res.BuildPluginOutput()), "OK - mounts are as expected", "output matches") + } + + StopTestAgent(t, snc) +} diff --git a/pkg/snclient/check_mount_windows_test.go b/pkg/snclient/check_mount_windows_test.go new file mode 100644 index 00000000..69bc249c --- /dev/null +++ b/pkg/snclient/check_mount_windows_test.go @@ -0,0 +1,38 @@ +//go:build windows + +package snclient + +import ( + "regexp" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// TestMountWindowsNoDuplicateEntries makes sure a drive that is reported by both +// the partition discovery (getDrives) and +// the volume discovery (getVolumes) +// is only listed once in the output. +func TestMountWindowsNoDuplicateEntries(t *testing.T) { + snc := StartTestAgent(t, "") + + // force every entry into the problem list so all mounts end up in the output + res := snc.RunCheck("check_mount", []string{"options=force-mount-listing", "detail-syntax=mount=${mount}"}) + assert.Equalf(t, CheckExitWarning, res.State, "state Warning") + output := string(res.BuildPluginOutput()) + + mountRe := regexp.MustCompile(`mount (\S+)`) + mountSeen := map[string]int{} + for _, match := range mountRe.FindAllStringSubmatch(output, -1) { + mountSeen[match[1]]++ + } + + require.NotEmptyf(t, mountSeen, "expected at least one mount in output") + + for mount, count := range mountSeen { + assert.Equalf(t, 1, count, "mount %s reported %d times, expected exactly once", mount, count) + } + + StopTestAgent(t, snc) +} From 1821e273ca5630b8d8c0030a574b752df439a1ae Mon Sep 17 00:00:00 2001 From: Ahmet Ozturk Date: Thu, 6 Aug 2026 11:02:08 +0200 Subject: [PATCH 3/7] check_mount: fix failing windows duplicate drive/volume check due to regex problem --- pkg/snclient/check_mount_windows_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/snclient/check_mount_windows_test.go b/pkg/snclient/check_mount_windows_test.go index 69bc249c..a6ae31b0 100644 --- a/pkg/snclient/check_mount_windows_test.go +++ b/pkg/snclient/check_mount_windows_test.go @@ -18,11 +18,11 @@ func TestMountWindowsNoDuplicateEntries(t *testing.T) { snc := StartTestAgent(t, "") // force every entry into the problem list so all mounts end up in the output - res := snc.RunCheck("check_mount", []string{"options=force-mount-listing", "detail-syntax=mount=${mount}"}) - assert.Equalf(t, CheckExitWarning, res.State, "state Warning") + res := snc.RunCheck("check_mount", []string{"detail-syntax=mount=${mount}", "show-all"}) + assert.Equalf(t, CheckExitOK, res.State, "state OK") output := string(res.BuildPluginOutput()) - mountRe := regexp.MustCompile(`mount (\S+)`) + mountRe := regexp.MustCompile(`mount=(\S+)`) mountSeen := map[string]int{} for _, match := range mountRe.FindAllStringSubmatch(output, -1) { mountSeen[match[1]]++ From dc9a221c31420e4d68eaf6c7fae42f3b1f8d3502 Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Thu, 6 Aug 2026 11:13:10 +0200 Subject: [PATCH 4/7] check_mount: change the okSyntax to include mount counts --- pkg/snclient/check_mount.go | 4 ++-- pkg/snclient/check_mount_test.go | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/snclient/check_mount.go b/pkg/snclient/check_mount.go index 51a772d7..79dfd52a 100644 --- a/pkg/snclient/check_mount.go +++ b/pkg/snclient/check_mount.go @@ -40,7 +40,7 @@ func (l *CheckMount) Build() *CheckData { "fstype": {value: &l.expectFSType, description: "The fstype to expect"}, }, detailSyntax: "mount ${mount} ${issues}", - okSyntax: "${status} - mounts are as expected", + okSyntax: "${status} - ${count} mount(s) as expected", topSyntax: "${status} - ${problem_list}", defaultWarning: "issues != ''", defaultCritical: "issues like 'not mounted'", @@ -55,7 +55,7 @@ func (l *CheckMount) Build() *CheckData { }, exampleDefault: ` check_mount mount=/ options=rw,relatime fstype=ext4 - OK - mounts are as expected + OK - 3 mounts(s) are as expected `, exampleArgs: `'mount=/' 'options=rw,relatime'`, } diff --git a/pkg/snclient/check_mount_test.go b/pkg/snclient/check_mount_test.go index 9f427548..2910fc8b 100644 --- a/pkg/snclient/check_mount_test.go +++ b/pkg/snclient/check_mount_test.go @@ -21,14 +21,14 @@ func TestMount(t *testing.T) { res = snc.RunCheck("check_mount", []string{"mount=/"}) } assert.Equalf(t, CheckExitOK, res.State, "state OK") - assert.Contains(t, string(res.BuildPluginOutput()), "OK - mounts are as expected", "output matches") + assert.Contains(t, string(res.BuildPluginOutput()), "OK - 1 mount(s) as expected", "output matches") inv, err := snc.getInventoryEntry(t.Context(), "check_mount") require.NoError(t, err) require.NotEmptyf(t, inv, "expected mounts list to be non-empty") res = snc.RunCheck("check_mount", []string{"mount=" + inv[0]["mount"], "options=" + inv[0]["options"], "fstype=" + inv[0]["fstype"]}) assert.Equalf(t, CheckExitOK, res.State, "state OK") - assert.Contains(t, string(res.BuildPluginOutput()), "OK - mounts are as expected", "output matches") + assert.Contains(t, string(res.BuildPluginOutput()), "OK - 1 mount(s) as expected", "output matches") StopTestAgent(t, snc) } @@ -39,7 +39,7 @@ func TestMountNoMountArgument(t *testing.T) { // mount= left empty means all mounts are checked res := snc.RunCheck("check_mount", []string{}) assert.Equalf(t, CheckExitOK, res.State, "state OK") - assert.Contains(t, string(res.BuildPluginOutput()), "OK - mounts are as expected", "output matches") + assert.Regexp(t, `OK - [\d]+ mount\(s\) as expected`, string(res.BuildPluginOutput()), "output matches") StopTestAgent(t, snc) } @@ -66,7 +66,7 @@ func TestMountMultipleMounts(t *testing.T) { } res := snc.RunCheck("check_mount", args) assert.Equalf(t, CheckExitOK, res.State, "state OK") - assert.Contains(t, string(res.BuildPluginOutput()), "OK - mounts are as expected", "output matches") + assert.Regexp(t, `OK - [\d]+ mount\(s\) as expected`, string(res.BuildPluginOutput()), "output matches") // if one of them is missing, the whole check must raise critical missing := "not_mounted_xyz" @@ -86,11 +86,11 @@ func TestMountSingleSpecifiedMount(t *testing.T) { if runtime.GOOS == "windows" { res := snc.RunCheck("check_mount", []string{"mount=C:\\"}) assert.Equalf(t, CheckExitOK, res.State, "state OK") - assert.Contains(t, string(res.BuildPluginOutput()), "OK - mounts are as expected", "output matches") + assert.Contains(t, string(res.BuildPluginOutput()), "OK - 1 mount(s) as expected", "output matches") } else { res := snc.RunCheck("check_mount", []string{"mount=/"}) assert.Equalf(t, CheckExitOK, res.State, "state OK") - assert.Contains(t, string(res.BuildPluginOutput()), "OK - mounts are as expected", "output matches") + assert.Contains(t, string(res.BuildPluginOutput()), "OK - 1 mount(s) as expected", "output matches") } StopTestAgent(t, snc) From bd4d121db04cdd36f92db618cb31f220c2037866 Mon Sep 17 00:00:00 2001 From: Ahmet Ozturk Date: Thu, 6 Aug 2026 11:18:42 +0200 Subject: [PATCH 5/7] check_mount: fix the example output of check and add windows example --- pkg/snclient/check_mount.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/snclient/check_mount.go b/pkg/snclient/check_mount.go index 79dfd52a..74373fc8 100644 --- a/pkg/snclient/check_mount.go +++ b/pkg/snclient/check_mount.go @@ -54,8 +54,14 @@ func (l *CheckMount) Build() *CheckData { {name: "issues", description: "Issues found"}, }, exampleDefault: ` - check_mount mount=/ options=rw,relatime fstype=ext4 - OK - 3 mounts(s) are as expected + check_mount + OK - 3 mounts(s) as expected + + check_mount mount=/ options=rw,relatime fstype=ext4 + OK - 1 mount(s) as expected + + check_mount mount=X: + CRITICAL - mount X: not mounted `, exampleArgs: `'mount=/' 'options=rw,relatime'`, } From ae799225f3ffc636c2d7e7170fc9493ac12c58d8 Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Thu, 6 Aug 2026 11:19:15 +0200 Subject: [PATCH 6/7] check_mount: make docs --- docs/checks/commands/check_mount.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/checks/commands/check_mount.md b/docs/checks/commands/check_mount.md index be807fc3..b6547230 100644 --- a/docs/checks/commands/check_mount.md +++ b/docs/checks/commands/check_mount.md @@ -20,8 +20,14 @@ Checks the status for a mounted filesystem ### Default Check - check_mount mount=/ options=rw,relatime fstype=ext4 - OK - mounts are as expected + check_mount + OK - 3 mounts(s) as expected + + check_mount mount=/ options=rw,relatime fstype=ext4 + OK - 1 mount(s) as expected + + check_mount mount=X: + CRITICAL - mount X: not mounted ### Example using NRPE and Naemon @@ -48,7 +54,7 @@ Naemon Config | empty-state | 3 (UNKNOWN) | | empty-syntax | check_mount failed to find anything with this filter. | | top-syntax | \${status} - \${problem_list} | -| ok-syntax | \${status} - mounts are as expected | +| ok-syntax | \${status} - \${count} mount(s) as expected | | detail-syntax | mount \${mount} \${issues} | ## Check Specific Arguments From 2451b3a9a9b54604e26ea407c26d9f8b8e55e36f Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Thu, 6 Aug 2026 16:08:01 +0200 Subject: [PATCH 7/7] check_mount: change okSyntax to: '%{status} - ${count} mount(s) found" return unknown if no mount, options and fstype arguments are specified, and the check is naked: UNKNOWN - must specify at least one of mount/options/fstype --- docs/checks/commands/check_mount.md | 6 +++--- pkg/snclient/check_mount.go | 10 +++++++--- pkg/snclient/check_mount_test.go | 14 +++++++------- pkg/snclient/check_mount_windows_test.go | 2 +- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/docs/checks/commands/check_mount.md b/docs/checks/commands/check_mount.md index b6547230..2bbf9947 100644 --- a/docs/checks/commands/check_mount.md +++ b/docs/checks/commands/check_mount.md @@ -21,10 +21,10 @@ Checks the status for a mounted filesystem ### Default Check check_mount - OK - 3 mounts(s) as expected + OK - 3 mounts(s) found check_mount mount=/ options=rw,relatime fstype=ext4 - OK - 1 mount(s) as expected + OK - 1 mount(s) found check_mount mount=X: CRITICAL - mount X: not mounted @@ -54,7 +54,7 @@ Naemon Config | empty-state | 3 (UNKNOWN) | | empty-syntax | check_mount failed to find anything with this filter. | | top-syntax | \${status} - \${problem_list} | -| ok-syntax | \${status} - \${count} mount(s) as expected | +| ok-syntax | \${status} - \${count} mount(s) found | | detail-syntax | mount \${mount} \${issues} | ## Check Specific Arguments diff --git a/pkg/snclient/check_mount.go b/pkg/snclient/check_mount.go index 74373fc8..b48e7575 100644 --- a/pkg/snclient/check_mount.go +++ b/pkg/snclient/check_mount.go @@ -40,7 +40,7 @@ func (l *CheckMount) Build() *CheckData { "fstype": {value: &l.expectFSType, description: "The fstype to expect"}, }, detailSyntax: "mount ${mount} ${issues}", - okSyntax: "${status} - ${count} mount(s) as expected", + okSyntax: "${status} - ${count} mount(s) found", topSyntax: "${status} - ${problem_list}", defaultWarning: "issues != ''", defaultCritical: "issues like 'not mounted'", @@ -55,10 +55,10 @@ func (l *CheckMount) Build() *CheckData { }, exampleDefault: ` check_mount - OK - 3 mounts(s) as expected + OK - 3 mounts(s) found check_mount mount=/ options=rw,relatime fstype=ext4 - OK - 1 mount(s) as expected + OK - 1 mount(s) found check_mount mount=X: CRITICAL - mount X: not mounted @@ -69,6 +69,10 @@ func (l *CheckMount) Build() *CheckData { //nolint:funlen // no need to split this up func (l *CheckMount) Check(ctx context.Context, _ *Agent, check *CheckData, _ []Argument) (*CheckResult, error) { + if check.output != OutputInventory && len(l.mountPoints) == 0 && l.expectOptions == "" && l.expectFSType == "" { + return nil, fmt.Errorf("must specify at least one of mount/options/fstype") + } + for idx := range l.mountPoints { l.mountPoints[idx] = trimTrailingSeparator(l.mountPoints[idx]) } diff --git a/pkg/snclient/check_mount_test.go b/pkg/snclient/check_mount_test.go index 2910fc8b..49b01ff5 100644 --- a/pkg/snclient/check_mount_test.go +++ b/pkg/snclient/check_mount_test.go @@ -21,14 +21,14 @@ func TestMount(t *testing.T) { res = snc.RunCheck("check_mount", []string{"mount=/"}) } assert.Equalf(t, CheckExitOK, res.State, "state OK") - assert.Contains(t, string(res.BuildPluginOutput()), "OK - 1 mount(s) as expected", "output matches") + assert.Contains(t, string(res.BuildPluginOutput()), "OK - 1 mount(s) found", "output matches") inv, err := snc.getInventoryEntry(t.Context(), "check_mount") require.NoError(t, err) require.NotEmptyf(t, inv, "expected mounts list to be non-empty") res = snc.RunCheck("check_mount", []string{"mount=" + inv[0]["mount"], "options=" + inv[0]["options"], "fstype=" + inv[0]["fstype"]}) assert.Equalf(t, CheckExitOK, res.State, "state OK") - assert.Contains(t, string(res.BuildPluginOutput()), "OK - 1 mount(s) as expected", "output matches") + assert.Contains(t, string(res.BuildPluginOutput()), "OK - 1 mount(s) found", "output matches") StopTestAgent(t, snc) } @@ -38,8 +38,8 @@ func TestMountNoMountArgument(t *testing.T) { // mount= left empty means all mounts are checked res := snc.RunCheck("check_mount", []string{}) - assert.Equalf(t, CheckExitOK, res.State, "state OK") - assert.Regexp(t, `OK - [\d]+ mount\(s\) as expected`, string(res.BuildPluginOutput()), "output matches") + assert.Equalf(t, CheckExitUnknown, res.State, "state UNKNOWN") + assert.Equalf(t, "UNKNOWN - must specify at least one of mount/options/fstype", string(res.BuildPluginOutput()), "output matches") StopTestAgent(t, snc) } @@ -66,7 +66,7 @@ func TestMountMultipleMounts(t *testing.T) { } res := snc.RunCheck("check_mount", args) assert.Equalf(t, CheckExitOK, res.State, "state OK") - assert.Regexp(t, `OK - [\d]+ mount\(s\) as expected`, string(res.BuildPluginOutput()), "output matches") + assert.Regexp(t, `OK - [\d]+ mount\(s\) found`, string(res.BuildPluginOutput()), "output matches") // if one of them is missing, the whole check must raise critical missing := "not_mounted_xyz" @@ -86,11 +86,11 @@ func TestMountSingleSpecifiedMount(t *testing.T) { if runtime.GOOS == "windows" { res := snc.RunCheck("check_mount", []string{"mount=C:\\"}) assert.Equalf(t, CheckExitOK, res.State, "state OK") - assert.Contains(t, string(res.BuildPluginOutput()), "OK - 1 mount(s) as expected", "output matches") + assert.Contains(t, string(res.BuildPluginOutput()), "OK - 1 mount(s) found", "output matches") } else { res := snc.RunCheck("check_mount", []string{"mount=/"}) assert.Equalf(t, CheckExitOK, res.State, "state OK") - assert.Contains(t, string(res.BuildPluginOutput()), "OK - 1 mount(s) as expected", "output matches") + assert.Contains(t, string(res.BuildPluginOutput()), "OK - 1 mount(s) found", "output matches") } StopTestAgent(t, snc) diff --git a/pkg/snclient/check_mount_windows_test.go b/pkg/snclient/check_mount_windows_test.go index a6ae31b0..24877aac 100644 --- a/pkg/snclient/check_mount_windows_test.go +++ b/pkg/snclient/check_mount_windows_test.go @@ -18,7 +18,7 @@ func TestMountWindowsNoDuplicateEntries(t *testing.T) { snc := StartTestAgent(t, "") // force every entry into the problem list so all mounts end up in the output - res := snc.RunCheck("check_mount", []string{"detail-syntax=mount=${mount}", "show-all"}) + res := snc.RunCheck("check_mount", []string{"detail-syntax=mount=${mount}", "fstype=NTFS", "show-all"}) assert.Equalf(t, CheckExitOK, res.State, "state OK") output := string(res.BuildPluginOutput())