Skip to content

feat(ref #1): add new source for LLDP #23104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 56 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ ipnet = { version = "2", default-features = false, optional = true, features = [
itertools = { version = "0.14.0", default-features = false, optional = false, features = ["use_alloc"] }
k8s-openapi = { version = "0.22.0", default-features = false, features = ["v1_26"], optional = true }
kube = { version = "0.93.0", default-features = false, features = ["client", "openssl-tls", "runtime"], optional = true }
libc = "0.2.171"
listenfd = { version = "1.0.2", default-features = false, optional = true }
lru = { version = "0.13.0", default-features = false, optional = true }
maxminddb = { version = "0.26.0", default-features = false, optional = true, features = ["simdutf8"] }
Expand Down Expand Up @@ -405,6 +406,7 @@ heim = { git = "https://github.com/vectordotdev/heim.git", branch = "update-nix"
mlua = { version = "0.10.3", default-features = false, features = ["lua54", "send", "vendored", "macros"], optional = true }
sysinfo = "0.34.2"
byteorder = "1.5.0"
time = "0.3.36"

[target.'cfg(windows)'.dependencies]
windows-service = "0.7.0"
Expand All @@ -419,6 +421,7 @@ netlink-packet-core = "0.7.0"
netlink-sys = { version = "0.8.7", features = ["tokio_socket"] }

[build-dependencies]
bindgen = "0.71.1"
prost-build = { workspace = true, optional = true }
tonic-build = { workspace = true, optional = true }
# update 'openssl_version' in website/config.toml whenever <major.minor> version changes
Expand Down Expand Up @@ -605,6 +608,7 @@ sources-metrics = [
"sources-static_metrics",
"sources-statsd",
"sources-vector",
"sources-lldp",
]

sources-amqp = ["lapin"]
Expand Down Expand Up @@ -634,6 +638,7 @@ sources-journald = []
sources-kafka = ["dep:rdkafka"]
sources-kubernetes_logs = ["vector-lib/file-source", "kubernetes", "transforms-reduce"]
sources-logstash = ["sources-utils-net-tcp", "tokio-util/net"]
sources-lldp = []
sources-mongodb_metrics = ["dep:mongodb"]
sources-nats = ["dep:async-nats", "dep:nkeys"]
sources-nginx_metrics = ["dep:nom"]
Expand Down
17 changes: 17 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,23 @@ fn main() {
// Always rerun if the build script itself changes.
println!("cargo:rerun-if-changed=build.rs");

println!("cargo:rustc-link-search=native=/usr/lib/x86_64-linux-gnu");
println!("cargo:rustc-link-lib=dylib=lldpctl");

println!("cargo:rerun-if-changed=src/sources/lldp/wrapper.h");

// 生成 lldpctl bindings
let lldp_bindings = bindgen::Builder::default()
.header("src/sources/lldp/wrapper.h") // 你要创建这个 wrapper.h
.clang_arg("-I/usr/include/") // 可能需要根据实际 lldp 安装路径添加
.layout_tests(false)
.generate()
.expect("Unable to generate lldpctl bindings");

lldp_bindings
.write_to_file("src/sources/lldp/bindings.rs")
.expect("Couldn't write lldpctl bindings!");

// re-run if the HEAD has changed. This is only necessary for non-release and nightly builds.
#[cfg(not(feature = "nightly"))]
println!("cargo:rerun-if-changed=.git/HEAD");
Expand Down
2 changes: 1 addition & 1 deletion distribution/docker/debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ LABEL org.opencontainers.image.documentation="https://vector.dev/docs"

# we want the latest versions of these
# hadolint ignore=DL3008
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates tzdata systemd && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates tzdata systemd liblldpctl-dev && rm -rf /var/lib/apt/lists/*

COPY --from=builder /usr/bin/vector /usr/bin/vector
COPY --from=builder /usr/share/vector /usr/share/vector
Expand Down
23 changes: 22 additions & 1 deletion scripts/cross/x86_64-unknown-linux-gnu.dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
FROM ghcr.io/cross-rs/x86_64-unknown-linux-gnu:0.2.5

RUN apt-get update && apt-get install -y \
apt-transport-https \
ca-certificates \
wget \
gnupg \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*

RUN sed -i \
-e 's|http://[^/]*/ubuntu|https://mirrors.tuna.tsinghua.edu.cn/ubuntu|g' \
/etc/apt/sources.list

RUN apt-get update && apt-get install -y \
liblldpctl-dev \
pkg-config \
build-essential \
libc6-dev \
libclang-dev \
clang \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/cross/bootstrap-ubuntu.sh scripts/environment/install-protoc.sh /
RUN /bootstrap-ubuntu.sh && bash /install-protoc.sh
RUN /bootstrap-ubuntu.sh && bash /install-protoc.sh
Loading
Loading