parent
2fb07c9291
commit
9983c2ea30
2 changed files with 22 additions and 0 deletions
@ -0,0 +1,2 @@ |
|||||||
|
# Can replace the builtin net.if.discovery on agent < 2.0.0 |
||||||
|
UserParameter=net.if.discovery,/var/lib/zabbix/bin/disco_net_interface |
@ -0,0 +1,20 @@ |
|||||||
|
#!/usr/bin/perl -w |
||||||
|
|
||||||
|
use JSON; |
||||||
|
|
||||||
|
opendir(my $dh, "/sys/class/net") or die "Couldn't open /sys/class/net: $!"; |
||||||
|
my @nics = grep { $_ !~ m/^\./ } readdir($dh); |
||||||
|
closedir($dh); |
||||||
|
my $json; |
||||||
|
foreach my $nic (@nics){ |
||||||
|
# Untaint $nic and makes sure the name looks OK |
||||||
|
next unless ($nic =~ m/^(\w+[\.:]?\d+)$/); |
||||||
|
$nic = $1; |
||||||
|
next if ( |
||||||
|
# skip non links |
||||||
|
!-l "/sys/class/net/$nic" |
||||||
|
); |
||||||
|
push @{$json->{data}}, { "{#IFNAME}" => $nic}; |
||||||
|
} |
||||||
|
print to_json($json) if (defined $json->{data}); |
||||||
|
exit(0); |
Loading…
Reference in new issue