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.

feat: Add detection for legacy SSH temperature monitoring

rcourtman6d56917cd952
diff --git a/internal/api/router.go b/internal/api/router.go
index d708a151ff..5f78cb2b14 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -1128,6 +1128,56 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
}), allowEmbedding, allowedEmbedOrigins).ServeHTTP(w, req)
}
+// detectLegacySSH checks if Pulse is using legacy SSH for temperature monitoring
+func (r *Router) detectLegacySSH() (legacyDetected, recommendProxy bool) {
+ // Check if running in a container
+ inContainer := false
+ if _, err := os.Stat("/.dockerenv"); err == nil {
+ inContainer = true
+ } else if data, err := os.ReadFile("/proc/1/cgroup"); err == nil {
+ if strings.Contains(string(data), "docker") || strings.Contains(string(data), "lxc") {
+ inContainer = true
+ }
+ }
+
+ // If not in container, no need for proxy
+ if !inContainer {
+ return false, false
+ }
+
+ // Check if SSH keys are configured in the data directory
+ sshKeysConfigured := false
+
+ // Check for SSH keys in the configured data directory
+ dataDir := r.config.DataPath
+ if dataDir == "" {
+ dataDir = "/etc/pulse"
+ }
+
+ sshPrivKeyPath := filepath.Join(dataDir, ".ssh", "id_ed25519")
+ if _, err := os.Stat(sshPrivKeyPath); err == nil {
+ sshKeysConfigured = true
+ }
+
+ // Also check for RSA keys
+ sshPrivKeyPathRSA := filepath.Join(dataDir, ".ssh", "id_rsa")
+ if _, err := os.Stat(sshPrivKeyPathRSA); err == nil {
+ sshKeysConfigured = true
+ }
+
+ // If SSH keys exist, check if proxy is running
+ if sshKeysConfigured {
+ // Check if pulse-sensor-proxy is available via unix socket
+ proxySocket := "/run/pulse-sensor-proxy/sensor.sock"
+ if _, err := os.Stat(proxySocket); err != nil {
+ // Socket doesn't exist - legacy SSH method detected
+ return true, true
+ }
+ }
+
+ return false, false
+}
+
// handleHealth handles health check requests
func (r *Router) handleHealth(w http.ResponseWriter, req *http.Request) {
if req.Method != http.MethodGet && req.Method != http.MethodHead {
@@ -1135,10 +1185,16 @@ func (r *Router) handleHealth(w http.ResponseWriter, req *http.Request) {
return
}
+ // Detect legacy SSH setup
+ legacySSH, recommendProxy := r.detectLegacySSH()
+
response := HealthResponse{
- Status: "healthy",
- Timestamp: time.Now().Unix(),
- Uptime: time.Since(r.monitor.GetStartTime()).Seconds(),
+ Status: "healthy",
+ Timestamp: time.Now().Unix(),
+ Uptime: time.Since(r.monitor.GetStartTime()).Seconds(),
+ LegacySSHDetected: legacySSH,
+ RecommendProxyUpgrade: recommendProxy,
+ ProxyInstallScriptAvailable: true, // Install script is always available
}
if err := utils.WriteJSONResponse(w, response); err != nil {
diff --git a/internal/api/types.go b/internal/api/types.go
index b7acc4c14a..6815c70128 100644
--- a/internal/api/types.go
+++ b/internal/api/types.go
@@ -11,9 +11,12 @@ import (
// HealthResponse represents the health check response
type HealthResponse struct {
- Status string `json:"status"`
- Timestamp int64 `json:"timestamp"`
- Uptime float64 `json:"uptime"`
+ Status string `json:"status"`
+ Timestamp int64 `json:"timestamp"`
+ Uptime float64 `json:"uptime"`
+ LegacySSHDetected bool `json:"legacySSHDetected,omitempty"`
+ RecommendProxyUpgrade bool `json:"recommendProxyUpgrade,omitempty"`
+ ProxyInstallScriptAvailable bool `json:"proxyInstallScriptAvailable,omitempty"`
}
// VersionResponse represents version information