collect_data(:default) do
lldp Mash.new
- json = JSON.parse(%x(/sbin/lldpctl -f json))
+ json = JSON.parse(%x(/usr/sbin/lldpctl -f json))
- json["lldp"].each do |key, value|
- lldp[key] = value
+ interfaces = if json["lldp"]["interface"].is_a?(Array)
+ json["lldp"]["interface"]
+ else
+ [json["lldp"]["interface"]]
+ end
+
+ interfaces.each do |interface|
+ interface.each do |name, details|
+ lldp[name] = details
+ end
end
lldp