feat(agent): add basic macOS platform support#11449
feat(agent): add basic macOS platform support#11449zy84338719 wants to merge 1 commit intodeepflowio:mainfrom
Conversation
This PR adds initial macOS support for deepflow-agent, enabling basic data collection on macOS systems. Changes: - Add macOS platform constants (log file, config file paths) - Add macOS platform querier (hostname, IP address collection) - Add macOS process data placeholder - Add macOS RecvEngine default (using libpcap) Note: This is an initial implementation. Advanced features like eBPF, AF_PACKET, and network namespace support are not available on macOS. The agent uses libpcap for packet capture. Related: #issue for macOS support
There was a problem hiding this comment.
Pull request overview
Adds initial macOS support for deepflow-agent by wiring in macOS-specific platform implementations so the agent can run with basic platform querying and libpcap-based packet capture (instead of Linux-only mechanisms like AF_PACKET/eBPF).
Changes:
- Add a macOS
platform::querier::Querierimplementation and hook it into the platform querier selector. - Add macOS stubs for platform process synchronization (
ProcessData) where Linux-only functionality isn’t available. - Enable
RecvEngine::default()on macOS to useLibpcap, and add macOS platform constants (paths/corefile settings).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| agent/src/platform/querier/macos.rs | New macOS querier implementation for hostname/IP collection and genesis sync message generation. |
| agent/src/platform/querier.rs | Selects the macOS querier via cfg(target_os = "macos"). |
| agent/src/platform/platform_synchronizer/mod.rs | Adds macOS ProcessData placeholder for non-Linux platforms. |
| agent/src/dispatcher/recv_engine/mod.rs | Enables RecvEngine::default() for macOS to use libpcap. |
| agent/crates/public/src/consts.rs | Adds macOS-specific process name and platform constants (paths/corefile settings). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| use crate::{ | ||
| config::handler::PlatformConfig, | ||
| utils::command::{get_hostname, get_ip_address}, | ||
| }; | ||
|
|
||
| use public::proto::agent as pb; | ||
|
|
There was a problem hiding this comment.
Querier imports get_hostname/get_ip_address from crate::utils::command, but agent/src/utils/command/mod.rs only exports implementations for linux|android and windows (no macos module). As-is, macOS builds will fail with unresolved imports. Add a macOS implementation (e.g., command/macos.rs) and update the cfg gates in command/mod.rs to include target_os = "macos" (and implement get_ip_address using ifconfig/system APIs).
| use crate::{ | |
| config::handler::PlatformConfig, | |
| utils::command::{get_hostname, get_ip_address}, | |
| }; | |
| use public::proto::agent as pb; | |
| use std::process::Command; | |
| use crate::config::handler::PlatformConfig; | |
| use public::proto::agent as pb; | |
| fn get_hostname() -> std::io::Result<String> { | |
| let output = Command::new("hostname").output()?; | |
| let hostname = String::from_utf8_lossy(&output.stdout).trim().to_string(); | |
| Ok(hostname) | |
| } | |
| fn get_ip_address() -> std::io::Result<String> { | |
| let output = Command::new("ifconfig").arg("-a").output()?; | |
| let ip_info = String::from_utf8_lossy(&output.stdout).to_string(); | |
| Ok(ip_info) | |
| } |
Motivation
This PR adds initial macOS support for deepflow-agent, enabling basic data collection capabilities on macOS systems. While eBPF-based deep observability is not available on macOS (due to platform limitations), this allows users to leverage other deepflow-agent features on macOS development machines.
Changes
Platform Constants
Platform Querier
Querierstruct for hostname and IP address collectionget_hostname()andget_ip_address()utilitiesPlatform Synchronizer
ProcessDataplaceholder structReceive Engine
RecvEngine::default()implementation usingLibpcapLimitations
The following features are not available on macOS due to platform differences:
Testing
This PR enables the agent to compile and run basic operations on macOS. Packet capture via libpcap is functional for local traffic analysis.
Use Cases
Related
Checklist
cfg(target_os = "macos")