]> git.openstreetmap.org Git - chef.git/blob - cookbooks/hardware/templates/default/lldp.rb.erb
Stop running hwraid status daemons
[chef.git] / cookbooks / hardware / templates / default / lldp.rb.erb
1 require "json"
2
3 Ohai.plugin(:Lldp) do
4   provides "lldp"
5
6   collect_data(:default) do
7     lldp Mash.new
8
9     json = JSON.parse(%x(/usr/sbin/lldpctl -f json))
10
11     interfaces = if json["lldp"]["interface"].is_a?(Array)
12                    json["lldp"]["interface"]
13                  else
14                    [json["lldp"]["interface"]]
15                  end
16
17     interfaces.each do |interface|
18       interface.each do |name, details|
19         lldp[name] = details
20       end
21     end
22
23     lldp
24   end
25 end