Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Allow agents to include filtered disk mounts

[email protected]4dac4dd16312
diff --git a/cmd/pulse-agent/main.go b/cmd/pulse-agent/main.go
index f3661bf23b..b215f9e3ad 100644
--- a/cmd/pulse-agent/main.go
+++ b/cmd/pulse-agent/main.go
@@ -417,6 +417,7 @@ func run(ctx context.Context, args []string, getenv func(string) string) error {
EnableCommands: cfg.EnableCommands,
Enroll: cfg.Enroll,
DiskExclude: cfg.DiskExclude,
+ DiskInclude: cfg.DiskInclude,
StateDir: cfg.StateDir,
ReportIP: cfg.ReportIP,
DisableCeph: cfg.DisableCeph,
@@ -469,6 +470,7 @@ func run(ctx context.Context, args []string, getenv func(string) string) error {
IncludeTasks: true,
CollectDiskMetrics: false,
DiskExclude: cfg.DiskExclude,
+ DiskInclude: cfg.DiskInclude,
Targets: dockerReportTargets(cfg),
}
@@ -855,6 +857,7 @@ type Config struct {
// Disk filtering
DiskExclude []string // Mount points or patterns to exclude from disk monitoring
+ DiskInclude []string // Devices or mount points to opt into monitoring despite automatic filtering
// Network configuration
ReportIP string // IP address to report (for multi-NIC systems)
@@ -988,6 +991,7 @@ func loadConfig(args []string, getenv func(string) string) (Config, error) {
envKubeMaxPods := strings.TrimSpace(getenv("PULSE_KUBE_MAX_PODS"))
envStateDir := strings.TrimSpace(getenv("PULSE_STATE_DIR"))
envDiskExclude := strings.TrimSpace(getenv("PULSE_DISK_EXCLUDE"))
+ envDiskInclude := strings.TrimSpace(getenv("PULSE_DISK_INCLUDE"))
envReportIP := strings.TrimSpace(getenv("PULSE_REPORT_IP"))
envDisableCeph := strings.TrimSpace(getenv("PULSE_DISABLE_CEPH"))
envObserversFile := strings.TrimSpace(getenv("PULSE_OBSERVERS_FILE"))
@@ -1082,6 +1086,8 @@ func loadConfig(args []string, getenv func(string) string) (Config, error) {
fs.Var(&kubeExcludeNamespaceFlags, "kube-exclude-namespace", "Namespace to exclude (repeatable)")
var diskExcludeFlags multiValue
fs.Var(&diskExcludeFlags, "disk-exclude", "Device name/path or mount point pattern to exclude from disk monitoring (repeatable)")
+ var diskIncludeFlags multiValue
+ fs.Var(&diskIncludeFlags, "disk-include", "Device name/path or mount point pattern to include despite automatic filesystem filtering (repeatable)")
if err := fs.Parse(args); err != nil {
return Config{}, err
@@ -1161,6 +1167,7 @@ func loadConfig(args []string, getenv func(string) string) (Config, error) {
kubeIncludeNamespaces := gatherCSV(envKubeIncludeNamespaces, kubeIncludeNamespaceFlags)
kubeExcludeNamespaces := gatherCSV(envKubeExcludeNamespaces, kubeExcludeNamespaceFlags)
diskExclude := gatherCSV(envDiskExclude, diskExcludeFlags)
+ diskInclude := gatherCSV(envDiskInclude, diskIncludeFlags)
// Check if Docker was explicitly configured via fs or env. An explicit
// local disable is a privacy boundary and cannot be reversed by remote
@@ -1222,6 +1229,7 @@ func loadConfig(args []string, getenv func(string) string) (Config, error) {
KubeMaxPods: kubeMaxPods,
StateDir: stateDir,
DiskExclude: diskExclude,
+ DiskInclude: diskInclude,
ReportIP: strings.TrimSpace(*reportIPFlag),
DisableCeph: *disableCephFlag,
SelfTest: *selfTest,
diff --git a/cmd/pulse-agent/main_test.go b/cmd/pulse-agent/main_test.go
index b41c3cea37..3bb89c0061 100644
--- a/cmd/pulse-agent/main_test.go
+++ b/cmd/pulse-agent/main_test.go
@@ -1155,19 +1155,22 @@ func TestLoadConfig(t *testing.T) {
}
})
- t.Run("tags and repeated disk exclusions", func(t *testing.T) {
+ t.Run("tags and repeated disk filters", func(t *testing.T) {
cfg, err := loadConfig([]string{
"-token", "T",
"-tag", "t1",
"-tag", "t2",
"-disk-exclude", "sdb",
"-disk-exclude", "/mnt/pve/local-backup",
+ "-disk-include", "/var/log",
}, func(s string) string {
switch s {
case "PULSE_TAGS":
return "e1,e2"
case "PULSE_DISK_EXCLUDE":
return "/dev/sda,/var/run/samba/fd"
+ case "PULSE_DISK_INCLUDE":
+ return "log2ram"
}
return ""
})
@@ -1182,6 +1185,10 @@ func TestLoadConfig(t *testing.T) {
if !reflect.DeepEqual(cfg.DiskExclude, expectedDisk) {
t.Errorf("expected disk exclude %v, got %v", expectedDisk, cfg.DiskExclude)
}
+ expectedIncludedDisk := []string{"log2ram", "/var/log"}
+ if !reflect.DeepEqual(cfg.DiskInclude, expectedIncludedDisk) {
+ t.Errorf("expected disk include %v, got %v", expectedIncludedDisk, cfg.DiskInclude)
+ }
})
}
diff --git a/docs/AGENT_SECURITY.md b/docs/AGENT_SECURITY.md
index efefa6e017..6aa4a2c0ea 100644
--- a/docs/AGENT_SECURITY.md
+++ b/docs/AGENT_SECURITY.md
@@ -35,6 +35,12 @@ directives reduce service blast radius while keeping the filesystem and device
access needed for full host telemetry, Proxmox token setup, SMART, Docker, and
NAS integrations.
+Disk monitoring normally filters pseudo-filesystems such as `tmpfs`. The local
+`--disk-include` option can opt a specific device or mount point back into
+capacity monitoring, for example a log2ram `/var/log` mount. This reports
+filesystem capacity and usage metadata. It does not read or transmit file
+contents. Local `--disk-exclude` rules still take precedence.
+
Command execution is disabled by default. It can be enabled with
`--enable-commands`, `PULSE_ENABLE_COMMANDS=true`, or the centralized agent
command setting after enrollment. Leave it disabled for read-only monitoring.
diff --git a/docs/UNIFIED_AGENT.md b/docs/UNIFIED_AGENT.md
index 3bbf335a9f..258c3f2dd3 100644
--- a/docs/UNIFIED_AGENT.md
+++ b/docs/UNIFIED_AGENT.md
@@ -305,6 +305,7 @@ sudo chmod 0700 /usr/local/libexec/pulse-queue-depth
| `--enable-commands` | `PULSE_ENABLE_COMMANDS` | Enable Pulse command execution: Docker / Podman container actions from the UI (start/stop/restart/update), Patrol actions, and Proxmox LXC Docker inventory (disabled by default) | `false` |
| `--disable-commands` | `PULSE_DISABLE_COMMANDS` | **Deprecated** (commands are disabled by default) | - |
| `--disk-exclude` | `PULSE_DISK_EXCLUDE` | Device name/path or mount point patterns to exclude from disk and S.M.A.R.T. monitoring (repeatable or CSV) | *(none)* |
+| `--disk-include` | `PULSE_DISK_INCLUDE` | Device name/path or mount point patterns to include despite automatic filesystem filtering (repeatable or CSV) | *(none)* |
| `--kubeconfig` | `PULSE_KUBECONFIG` | Kubeconfig path (optional) | *(auto)* |
| `--kube-context` | `PULSE_KUBE_CONTEXT` | Kubeconfig context (optional) | *(auto)* |
| `--kube-include-namespace` | `PULSE_KUBE_INCLUDE_NAMESPACES` | Limit namespaces (repeatable or CSV, wildcards supported) | *(all)* |
@@ -489,6 +490,23 @@ Exclusions are applied before filesystem usage, disk I/O, and S.M.A.R.T. collect
On linked Proxmox hosts, matching physical-disk health and SSD wear alerts are
also suppressed.
+### Include an Automatically Filtered Filesystem
+
+Pulse normally filters pseudo-filesystems such as `tmpfs` to keep system mounts
+out of disk monitoring. A specific mount can be opted back in when its capacity
+matters, such as a log2ram volume mounted at `/var/log`.
+
+```bash
+pulse-agent --disk-include /var/log
+
+# Via environment variable
+PULSE_DISK_INCLUDE=/var/log
+```
+
+Include patterns use the same exact, prefix, and contains matching rules as
+exclusions. They only override automatic filesystem filtering. An explicit
+`--disk-exclude` match still wins.
+
## S.M.A.R.T. Disk Health
The agent can report S.M.A.R.T. disk temperatures, health status, identity, and normalized health counters when running in Agent mode. This requires:
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index f386e97e92..507c5c229e 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -161,6 +161,12 @@ identity, validity, and trust are observation payloads only. They do not renew
the target lease, agent enrollment, host heartbeat, or command readiness beyond
the accepted report's existing server-receipt evidence.
+Explicit disk inclusion is an agent lifecycle input. The CLI, persisted
+service arguments, unified host agent, and Docker/Podman agent must carry the
+same include list to collection. Includes may opt a matching filesystem back
+in after Pulse's automatic pseudo-filesystem filtering, while an explicit
+operator exclusion remains authoritative.
+
## Canonical Files
1. `internal/api/agent_install_command_shared.go`
diff --git a/docs/release-control/v6/internal/subsystems/deployment-installability.md b/docs/release-control/v6/internal/subsystems/deployment-installability.md
index 474c627582..8b3405ac72 100644
--- a/docs/release-control/v6/internal/subsystems/deployment-installability.md
+++ b/docs/release-control/v6/internal/subsystems/deployment-installability.md
@@ -27,6 +27,11 @@ pin trusted proxy CIDRs to the provider network, block tenant bridge access to
cloud metadata endpoints at the host firewall when possible, and pin the Traefik
TLS floor in the dynamic config.
+Installer argument persistence includes repeated `--disk-include` values. An
+upgrade must recover those values from both split and `--key=value` service
+arguments and reproduce them in the generated systemd command without
+discarding existing explicit disk exclusions.
+
## Canonical Files
1. `internal/updates/`
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 682abe7e23..0816007cf1 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -387,6 +387,11 @@ on this path: agent ingest is not gated on `PULSE_MOCK_KEEP_REAL_POLLING`, and
the read state is mock-substituted either way, so injecting real hosts would
only graft them onto fixture data.
+Host and container-runtime disk collection supports an explicit include list
+for filesystems hidden by Pulse's automatic virtual/container filtering. The
+include list is bounded to that automatic filter; explicit disk exclusions
+still win and disk-I/O filtering retains its existing exclusion semantics.
+
## Canonical Files
1. `internal/monitoring/monitor.go`
diff --git a/docs/release-control/v6/internal/subsystems/security-privacy.md b/docs/release-control/v6/internal/subsystems/security-privacy.md
index b6b6bc9f09..96d27b6add 100644
--- a/docs/release-control/v6/internal/subsystems/security-privacy.md
+++ b/docs/release-control/v6/internal/subsystems/security-privacy.md
@@ -38,6 +38,11 @@ and target lists must remain local. Detection remains behind the existing
Pulse Pro availability entitlement; the push adapter cannot turn Relay access
into availability-probe entitlement.
+`cmd/pulse-agent/main.go` treats disk inclusion as explicit local operator
+configuration. It may override Pulse's automatic filesystem suppression only;
+it must not override a matching operator exclusion or introduce remote
+authority to expand the reported filesystem set silently.
+
## Canonical Files
1. `SECURITY.md`
diff --git a/frontend-modern/public/docs/AGENT_SECURITY.md b/frontend-modern/public/docs/AGENT_SECURITY.md
index efefa6e017..6aa4a2c0ea 100644
--- a/frontend-modern/public/docs/AGENT_SECURITY.md
+++ b/frontend-modern/public/docs/AGENT_SECURITY.md
@@ -35,6 +35,12 @@ directives reduce service blast radius while keeping the filesystem and device
access needed for full host telemetry, Proxmox token setup, SMART, Docker, and
NAS integrations.
+Disk monitoring normally filters pseudo-filesystems such as `tmpfs`. The local
+`--disk-include` option can opt a specific device or mount point back into
+capacity monitoring, for example a log2ram `/var/log` mount. This reports
+filesystem capacity and usage metadata. It does not read or transmit file
+contents. Local `--disk-exclude` rules still take precedence.
+
Command execution is disabled by default. It can be enabled with
`--enable-commands`, `PULSE_ENABLE_COMMANDS=true`, or the centralized agent
command setting after enrollment. Leave it disabled for read-only monitoring.
diff --git a/frontend-modern/public/docs/UNIFIED_AGENT.md b/frontend-modern/public/docs/UNIFIED_AGENT.md
index 3bbf335a9f..258c3f2dd3 100644
--- a/frontend-modern/public/docs/UNIFIED_AGENT.md
+++ b/frontend-modern/public/docs/UNIFIED_AGENT.md
@@ -305,6 +305,7 @@ sudo chmod 0700 /usr/local/libexec/pulse-queue-depth
| `--enable-commands` | `PULSE_ENABLE_COMMANDS` | Enable Pulse command execution: Docker / Podman container actions from the UI (start/stop/restart/update), Patrol actions, and Proxmox LXC Docker inventory (disabled by default) | `false` |
| `--disable-commands` | `PULSE_DISABLE_COMMANDS` | **Deprecated** (commands are disabled by default) | - |
| `--disk-exclude` | `PULSE_DISK_EXCLUDE` | Device name/path or mount point patterns to exclude from disk and S.M.A.R.T. monitoring (repeatable or CSV) | *(none)* |
+| `--disk-include` | `PULSE_DISK_INCLUDE` | Device name/path or mount point patterns to include despite automatic filesystem filtering (repeatable or CSV) | *(none)* |
| `--kubeconfig` | `PULSE_KUBECONFIG` | Kubeconfig path (optional) | *(auto)* |
| `--kube-context` | `PULSE_KUBE_CONTEXT` | Kubeconfig context (optional) | *(auto)* |
| `--kube-include-namespace` | `PULSE_KUBE_INCLUDE_NAMESPACES` | Limit namespaces (repeatable or CSV, wildcards supported) | *(all)* |
@@ -489,6 +490,23 @@ Exclusions are applied before filesystem usage, disk I/O, and S.M.A.R.T. collect
On linked Proxmox hosts, matching physical-disk health and SSD wear alerts are
also suppressed.
+### Include an Automatically Filtered Filesystem
+
+Pulse normally filters pseudo-filesystems such as `tmpfs` to keep system mounts
+out of disk monitoring. A specific mount can be opted back in when its capacity
+matters, such as a log2ram volume mounted at `/var/log`.
+
+```bash
+pulse-agent --disk-include /var/log
+
+# Via environment variable
+PULSE_DISK_INCLUDE=/var/log
+```
+
+Include patterns use the same exact, prefix, and contains matching rules as
+exclusions. They only override automatic filesystem filtering. An explicit
+`--disk-exclude` match still wins.
+
## S.M.A.R.T. Disk Health
The agent can report S.M.A.R.T. disk temperatures, health status, identity, and normalized health counters when running in Agent mode. This requires:
diff --git a/internal/dockeragent/agent.go b/internal/dockeragent/agent.go
index ca0c3479ba..623ff8de94 100644
--- a/internal/dockeragent/agent.go
+++ b/internal/dockeragent/agent.go
@@ -57,6 +57,7 @@ type Config struct {
IncludeContainers bool
CollectDiskMetrics bool
DiskExclude []string // Mount points or path prefixes to exclude from disk monitoring
+ DiskInclude []string // Devices or mount points to opt into monitoring despite automatic filtering
LogLevel zerolog.Level
Logger *zerolog.Logger
}
diff --git a/internal/dockeragent/agent_internal_test.go b/internal/dockeragent/agent_internal_test.go
index 1ab1abb710..6c67f0ebf2 100644
--- a/internal/dockeragent/agent_internal_test.go
+++ b/internal/dockeragent/agent_internal_test.go
@@ -1678,3 +1678,37 @@ func TestIssue1647ReconnectAfterPersistentDaemonGone(t *testing.T) {
t.Fatalf("healthy collects must not trigger further reconnects, got %d", reconnects)
}
}
+
+func TestBuildReportForwardsExplicitDiskIncludesAndExcludes(t *testing.T) {
+ var gotExclude, gotInclude []string
+ swap(t, &hostmetricsCollectWithDiskFilters, func(_ context.Context, exclude, include []string) (hostmetrics.Snapshot, error) {
+ gotExclude = append([]string(nil), exclude...)
+ gotInclude = append([]string(nil), include...)
+ return hostmetrics.Snapshot{}, nil
+ })
+
+ agent := &Agent{
+ cfg: Config{
+ AgentID: "docker-agent-1",
+ Interval: 30 * time.Second,
+ DiskExclude: []string{"/mnt/private"},
+ DiskInclude: []string{"/mnt/containers"},
+ },
+ docker: &fakeDockerClient{
+ infoFunc: func(context.Context) (systemtypes.Info, error) {
+ return systemtypes.Info{ID: "daemon", ServerVersion: "24.0.0"}, nil
+ },
+ },
+ logger: zerolog.Nop(),
+ }
+
+ if _, err := agent.buildReport(context.Background()); err != nil {
+ t.Fatalf("buildReport() failed: %v", err)
+ }
+ if got := strings.Join(gotExclude, ","); got != "/mnt/private" {
+ t.Fatalf("disk excludes = %q, want /mnt/private", got)
+ }
+ if got := strings.Join(gotInclude, ","); got != "/mnt/containers" {
+ t.Fatalf("disk includes = %q, want /mnt/containers", got)
+ }
+}
diff --git a/internal/dockeragent/collect.go b/internal/dockeragent/collect.go
index e3e4407334..489d4a18f4 100644
--- a/internal/dockeragent/collect.go
+++ b/internal/dockeragent/collect.go
@@ -109,7 +109,7 @@ func (a *Agent) buildReport(ctx context.Context) (agentsdocker.Report, error) {
uptime := readSystemUptime()
metricsCtx, metricsCancel := context.WithTimeout(ctx, 10*time.Second)
- snapshot, err := hostmetricsCollect(metricsCtx, a.cfg.DiskExclude)
+ snapshot, err := hostmetricsCollectWithDiskFilters(metricsCtx, a.cfg.DiskExclude, a.cfg.DiskInclude)
metricsCancel()
if err != nil {
return agentsdocker.Report{}, fmt.Errorf("collect host metrics: %w", err)
diff --git a/internal/dockeragent/deps.go b/internal/dockeragent/deps.go
index 4da1f391a1..c7d11be22c 100644
--- a/internal/dockeragent/deps.go
+++ b/internal/dockeragent/deps.go
@@ -15,8 +15,14 @@ import (
)
var (
- connectRuntimeFn = connectRuntime
- hostmetricsCollect = hostmetrics.Collect
+ connectRuntimeFn = connectRuntime
+ hostmetricsCollect = hostmetrics.Collect
+ hostmetricsCollectWithDiskFilters = func(ctx context.Context, exclude, include []string) (hostmetrics.Snapshot, error) {
+ if len(include) == 0 {
+ return hostmetricsCollect(ctx, exclude)
+ }
+ return hostmetrics.CollectWithDiskFilters(ctx, exclude, include)
+ }
newTickerFn = time.NewTicker
randomDurationFn = randomDuration
nowFn = time.Now
diff --git a/internal/hostagent/agent.go b/internal/hostagent/agent.go
index 6d50fb60ca..70f8122caf 100644
--- a/internal/hostagent/agent.go
+++ b/internal/hostagent/agent.go
@@ -69,6 +69,7 @@ type Config struct {
// Disk filtering
DiskExclude []string // Mount points or path prefixes to exclude from disk monitoring
+ DiskInclude []string // Devices or mount points to opt into monitoring despite automatic filtering
// State directory for persistent files (agent-id, proxmox registration, etc.)
StateDir string // Default: /var/lib/pulse-agent
@@ -617,6 +618,7 @@ type runtimeConfigSnapshot struct {
interval time.Duration
commandsEnabled bool
diskExclude []string
+ diskInclude []string
tags []string
reportIP string
disableCeph bool
@@ -646,6 +648,7 @@ func (a *Agent) runtimeConfigSnapshot() runtimeConfigSnapshot {
interval: a.interval,
commandsEnabled: a.cfg.EnableCommands,
diskExclude: append([]string(nil), a.cfg.DiskExclude...),
+ diskInclude: append([]string(nil), a.cfg.DiskInclude...),
tags: append([]string(nil), a.cfg.Tags...),
reportIP: a.reportIP,
disableCeph: a.cfg.DisableCeph,
@@ -1104,7 +1107,7 @@ func (a *Agent) buildReport(ctx context.Context) (agentshost.Report, error) {
if err != nil {
a.logger.Debug().Err(err).Msg("Failed to collect host uptime; defaulting to 0")
}
- snapshot, err := a.collector.Metrics(collectCtx, runtimeConfig.diskExclude)
+ snapshot, err := collectMetricsWithDiskFilters(collectCtx, a.collector, runtimeConfig.diskExclude, runtimeConfig.diskInclude)
if err != nil {
return agentshost.Report{}, fmt.Errorf("collect metrics: %w", err)
}
diff --git a/internal/hostagent/agent_metrics_test.go b/internal/hostagent/agent_metrics_test.go
index a8df934e69..f63984a8d2 100644
--- a/internal/hostagent/agent_metrics_test.go
+++ b/internal/hostagent/agent_metrics_test.go
@@ -476,6 +476,38 @@ rdevId.29=
})
}
+func TestBuildReportForwardsExplicitDiskIncludesAndExcludes(t *testing.T) {
+ var gotExclude, gotInclude []string
+ mc := &mockCollector{
+ metricsWithDiskFiltersFn: func(_ context.Context, exclude, include []string) (hostmetrics.Snapshot, error) {
+ gotExclude = append([]string(nil), exclude...)
+ gotInclude = append([]string(nil), include...)
+ return hostmetrics.Snapshot{}, nil
+ },
+ }
+ agent, err := New(Config{
+ APIToken: "token",
+ AgentID: "agent-1",
+ LogLevel: -1,
+ Collector: mc,
+ DiskExclude: []string{"/mnt/private"},
+ DiskInclude: []string{"/mnt/containers"},
+ })
+ if err != nil {
+ t.Fatalf("New() failed: %v", err)
+ }
+
+ if _, err := agent.buildReport(context.Background()); err != nil {
+ t.Fatalf("buildReport() failed: %v", err)
+ }
+ if got := strings.Join(gotExclude, ","); got != "/mnt/private" {
+ t.Fatalf("disk excludes = %q, want /mnt/private", got)
+ }
+ if got := strings.Join(gotInclude, ","); got != "/mnt/containers" {
+ t.Fatalf("disk includes = %q, want /mnt/containers", got)
+ }
+}
+
func TestBuildReportIncludesDarwinThermalState(t *testing.T) {
mc := &mockCollector{
goos: "darwin",
diff --git a/internal/hostagent/mock_collector_test.go b/internal/hostagent/mock_collector_test.go
index 3d9053040b..edf8bf113f 100644
--- a/internal/hostagent/mock_collector_test.go
+++ b/internal/hostagent/mock_collector_test.go
@@ -14,20 +14,21 @@ import (
)
type mockCollector struct {
- hostInfoFn func(ctx context.Context) (*gohost.InfoStat, error)
- hostUptimeFn func(ctx context.Context) (uint64, error)
- metricsFn func(ctx context.Context, exclude []string) (hostmetrics.Snapshot, error)
- sensorsLocalFn func(ctx context.Context) (string, error)
- sensorsParseFn func(jsonStr string) (*sensors.TemperatureData, error)
- sensorsPowerFn func(ctx context.Context) (*sensors.PowerData, error)
- raidArraysFn func(ctx context.Context) ([]agentshost.RAIDArray, error)
- unraidStorageFn func(ctx context.Context) (*agentshost.UnraidStorage, error)
- cephStatusFn func(ctx context.Context) (*CephClusterStatus, error)
- smartLocalFn func(ctx context.Context, exclude []string, unraid *agentshost.UnraidStorage) ([]DiskSMART, error)
- nowFn func() time.Time
- goos string
- readFileFn func(name string) ([]byte, error)
- netInterfacesFn func() ([]net.Interface, error)
+ hostInfoFn func(ctx context.Context) (*gohost.InfoStat, error)
+ hostUptimeFn func(ctx context.Context) (uint64, error)
+ metricsFn func(ctx context.Context, exclude []string) (hostmetrics.Snapshot, error)
+ metricsWithDiskFiltersFn func(ctx context.Context, exclude, include []string) (hostmetrics.Snapshot, error)
+ sensorsLocalFn func(ctx context.Context) (string, error)
+ sensorsParseFn func(jsonStr string) (*sensors.TemperatureData, error)
+ sensorsPowerFn func(ctx context.Context) (*sensors.PowerData, error)
+ raidArraysFn func(ctx context.Context) ([]agentshost.RAIDArray, error)
+ unraidStorageFn func(ctx context.Context) (*agentshost.UnraidStorage, error)
+ cephStatusFn func(ctx context.Context) (*CephClusterStatus, error)
+ smartLocalFn func(ctx context.Context, exclude []string, unraid *agentshost.UnraidStorage) ([]DiskSMART, error)
+ nowFn func() time.Time
+ goos string
+ readFileFn func(name string) ([]byte, error)
+ netInterfacesFn func() ([]net.Interface, error)
hostnameFn func() (string, error)
lookupIPFn func(host string) ([]net.IP, error)
@@ -67,6 +68,13 @@ func (m *mockCollector) Metrics(ctx context.Context, exclude []string) (hostmetr
return hostmetrics.Snapshot{}, nil
}
+func (m *mockCollector) MetricsWithDiskFilters(ctx context.Context, exclude, include []string) (hostmetrics.Snapshot, error) {
+ if m.metricsWithDiskFiltersFn != nil {
+ return m.metricsWithDiskFiltersFn(ctx, exclude, include)
+ }
+ return m.Metrics(ctx, exclude)
+}
+
func (m *mockCollector) SensorsLocal(ctx context.Context) (string, error) {
if m.sensorsLocalFn != nil {
return m.sensorsLocalFn(ctx)
diff --git a/internal/hostagent/sysinfo.go b/internal/hostagent/sysinfo.go
index b90827a592..3bab6561a4 100644
--- a/internal/hostagent/sysinfo.go
+++ b/internal/hostagent/sysinfo.go
@@ -44,6 +44,17 @@ type SystemCollector interface {
LookPath(file string) (string, error)
}
+type diskFilterMetricsCollector interface {
+ MetricsWithDiskFilters(ctx context.Context, exclude, include []string) (hostmetrics.Snapshot, error)
+}
+
+func collectMetricsWithDiskFilters(ctx context.Context, collector SystemCollector, exclude, include []string) (hostmetrics.Snapshot, error) {
+ if filtered, ok := collector.(diskFilterMetricsCollector); ok {
+ return filtered.MetricsWithDiskFilters(ctx, exclude, include)
+ }
+ return collector.Metrics(ctx, exclude)
+}
+
// NewDefaultCollector returns a SystemCollector that uses real OS calls.
func NewDefaultCollector() SystemCollector {
return &defaultCollector{}
@@ -63,6 +74,10 @@ func (c *defaultCollector) Metrics(ctx context.Context, exclude []string) (hostm
return hostmetrics.Collect(ctx, exclude)
}
+func (c *defaultCollector) MetricsWithDiskFilters(ctx context.Context, exclude, include []string) (hostmetrics.Snapshot, error) {
+ return hostmetrics.CollectWithDiskFilters(ctx, exclude, include)
+}
+
func (c *defaultCollector) SensorsLocal(ctx context.Context) (string, error) {
return sensors.CollectLocal(ctx)
}
diff --git a/internal/hostmetrics/collector.go b/internal/hostmetrics/collector.go
index 25a21301ce..8966e2dc1e 100644
--- a/internal/hostmetrics/collector.go
+++ b/internal/hostmetrics/collector.go
@@ -44,8 +44,16 @@ type Snapshot struct {
}
// Collect gathers a point-in-time snapshot of host resource utilisation.
-// diskExclude contains user-defined patterns for mount points to exclude.
+// diskExclude contains user-defined patterns for devices or mount points to
+// exclude. It preserves the original API for callers that do not need includes.
func Collect(ctx context.Context, diskExclude []string) (Snapshot, error) {
+ return CollectWithDiskFilters(ctx, diskExclude, nil)
+}
+
+// CollectWithDiskFilters gathers a snapshot with user-defined disk exclusions
+// and includes. Includes opt matching filesystems back in after Pulse's
+// automatic pseudo-filesystem filtering. Explicit exclusions always win.
+func CollectWithDiskFilters(ctx context.Context, diskExclude, diskInclude []string) (Snapshot, error) {
collectCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
defer cancel()
@@ -127,7 +135,7 @@ func Collect(ctx context.Context, diskExclude []string) (Snapshot, error) {
SwapUsed: swapUsed,
}
- snapshot.Disks = collectDisks(collectCtx, diskExclude)
+ snapshot.Disks = collectDisksWithIncludes(collectCtx, diskExclude, diskInclude)
snapshot.DiskIO = collectDiskIO(collectCtx, diskExclude)
snapshot.Network = collectNetwork(collectCtx)
@@ -219,6 +227,10 @@ func spotCPUUsage(ctx context.Context) (float64, error) {
}
func collectDisks(ctx context.Context, diskExclude []string) []agentshost.Disk {
+ return collectDisksWithIncludes(ctx, diskExclude, nil)
+}
+
+func collectDisksWithIncludes(ctx context.Context, diskExclude, diskInclude []string) []agentshost.Disk {
partitions, err := diskPartitions(ctx, true)
if err != nil {
log.Debug().Err(err).Msg("disk: failed to list partitions")
@@ -288,7 +300,8 @@ func collectDisks(ctx context.Context, diskExclude []string) []agentshost.Disk {
// - Virtual/pseudo filesystems (tmpfs, devtmpfs, cgroup, etc.)
// - Container overlay paths (Docker/Podman layers on ZFS, including TrueNAS .ix-apps)
// See issues #505, #690, #718, #790.
- if shouldSkip, _ := fsfilters.ShouldSkipFilesystem(part.Fstype, part.Mountpoint, usage.Total, usage.Used); shouldSkip {
+ explicitlyIncluded := fsfilters.MatchesDiskInclude(part.Device, part.Mountpoint, diskInclude)
+ if shouldSkip, _ := fsfilters.ShouldSkipFilesystem(part.Fstype, part.Mountpoint, usage.Total, usage.Used); shouldSkip && !explicitlyIncluded {
continue
}
diff --git a/internal/hostmetrics/collector_test.go b/internal/hostmetrics/collector_test.go
index 26d78fd688..6492b2deae 100644
--- a/internal/hostmetrics/collector_test.go
+++ b/internal/hostmetrics/collector_test.go
@@ -148,6 +148,60 @@ func TestCollectDisksExcludesFreeBSDFdescfsBeforeUsage(t *testing.T) {
}
}
+func TestCollectDisksIncludesExplicitTmpfsMount(t *testing.T) {
+ origPartitions := diskPartitions
+ origUsage := diskUsage
+ t.Cleanup(func() {
+ diskPartitions = origPartitions
+ diskUsage = origUsage
+ })
+
+ diskPartitions = func(context.Context, bool) ([]godisk.PartitionStat, error) {
+ return []godisk.PartitionStat{
+ {Device: "log2ram", Mountpoint: "/var/log", Fstype: "tmpfs"},
+ {Device: "tmpfs", Mountpoint: "/run", Fstype: "tmpfs"},
+ }, nil
+ }
+ diskUsage = func(_ context.Context, path string) (*godisk.UsageStat, error) {
+ return &godisk.UsageStat{
+ Path: path,
+ Total: 1024,
+ Used: 768,
+ Free: 256,
+ UsedPercent: 75,
+ }, nil
+ }
+
+ disks := collectDisksWithIncludes(context.Background(), nil, []string{"/var/log"})
+ if len(disks) != 1 || disks[0].Mountpoint != "/var/log" || disks[0].Filesystem != "tmpfs" {
+ t.Fatalf("explicit tmpfs include was not reported correctly: %+v", disks)
+ }
+}
+
+func TestCollectDisksExplicitExcludeWinsOverInclude(t *testing.T) {
+ origPartitions := diskPartitions
+ origUsage := diskUsage
+ t.Cleanup(func() {
+ diskPartitions = origPartitions
+ diskUsage = origUsage
+ })
+
+ diskPartitions = func(context.Context, bool) ([]godisk.PartitionStat, error) {
+ return []godisk.PartitionStat{
+ {Device: "log2ram", Mountpoint: "/var/log", Fstype: "tmpfs"},
+ }, nil
+ }
+ diskUsage = func(context.Context, string) (*godisk.UsageStat, error) {
+ t.Fatal("excluded mount should not be queried")
+ return nil, nil
+ }
+
+ disks := collectDisksWithIncludes(context.Background(), []string{"/var/log"}, []string{"/var/log"})
+ if len(disks) != 0 {
+ t.Fatalf("explicit exclusion should win over include: %+v", disks)
+ }
+}
+
func TestCollectSplitsReclaimableCache(t *testing.T) {
origVirtualMemory := virtualMemory
t.Cleanup(func() { virtualMemory = origVirtualMemory })
diff --git a/pkg/fsfilters/filters.go b/pkg/fsfilters/filters.go
index 75f743f20c..03e74b94df 100644
--- a/pkg/fsfilters/filters.go
+++ b/pkg/fsfilters/filters.go
@@ -248,6 +248,14 @@ func MatchesDiskExclude(device, mountpoint string, excludePatterns []string) boo
return false
}
+// MatchesDiskInclude checks whether a disk was explicitly opted back into
+// monitoring by device or mountpoint. Include patterns use the same matching
+// rules as exclusions, but only override Pulse's automatic filesystem filter.
+// An explicit user exclusion still takes precedence.
+func MatchesDiskInclude(device, mountpoint string, includePatterns []string) bool {
+ return MatchesDiskExclude(device, mountpoint, includePatterns)
+}
+
// virtualBlockDevicePrefixes are device-name prefixes for virtual or
// pseudo block devices that should never be treated as physical disks.
// The list is shared between the host agent (which skips these during
diff --git a/scripts/install.sh b/scripts/install.sh
index 101bb4033d..2d7a11ffff 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -21,6 +21,7 @@
# --interval <dur> Reporting interval (default: 30s)
# --agent-id <id> Custom agent identifier (default: auto-generated)
# --disk-exclude <pattern> Exclude device names/paths or mount points (repeatable)
+# --disk-include <pattern> Include a device or mount point despite automatic filtering (repeatable)
# --insecure Skip TLS certificate verification
# --server-fingerprint <sha256> Pin the Pulse server leaf certificate
# --observers-file <path> Report to additional observer Pulse instances
@@ -95,6 +96,7 @@ KUBECONFIG_PATH="" # Path to kubeconfig file for Kubernetes monitoring
KUBE_INCLUDE_ALL_PODS="false"
KUBE_INCLUDE_ALL_DEPLOYMENTS="false"
DISK_EXCLUDES=() # Array for multiple --disk-exclude values
+DISK_INCLUDES=() # Array for multiple --disk-include values
AGENT_LOG_FILE="" # When set, pass --log-file so the agent's rotating log writer engages (set per platform)
DEFAULT_STATE_DIR="/var/lib/pulse-agent"
STATE_DIR="$DEFAULT_STATE_DIR" # Persistent state directory (overridden per platform)
@@ -473,6 +475,7 @@ Options:
--report-ip <ip> IP address to report to Pulse (for multi-NIC systems)
--state-dir <path> Override persistent state directory
--disk-exclude <pattern> Exclude device names/paths or mount points (repeatable)
+ --disk-include <pattern> Include a device or mount point despite automatic filtering (repeatable)
--insecure Skip TLS verification (auto-enabled for http:// URLs)
--cacert <path> Custom CA certificate for TLS (used by curl and agent)
--server-fingerprint <sha256> Pin the Pulse server leaf certificate for agent connections
@@ -1965,6 +1968,9 @@ build_exec_arg_items() {
for pattern in ${DISK_EXCLUDES[@]+"${DISK_EXCLUDES[@]}"}; do
EXEC_ARG_ITEMS+=(--disk-exclude "$pattern")
done
+ for pattern in ${DISK_INCLUDES[@]+"${DISK_INCLUDES[@]}"}; do
+ EXEC_ARG_ITEMS+=(--disk-include "$pattern")
+ done
}
join_exec_arg_items() {
@@ -2301,6 +2307,10 @@ apply_recovered_agent_arg_value() {
DISK_EXCLUDES+=("$value")
RECOVERED_AGENT_ARG_STATE="true"
;;
+ disk-include)
+ DISK_INCLUDES+=("$value")
+ RECOVERED_AGENT_ARG_STATE="true"
+ ;;
esac
}
@@ -2328,10 +2338,10 @@ recover_connection_state_from_arg_stream() {
fi
case "$arg" in
- --url|--pulse-url|--token|--token-file|--interval|--agent-id|--hostname|--report-ip|--cacert|--server-fingerprint|--observers-file|--health-addr|--state-dir|--kubeconfig|--proxmox-type|--disk-exclude|-url|-pulse-url|-token|-token-file|-interval|-agent-id|-hostname|-report-ip|-cacert|-server-fingerprint|-observers-file|-health-addr|-state-dir|-kubeconfig|-proxmox-type|-disk-exclude)
+ --url|--pulse-url|--token|--token-file|--interval|--agent-id|--hostname|--report-ip|--cacert|--server-fingerprint|--observers-file|--health-addr|--state-dir|--kubeconfig|--proxmox-type|--disk-exclude|--disk-include|-url|-pulse-url|-token|-token-file|-interval|-agent-id|-hostname|-report-ip|-cacert|-server-fingerprint|-observers-file|-health-addr|-state-dir|-kubeconfig|-proxmox-type|-disk-exclude|-disk-include)
pending_key=$(normalize_recovered_agent_arg_key "$arg")
;;
- --url=*|--pulse-url=*|--token=*|--token-file=*|--interval=*|--agent-id=*|--hostname=*|--report-ip=*|--cacert=*|--server-fingerprint=*|--observers-file=*|--health-addr=*|--state-dir=*|--kubeconfig=*|--proxmox-type=*|--disk-exclude=*|-url=*|-pulse-url=*|-token=*|-token-file=*|-interval=*|-agent-id=*|-hostname=*|-report-ip=*|-cacert=*|-server-fingerprint=*|-observers-file=*|-health-addr=*|-state-dir=*|-kubeconfig=*|-proxmox-type=*|-disk-exclude=*)
+ --url=*|--pulse-url=*|--token=*|--token-file=*|--interval=*|--agent-id=*|--hostname=*|--report-ip=*|--cacert=*|--server-fingerprint=*|--observers-file=*|--health-addr=*|--state-dir=*|--kubeconfig=*|--proxmox-type=*|--disk-exclude=*|--disk-include=*|-url=*|-pulse-url=*|-token=*|-token-file=*|-interval=*|-agent-id=*|-hostname=*|-report-ip=*|-cacert=*|-server-fingerprint=*|-observers-file=*|-health-addr=*|-state-dir=*|-kubeconfig=*|-proxmox-type=*|-disk-exclude=*|-disk-include=*)
key="${arg%%=*}"
value="${arg#*=}"
apply_recovered_agent_arg_value "$key" "$value"
@@ -2928,6 +2938,7 @@ while [[ $# -gt 0 ]]; do
--kube-include-all-pods) KUBE_INCLUDE_ALL_PODS="true"; shift ;;
--kube-include-all-deployments) KUBE_INCLUDE_ALL_DEPLOYMENTS="true"; shift ;;
--disk-exclude) DISK_EXCLUDES+=("$2"); shift 2 ;;
+ --disk-include) DISK_INCLUDES+=("$2"); shift 2 ;;
--non-interactive) NON_INTERACTIVE="true"; shift ;;
--token-file) TOKEN_FILE_PATH="$2"; shift 2 ;;
--pulse-url) PULSE_URL="$2"; shift 2 ;;
diff --git a/scripts/installtests/install_sh_test.go b/scripts/installtests/install_sh_test.go
index 585eb9c006..3930b4508e 100644
--- a/scripts/installtests/install_sh_test.go
+++ b/scripts/installtests/install_sh_test.go
@@ -454,6 +454,7 @@ func TestBuildPlistProgramArgumentsUsesSharedExecArgs(t *testing.T) {
HOSTNAME_OVERRIDE="Richard's Mac & Mini"
STATE_DIR="/var/lib/pulse-agent"
DISK_EXCLUDES=("Time Machine")
+ DISK_INCLUDES=("/var/log")
build_plist_program_arguments "/usr/local/bin/pulse-agent"
printf '%s\n' "$PLIST_ARGS"
`
@@ -479,6 +480,8 @@ func TestBuildPlistProgramArgumentsUsesSharedExecArgs(t *testing.T) {
`<string>/var/lib/pulse-agent</string>`,
`<string>--disk-exclude</string>`,
`<string>Time Machine</string>`,
+ `<string>--disk-include</string>`,
+ `<string>/var/log</string>`,
}
for _, needle := range required {
if !strings.Contains(got, needle) {
@@ -818,7 +821,7 @@ func TestInstallSHSupportsSavedStateUpdateMode(t *testing.T) {
`recover_connection_state_from_arg_stream`,
`recover_token_from_default_agent_token_file() {`,
`normalize_recovered_agent_arg_key() {`,
- `-url|-pulse-url|-token|-token-file|-interval|-agent-id|-hostname|-report-ip|-cacert|-server-fingerprint|-observers-file|-health-addr|-state-dir|-kubeconfig|-proxmox-type|-disk-exclude)`,
+ `-url|-pulse-url|-token|-token-file|-interval|-agent-id|-hostname|-report-ip|-cacert|-server-fingerprint|-observers-file|-health-addr|-state-dir|-kubeconfig|-proxmox-type|-disk-exclude|-disk-include)`,
`--enable-host|-enable-host|--enable-host=true|-enable-host=true)`,
`recover_connection_state_from_env_stream`,
`recovered_connection_state_ready() {`,
@@ -870,6 +873,7 @@ func TestInstallSHRecoversV5ProcessArgsForSavedStateUpdate(t *testing.T) {
KUBE_INCLUDE_ALL_PODS="false"
KUBE_INCLUDE_ALL_DEPLOYMENTS="false"
DISK_EXCLUDES=()
+ DISK_INCLUDES=()
RUNTIME_TOKEN_FILE="/var/lib/pulse-agent/token"
` + extractInstallShellFunction(t, "strip_recovered_arg_quotes") + `
` + extractInstallShellFunction(t, "normalize_recovered_agent_arg_key") + `
@@ -898,6 +902,8 @@ pve-one
--disk-exclude
/dev/sda
--disk-exclude=/var/run/samba/fd
+--disk-include
+/var/log
ARGS
build_exec_args
printf 'URL=%s\nTOKEN=%s\nDOCKER=%s\nDOCKER_EXPLICIT=%s\nINSECURE=%s\nAGENT_ID=%s\nHOSTNAME=%s\nEXEC_ARGS=%s\n' \
@@ -921,6 +927,7 @@ ARGS
"--enable-docker",
"--disk-exclude /dev/sda",
"--disk-exclude /var/run/samba/fd",
+ "--disk-include /var/log",
}
for _, needle := range required {
if !strings.Contains(got, needle) {