我正在为 vnstat/vnstati 上的 webfront 编写 Perl 脚本。我不确定如何在没有任何特殊模块的情况下构建接口列表,Net::Interface
例如OS::Interface
这是我在 bash 中的操作方式:
ip addr show|grep "^[0-9]:"|grep -e "state UP"|cut -d':' -f2
它返回 wlan1,但我需要让它在 Perl 中创建一个数组。这是我到目前为止所拥有的:
my @graphs = (
{ interface => 'eth0' },
{ interface => 'venet0' },
);
这是“默认值”,但我的一些机器超过 1 台,我不想在每次构建新的测试服务器时都自定义它。