diff --git a/agents/patchmon-agent.sh b/agents/patchmon-agent.sh index 843e21d..679c55d 100755 --- a/agents/patchmon-agent.sh +++ b/agents/patchmon-agent.sh @@ -56,6 +56,28 @@ warning() { log "WARNING: $1" } +# Get or generate machine ID +get_machine_id() { + # Try standard locations for machine-id + if [[ -f /etc/machine-id ]]; then + cat /etc/machine-id + elif [[ -f /var/lib/dbus/machine-id ]]; then + cat /var/lib/dbus/machine-id + else + # Fallback: generate from hardware UUID or hostname+MAC + if command -v dmidecode &> /dev/null; then + local uuid=$(dmidecode -s system-uuid 2>/dev/null | tr -d ' -' | tr '[:upper:]' '[:lower:]') + if [[ -n "$uuid" && "$uuid" != "notpresent" ]]; then + echo "$uuid" + return + fi + fi + # Last resort: hash hostname + primary MAC address + local primary_mac=$(ip link show | grep -oP '(?<=link/ether\s)[0-9a-f:]+' | head -1 | tr -d ':') + echo "$HOSTNAME-$primary_mac" | sha256sum | cut -d' ' -f1 | cut -c1-32 + fi +} + # Check if running as root check_root() { if [[ $EUID -ne 0 ]]; then @@ -865,6 +887,9 @@ send_update() { # Merge all JSON objects into one local merged_json=$(echo "$hardware_json $network_json $system_json" | jq -s '.[0] * .[1] * .[2]') + # Get machine ID + local machine_id=$(get_machine_id) + # Create the base payload and merge with system info local base_payload=$(cat < { try { @@ -338,6 +334,11 @@ router.post( updated_at: new Date(), }; + // Update machine_id if provided and current one is a placeholder + if (req.body.machineId && host.machine_id.startsWith("pending-")) { + updateData.machine_id = req.body.machineId; + } + // Basic system info if (req.body.osType) updateData.os_type = req.body.osType; if (req.body.osVersion) updateData.os_version = req.body.osVersion; diff --git a/frontend/src/pages/HostDetail.jsx b/frontend/src/pages/HostDetail.jsx index 4a9e785..8d185ac 100644 --- a/frontend/src/pages/HostDetail.jsx +++ b/frontend/src/pages/HostDetail.jsx @@ -466,11 +466,23 @@ const HostDetail = () => { {/* Network Information */} {activeTab === "network" && - (host.gateway_ip || + (host.ip || + host.gateway_ip || host.dns_servers || host.network_interfaces) && (
+ {host.ip && ( +
+

+ IP Address +

+

+ {host.ip} +

+
+ )} + {host.gateway_ip && (

@@ -802,6 +814,7 @@ const HostDetail = () => { {activeTab === "network" && !( + host.ip || host.gateway_ip || host.dns_servers || host.network_interfaces