Skip to content

feat(agent): add basic macOS platform support#11449

Open
zy84338719 wants to merge 1 commit intodeepflowio:mainfrom
zy84338719:feat/macos-support
Open

feat(agent): add basic macOS platform support#11449
zy84338719 wants to merge 1 commit intodeepflowio:mainfrom
zy84338719:feat/macos-support

Conversation

@zy84338719
Copy link

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

  • Add macOS-specific platform constants (log file path, config file paths, core file handling)

Platform Querier

  • Implement macOS Querier struct for hostname and IP address collection
  • Reuses existing get_hostname() and get_ip_address() utilities

Platform Synchronizer

  • Add macOS ProcessData placeholder struct
  • Note: Advanced process tracking features from Linux are not available on macOS

Receive Engine

  • Add macOS RecvEngine::default() implementation using Libpcap
  • Note: AF_PACKET is Linux-specific, so macOS uses libpcap for packet capture

Limitations

The following features are not available on macOS due to platform differences:

  • eBPF-based observability (kernel-level tracing)
  • AF_PACKET high-performance packet capture
  • Network namespace support
  • Advanced process/socket synchronization
  • cgroups integration

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

  1. Development & Testing: Developers using macOS can run deepflow-agent locally for testing
  2. Local Monitoring: Basic network traffic monitoring on macOS machines
  3. Cross-Platform Development: Enables building and testing agent code on macOS

Related

  • Issue: Add macOS platform support
  • Follow-up work: Additional macOS-specific optimizations and features can be added incrementally

Checklist

  • Code compiles on macOS
  • Platform-specific code uses cfg(target_os = "macos")
  • No breaking changes to Linux/Windows support
  • Documentation updated (this PR description)

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
Copilot AI review requested due to automatic review settings March 10, 2026 19:48
@CLAassistant
Copy link

CLAassistant commented Mar 10, 2026

CLA assistant check
All committers have signed the CLA.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::Querier implementation 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 use Libpcap, 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.

Comment on lines +21 to +28

use crate::{
config::handler::PlatformConfig,
utils::command::{get_hostname, get_ip_address},
};

use public::proto::agent as pb;

Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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)
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants