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|
36 firewall_rule "accept-munin-#{server}" do
38 family interface[:family]
39 source "#{interface[:zone]}:#{interface[:address]}"
48 template "/etc/munin/munin-node.conf" do
49 source "munin-node.conf.erb"
53 variables :servers => servers
54 notifies :restart, "service[munin-node]"
57 remote_directory "/usr/local/share/munin/plugins" do
68 remote_directory "/etc/munin/plugin-conf.d" do
69 source "plugin-conf.d"
77 notifies :restart, "service[munin-node]"
80 if Dir.glob("/proc/acpi/thermal_zone/*/temperature").empty?
81 munin_plugin "acpi" do
91 if File.exist?("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state")
92 munin_plugin "cpuspeed"
94 munin_plugin "cpuspeed" do
100 munin_plugin "df_inode"
101 munin_plugin "diskstats"
102 munin_plugin "entropy"
105 if node[:kernel][:modules].include?("nf_conntrack")
108 munin_plugin "fw_conntrack"
109 munin_plugin "fw_forwarded_local"
111 munin_plugin "fw_conntrack" do
115 munin_plugin "fw_forwarded_local" do
120 if File.read("/proc/sys/net/ipv4/ip_forward").chomp == "1"
121 munin_plugin "fw_packets"
123 munin_plugin "fw_packets" do
128 disks = node[:block_device].select do |_, attributes|
129 ["ATA", "FUJITSU", "SEAGATE", "DELL", "COMPAQ", "IBM-ESXS"].include?(attributes[:vendor])
133 munin_plugin "hddtemp_smartctl" do
137 munin_plugin "hddtemp_smartctl" do
139 conf_variables :disks => disks
143 if File.exist?("/sbin/hpasmcli")
144 munin_plugin "hpasmcli2_temp" do
148 munin_plugin "hpasmcli2_fans" do
152 munin_plugin "hpasmcli2_temp" do
156 munin_plugin "hpasmcli2_fans" do
161 munin_plugin "hpasmcli_temp" do # ~FC005
165 munin_plugin "hpasmcli_fans" do
169 munin_plugin "http_loadtime" do
173 node[:network][:interfaces].each do |ifname, ifattr|
174 if ifattr[:encapsulation] == "Ethernet" && ifattr[:state] == "up"
175 munin_plugin "if_err_#{ifname}" do
179 munin_plugin "if_#{ifname}" do
183 munin_plugin "if_err_#{ifname}" do
187 munin_plugin "if_#{ifname}" do
193 munin_plugin "interrupts"
194 munin_plugin "iostat"
195 munin_plugin "iostat_ios"
197 if Dir.glob("/dev/ipmi*").empty?
198 munin_plugin "ipmi_fans" do
202 munin_plugin "ipmi_temp" do
206 munin_plugin "ipmi_power" do
208 only_if { node[:lsb][:release].to_f >= 14.04 }
211 munin_plugin "ipmi_fans" do
215 munin_plugin "ipmi_temp" do
219 munin_plugin "ipmi_power" do
221 only_if { node[:lsb][:release].to_f >= 14.04 }
225 munin_plugin "irqstats"
227 munin_plugin "memory"
228 munin_plugin "netstat"
230 if node[:kernel][:modules].include?("nfsv3")
231 munin_plugin "nfs_client"
233 munin_plugin "nfs_client" do
238 if node[:kernel][:modules].include?("nfsv4")
239 munin_plugin "nfs4_client"
241 munin_plugin "nfs4_client" do
246 if node[:kernel][:modules].include?("nfsd")
250 munin_plugin "nfsd" do
254 munin_plugin "nfsd4" do
259 munin_plugin "open_files"
260 munin_plugin "open_inodes"
262 munin_plugin "postfix_mailqueue" do
266 munin_plugin "postfix_mailvolume" do
270 munin_plugin "processes"
271 munin_plugin "proc_pri"
277 Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
278 hwmon = "#{hwmon}/device" unless File.exist?("#{hwmon}/name")
280 sensors_fan = true unless Dir.glob("#{hwmon}/fan*_input").empty?
281 sensors_temp = true unless Dir.glob("#{hwmon}/temp*_input").empty?
282 sensors_volt = true unless Dir.glob("#{hwmon}/in*_input").empty?
285 if sensors_fan || sensors_temp || sensors_volt
290 munin_plugin "sensors_fan" do
294 munin_plugin "sensors_fan" do
300 munin_plugin "sensors_temp" do
304 munin_plugin "sensors_temp" do
310 munin_plugin "sensors_volt" do
312 conf "sensors_volt.erb"
315 munin_plugin "sensors_volt" do
320 node[:block_device].each do |name, attributes|
321 if attributes[:vendor] == "ATA"
322 munin_plugin "smart_#{name}" do
325 conf_variables :disk => name
328 munin_plugin "smart_#{name}" do
336 munin_plugin "threads"
337 munin_plugin "uptime"
339 munin_plugin "vmstat"