2 # Cookbook Name:: munin
5 # Copyright 2010, OpenStreetMap Foundation
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
20 include_recipe "networking"
24 service "munin-node" do
25 if node[:lsb][:release].to_f >= 14.04
26 provider Chef::Provider::Service::Upstart
28 action [:enable, :start]
29 supports :status => true, :restart => true, :reload => true
32 servers = search(:node, "recipes:munin\\:\\:server")
34 servers.each do |server|
35 server.interfaces(:role => :external) do |interface|
37 firewall_rule "accept-munin-#{server}" do
39 family interface[:family]
40 source "#{interface[:zone]}:#{interface[:address]}"
50 template "/etc/munin/munin-node.conf" do
51 source "munin-node.conf.erb"
55 variables :servers => servers
56 notifies :restart, "service[munin-node]"
59 remote_directory "/usr/local/share/munin/plugins" do
70 remote_directory "/etc/munin/plugin-conf.d" do
71 source "plugin-conf.d"
79 notifies :restart, "service[munin-node]"
82 if Dir.glob("/proc/acpi/thermal_zone/*/temperature").empty?
83 munin_plugin "acpi" do
93 if File.exist?("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state")
94 munin_plugin "cpuspeed"
96 munin_plugin "cpuspeed" do
102 munin_plugin "df_inode"
103 munin_plugin "diskstats"
104 munin_plugin "entropy"
107 if node[:kernel][:modules].include?("nf_conntrack")
110 munin_plugin "fw_conntrack"
111 munin_plugin "fw_forwarded_local"
113 munin_plugin "fw_conntrack" do
117 munin_plugin "fw_forwarded_local" do
122 if File.read("/proc/sys/net/ipv4/ip_forward").chomp == "1"
123 munin_plugin "fw_packets"
125 munin_plugin "fw_packets" do
130 disks = node[:block_device].select do |_, attributes|
131 ["ATA", "FUJITSU", "SEAGATE", "DELL", "COMPAQ", "IBM-ESXS"].include?(attributes[:vendor])
135 munin_plugin "hddtemp_smartctl" do
139 munin_plugin "hddtemp_smartctl" do
141 conf_variables :disks => disks
145 if File.exist?("/sbin/hpasmcli")
146 munin_plugin "hpasmcli2_temp" do
150 munin_plugin "hpasmcli2_fans" do
154 munin_plugin "hpasmcli2_temp" do
158 munin_plugin "hpasmcli2_fans" do
163 munin_plugin "hpasmcli_temp" do
167 munin_plugin "hpasmcli_fans" do
171 munin_plugin "http_loadtime" do
175 node[:network][:interfaces].each do |ifname, ifattr|
176 if ifattr[:encapsulation] == "Ethernet" && ifattr[:state] == "up"
177 munin_plugin "if_err_#{ifname}" do
181 munin_plugin "if_#{ifname}" do
185 munin_plugin "if_err_#{ifname}" do
189 munin_plugin "if_#{ifname}" do
195 munin_plugin "interrupts"
196 munin_plugin "iostat"
197 munin_plugin "iostat_ios"
199 if Dir.glob("/dev/ipmi*").empty?
200 munin_plugin "ipmi_fans" do
204 munin_plugin "ipmi_temp" do
208 munin_plugin "ipmi_power" do
210 only_if { node[:lsb][:release].to_f >= 14.04 }
213 munin_plugin "ipmi_fans" do
217 munin_plugin "ipmi_temp" do
221 munin_plugin "ipmi_power" do
223 only_if { node[:lsb][:release].to_f >= 14.04 }
227 munin_plugin "irqstats"
229 munin_plugin "memory"
230 munin_plugin "netstat"
232 if node[:kernel][:modules].include?("nfsv3")
233 munin_plugin "nfs_client"
235 munin_plugin "nfs_client" do
240 if node[:kernel][:modules].include?("nfsv4")
241 munin_plugin "nfs4_client"
243 munin_plugin "nfs4_client" do
248 if node[:kernel][:modules].include?("nfsd")
252 munin_plugin "nfsd" do
256 munin_plugin "nfsd4" do
261 munin_plugin "open_files"
262 munin_plugin "open_inodes"
264 munin_plugin "postfix_mailqueue" do
268 munin_plugin "postfix_mailvolume" do
272 munin_plugin "processes"
273 munin_plugin "proc_pri"
279 Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
280 hwmon = "#{hwmon}/device" unless File.exist?("#{hwmon}/name")
282 sensors_fan = true unless Dir.glob("#{hwmon}/fan*_input").empty?
283 sensors_temp = true unless Dir.glob("#{hwmon}/temp*_input").empty?
284 sensors_volt = true unless Dir.glob("#{hwmon}/in*_input").empty?
287 if sensors_fan || sensors_temp || sensors_volt
292 munin_plugin "sensors_fan" do
296 munin_plugin "sensors_fan" do
302 munin_plugin "sensors_temp" do
306 munin_plugin "sensors_temp" do
312 munin_plugin "sensors_volt" do
314 conf "sensors_volt.erb"
317 munin_plugin "sensors_volt" do
322 node[:block_device].each do |name, attributes|
323 if attributes[:vendor] == "ATA"
324 munin_plugin "smart_#{name}" do
327 conf_variables :disk => name
330 munin_plugin "smart_#{name}" do
338 munin_plugin "threads"
339 munin_plugin "uptime"
341 munin_plugin "vmstat"