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.
Go aialertsdashboarddockerdocker-monitoringgohomelabinfrastructure-monitoringkubernetesmonitoringmspproxmoxproxmox-backup-serverproxmox-mail-gatewayproxmox-veself-hostedtruenastypescriptvspherewebhooks
chore: fix staticcheck SA warnings
rcourtman6ff345fb6b00
diff --git a/cmd/pulse-sensor-proxy/ssh.go b/cmd/pulse-sensor-proxy/ssh.goindex b9bfbaf5c0..f93a559113 100644--- a/cmd/pulse-sensor-proxy/ssh.go+++ b/cmd/pulse-sensor-proxy/ssh.go@@ -1023,8 +1023,7 @@ func (p *Proxy) getTemperatureLocal(ctx context.Context) (string, error) {if err != nil {// Try without -j flag as fallbackcmd = exec.CommandContext(ctx, "sensors")- output, err = cmd.Output()- if err != nil {+ if _, err = cmd.Output(); err != nil {return "", fmt.Errorf("failed to run sensors: %w", err)}// Return empty JSON object for non-JSON outputdiff --git a/cmd/pulse-sensor-proxy/validation.go b/cmd/pulse-sensor-proxy/validation.goindex 21c180f39f..8a100accab 100644--- a/cmd/pulse-sensor-proxy/validation.go+++ b/cmd/pulse-sensor-proxy/validation.go@@ -412,12 +412,9 @@ func (v *nodeValidator) Validate(ctx context.Context, node string) error {return nil}-func (v *nodeValidator) validateAsLocalhost(ctx context.Context, node string) error {+func (v *nodeValidator) validateAsLocalhost(_ context.Context, node string) error {// When cluster validation is unavailable, only allow access to localhost// This maintains security while allowing self-monitoring- if ctx == nil {- ctx = context.Background()- }// Try to discover local host addresseslocalAddrs, err := discoverLocalHostAddresses()diff --git a/cmd/pulse/config.go b/cmd/pulse/config.goindex 6314c7b17e..3fb6789dcd 100644--- a/cmd/pulse/config.go+++ b/cmd/pulse/config.go@@ -4,7 +4,7 @@ import ("bufio""encoding/base64""fmt"- "io/ioutil"+ "io""net/http""net/url""os"@@ -86,7 +86,7 @@ var configExportCmd = &cobra.Command{// Write to file or stdoutif exportFile != "" {- if err := ioutil.WriteFile(exportFile, []byte(exportedData), 0600); err != nil {+ if err := os.WriteFile(exportFile, []byte(exportedData), 0600); err != nil {return fmt.Errorf("failed to write export file: %w", err)}fmt.Printf("Configuration exported to %s\n", exportFile)@@ -117,7 +117,7 @@ var configImportCmd = &cobra.Command{}// Read import file- data, err := ioutil.ReadFile(importFile)+ data, err := os.ReadFile(importFile)if err != nil {return fmt.Errorf("failed to read import file: %w", err)}@@ -245,7 +245,7 @@ var configAutoImportCmd = &cobra.Command{return fmt.Errorf("failed to fetch configuration from URL: %s", resp.Status)}- body, err := ioutil.ReadAll(resp.Body)+ body, err := io.ReadAll(resp.Body)if err != nil {return fmt.Errorf("failed to read configuration response: %w", err)}diff --git a/cmd/pulse/main.go b/cmd/pulse/main.goindex 993d0e7c57..2797da5832 100644--- a/cmd/pulse/main.go+++ b/cmd/pulse/main.go@@ -253,12 +253,10 @@ func runServer() {configWatcher.ReloadConfig()}- if reloadFunc != nil {- if err := reloadFunc(); err != nil {- log.Error().Err(err).Msg("Failed to reload monitor after SIGHUP")- } else {- log.Info().Msg("Runtime configuration reloaded")- }+ if err := reloadFunc(); err != nil {+ log.Error().Err(err).Msg("Failed to reload monitor after SIGHUP")+ } else {+ log.Info().Msg("Runtime configuration reloaded")}case <-sigChan:diff --git a/internal/agentbinaries/host_agent.go b/internal/agentbinaries/host_agent.goindex 448f2af7f3..b51d735436 100644--- a/internal/agentbinaries/host_agent.go+++ b/internal/agentbinaries/host_agent.go@@ -236,7 +236,7 @@ func extractHostAgentBinaries(archivePath, targetDir string) error {continue}- if header.Typeflag != tar.TypeReg && header.Typeflag != tar.TypeRegA && header.Typeflag != tar.TypeSymlink {+ if header.Typeflag != tar.TypeReg && header.Typeflag != tar.TypeSymlink {continue}@@ -252,7 +252,7 @@ func extractHostAgentBinaries(archivePath, targetDir string) error {destPath := filepath.Join(targetDir, base)switch header.Typeflag {- case tar.TypeReg, tar.TypeRegA:+ case tar.TypeReg:if err := writeHostAgentFile(destPath, tr, header.FileInfo().Mode()); err != nil {return err}diff --git a/internal/mock/generator.go b/internal/mock/generator.goindex 7ca6d43cd6..4b5d037dca 100644--- a/internal/mock/generator.go+++ b/internal/mock/generator.go@@ -226,7 +226,7 @@ func generateVirtualDisks() ([]models.Disk, models.Disk) {}func GenerateMockData(config MockConfig) models.StateSnapshot {- rand.Seed(time.Now().UnixNano())+ // rand is automatically seeded in Go 1.20+data := models.StateSnapshot{Nodes: generateNodes(config),@@ -273,8 +273,7 @@ func GenerateMockData(config MockConfig) models.StateSnapshot {}// Calculate VM count based on node role- vmCount := config.VMsPerNode- lxcCount := config.LXCsPerNode+ var vmCount, lxcCount intswitch nodeRole {case "vm-heavy":diff --git a/internal/monitoring/metrics_history_concurrency_test.go b/internal/monitoring/metrics_history_concurrency_test.goindex 26105ee21d..2417496a23 100644--- a/internal/monitoring/metrics_history_concurrency_test.go+++ b/internal/monitoring/metrics_history_concurrency_test.go@@ -59,6 +59,4 @@ func TestMetricsHistoryConcurrentAccess(t *testing.T) {wg.Wait()}-func init() {- rand.Seed(time.Now().UnixNano())-}+// rand is automatically seeded in Go 1.20+diff --git a/internal/monitoring/monitor.go b/internal/monitoring/monitor.goindex e648e6d391..050b4637ea 100644--- a/internal/monitoring/monitor.go+++ b/internal/monitoring/monitor.go@@ -3700,6 +3700,10 @@ func checkContainerizedTempMonitoring() {// New creates a new Monitor instancefunc New(cfg *config.Config) (*Monitor, error) {+ if cfg == nil {+ return nil, fmt.Errorf("config cannot be nil")+ }+// Initialize temperature collector with sensors SSH key// Will use root user for now - can be made configurable laterhomeDir := os.Getenv("HOME")@@ -3712,7 +3716,7 @@ func New(cfg *config.Config) (*Monitor, error) {// Security warning if running in container with SSH temperature monitoringcheckContainerizedTempMonitoring()- if cfg != nil && cfg.TemperatureMonitoringEnabled {+ if cfg.TemperatureMonitoringEnabled {isContainer := os.Getenv("PULSE_DOCKER") == "true" || system.InContainer()if isContainer && tempCollector != nil && !tempCollector.SocketProxyAvailable() {log.Warn().Msg("Temperature monitoring is enabled but the container does not have access to pulse-sensor-proxy. Install the proxy on the host or disable temperatures until it is available.")diff --git a/internal/tempproxy/client.go b/internal/tempproxy/client.goindex b4dd1b4a4e..b5ac2209e3 100644--- a/internal/tempproxy/client.go+++ b/internal/tempproxy/client.go@@ -278,8 +278,9 @@ func (c *Client) callWithContext(ctx context.Context, method string, params map[return resp, proxyErr}- lastErr = proxyErr- if lastErr == nil {+ if proxyErr != nil {+ lastErr = proxyErr+ } else {lastErr = err}