Skip to content

Commit 961764e

Browse files
author
hejiaqi
committed
feat(ref #1): add new source for LLDP
1 parent 82ffecb commit 961764e

File tree

10 files changed

+2191
-6
lines changed

10 files changed

+2191
-6
lines changed

Cargo.lock

Lines changed: 56 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ ipnet = { version = "2", default-features = false, optional = true, features = [
353353
itertools = { version = "0.14.0", default-features = false, optional = false, features = ["use_alloc"] }
354354
k8s-openapi = { version = "0.22.0", default-features = false, features = ["v1_26"], optional = true }
355355
kube = { version = "0.93.0", default-features = false, features = ["client", "openssl-tls", "runtime"], optional = true }
356+
libc = "0.2.171"
356357
listenfd = { version = "1.0.2", default-features = false, optional = true }
357358
lru = { version = "0.13.0", default-features = false, optional = true }
358359
maxminddb = { version = "0.26.0", default-features = false, optional = true, features = ["simdutf8"] }
@@ -405,6 +406,7 @@ heim = { git = "https://github.com/vectordotdev/heim.git", branch = "update-nix"
405406
mlua = { version = "0.10.3", default-features = false, features = ["lua54", "send", "vendored", "macros"], optional = true }
406407
sysinfo = "0.34.2"
407408
byteorder = "1.5.0"
409+
time = "0.3.36"
408410

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

421423
[build-dependencies]
424+
bindgen = "0.71.1"
422425
prost-build = { workspace = true, optional = true }
423426
tonic-build = { workspace = true, optional = true }
424427
# update 'openssl_version' in website/config.toml whenever <major.minor> version changes
@@ -605,6 +608,7 @@ sources-metrics = [
605608
"sources-static_metrics",
606609
"sources-statsd",
607610
"sources-vector",
611+
"sources-lldp",
608612
]
609613

610614
sources-amqp = ["lapin"]
@@ -634,6 +638,7 @@ sources-journald = []
634638
sources-kafka = ["dep:rdkafka"]
635639
sources-kubernetes_logs = ["vector-lib/file-source", "kubernetes", "transforms-reduce"]
636640
sources-logstash = ["sources-utils-net-tcp", "tokio-util/net"]
641+
sources-lldp = []
637642
sources-mongodb_metrics = ["dep:mongodb"]
638643
sources-nats = ["dep:async-nats", "dep:nkeys"]
639644
sources-nginx_metrics = ["dep:nom"]

build.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,23 @@ fn main() {
110110
// Always rerun if the build script itself changes.
111111
println!("cargo:rerun-if-changed=build.rs");
112112

113+
println!("cargo:rustc-link-search=native=/usr/lib/x86_64-linux-gnu");
114+
println!("cargo:rustc-link-lib=dylib=lldpctl");
115+
116+
println!("cargo:rerun-if-changed=src/sources/lldp/wrapper.h");
117+
118+
// 生成 lldpctl bindings
119+
let lldp_bindings = bindgen::Builder::default()
120+
.header("src/sources/lldp/wrapper.h") // 你要创建这个 wrapper.h
121+
.clang_arg("-I/usr/include/") // 可能需要根据实际 lldp 安装路径添加
122+
.layout_tests(false)
123+
.generate()
124+
.expect("Unable to generate lldpctl bindings");
125+
126+
lldp_bindings
127+
.write_to_file("src/sources/lldp/bindings.rs")
128+
.expect("Couldn't write lldpctl bindings!");
129+
113130
// re-run if the HEAD has changed. This is only necessary for non-release and nightly builds.
114131
#[cfg(not(feature = "nightly"))]
115132
println!("cargo:rerun-if-changed=.git/HEAD");

distribution/docker/debian/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LABEL org.opencontainers.image.documentation="https://vector.dev/docs"
1616

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

2121
COPY --from=builder /usr/bin/vector /usr/bin/vector
2222
COPY --from=builder /usr/share/vector /usr/share/vector
Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
11
FROM ghcr.io/cross-rs/x86_64-unknown-linux-gnu:0.2.5
22

3+
RUN apt-get update && apt-get install -y \
4+
apt-transport-https \
5+
ca-certificates \
6+
wget \
7+
gnupg \
8+
software-properties-common \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
RUN sed -i \
12+
-e 's|http://[^/]*/ubuntu|https://mirrors.tuna.tsinghua.edu.cn/ubuntu|g' \
13+
/etc/apt/sources.list
14+
15+
RUN apt-get update && apt-get install -y \
16+
liblldpctl-dev \
17+
pkg-config \
18+
build-essential \
19+
libc6-dev \
20+
libclang-dev \
21+
clang \
22+
&& rm -rf /var/lib/apt/lists/*
23+
324
COPY scripts/cross/bootstrap-ubuntu.sh scripts/environment/install-protoc.sh /
4-
RUN /bootstrap-ubuntu.sh && bash /install-protoc.sh
25+
RUN /bootstrap-ubuntu.sh && bash /install-protoc.sh

0 commit comments

Comments
 (0)