From b71847feba09f2a6ebd1ba2d1b05353d5b5b82ec Mon Sep 17 00:00:00 2001 From: higkoo Date: Mon, 23 Mar 2020 19:46:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0IP=E5=9C=B0=E5=9D=80=E7=9A=84?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ifconfig 和 route 命令,写绝对路径会导致兼容性不好。 1. Debian系统路径对应: /sbin/ifconfig 和 /sbin/route 2. 原命令获取的IP地址兼容性不好,会带“addr:”在前面。 addr:192.163.10.31 3. 本地配置正确的情况下 `hostname -i`是能拿到正确IP的 --- etc/collector.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/collector.yml b/etc/collector.yml index f1218cdd..eb0e960b 100644 --- a/etc/collector.yml +++ b/etc/collector.yml @@ -4,7 +4,7 @@ logger: keepHours: 2 identity: specify: "" - shell: /usr/sbin/ifconfig `/usr/sbin/route|grep '^default'|awk '{print $NF}'`|grep inet|awk '{print $2}'|head -n 1 + shell: hostname -i sys: # timeout in ms # interval in second -- GitLab