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 node[:dmi] and node[:dmi][:system] and node[:dmi][:system][:manufacturer] == "HP"
83 case node[:dmi][:system][:product_name]
84 when "ProLiant DL360 G6", "ProLiant DL360 G7"
85 template "/etc/sensors.d/disable-bad-acpi-sensor.conf" do
86 source "disable-bad-acpi-sensor.conf.erb"
94 if Dir.glob("/proc/acpi/thermal_zone/*/temperature").empty?
95 munin_plugin "acpi" do
105 if File.exists?("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state")
106 munin_plugin "cpuspeed"
108 munin_plugin "cpuspeed" do
114 munin_plugin "df_inode"
115 munin_plugin "diskstats"
116 munin_plugin "entropy"
119 if node[:kernel][:modules].include?("nf_conntrack")
122 munin_plugin "fw_conntrack"
123 munin_plugin "fw_forwarded_local"
125 munin_plugin "fw_conntrack" do
129 munin_plugin "fw_forwarded_local" do
134 if File.read("/proc/sys/net/ipv4/ip_forward").chomp == "1"
135 munin_plugin "fw_packets"
137 munin_plugin "fw_packets" do
142 disks = node[:block_device].select do |name,attributes|
143 [ "ATA", "FUJITSU", "SEAGATE", "DELL", "COMPAQ", "IBM-ESXS" ].include?(attributes[:vendor])
147 munin_plugin "hddtemp_smartctl" do
151 munin_plugin "hddtemp_smartctl" do
153 conf_variables :disks => disks
157 if File.exists?("/sbin/hpasmcli")
158 munin_plugin "hpasmcli_temp"
159 munin_plugin "hpasmcli_fans"
161 munin_plugin "hpasmcli_temp" do
165 munin_plugin "hpasmcli_fans" do
170 munin_plugin "http_loadtime" do
174 node[:network][:interfaces].each do |ifname,ifattr|
175 if ifname =~ /^eth\d+$/
176 if ifattr[:flags] and ifattr[:flags].include?("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
196 munin_plugin "interrupts"
197 munin_plugin "iostat"
198 munin_plugin "iostat_ios"
200 if Dir.glob("/dev/ipmi*").empty?
201 munin_plugin "ipmi_fans" do
205 munin_plugin "ipmi_temp" do
209 munin_plugin "ipmi_fans" do
213 munin_plugin "ipmi_temp" do
218 munin_plugin "irqstats"
220 munin_plugin "memory"
221 munin_plugin "netstat"
223 if node[:kernel][:modules].include?("nfsv3")
224 munin_plugin "nfs_client"
226 munin_plugin "nfs_client" do
231 if node[:kernel][:modules].include?("nfsv4")
232 munin_plugin "nfs4_client"
234 munin_plugin "nfs4_client" do
239 if node[:kernel][:modules].include?("nfsd")
243 munin_plugin "nfsd" do
247 munin_plugin "nfsd4" do
252 munin_plugin "open_files"
253 munin_plugin "open_inodes"
255 munin_plugin "postfix_mailqueue" do
259 munin_plugin "postfix_mailvolume" do
263 munin_plugin "processes"
264 munin_plugin "proc_pri"
270 Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
271 hwmon = "#{hwmon}/device" unless File.exists?("#{hwmon}/name")
273 sensors_fan = true unless Dir.glob("#{hwmon}/fan*_input").empty?
274 sensors_temp = true unless Dir.glob("#{hwmon}/temp*_input").empty?
275 sensors_volt = true unless Dir.glob("#{hwmon}/in*_input").empty?
278 if sensors_fan || sensors_temp || sensors_volt
283 munin_plugin "sensors_fan" do
287 munin_plugin "sensors_fan" do
293 munin_plugin "sensors_temp" do
297 munin_plugin "sensors_temp" do
303 munin_plugin "sensors_volt" do
307 munin_plugin "sensors_volt" do
312 node[:block_device].each do |name,attributes|
313 if attributes[:vendor] == "ATA"
314 munin_plugin "smart_#{name}" do
318 munin_plugin "smart_#{name}" do
326 munin_plugin "threads"
327 munin_plugin "uptime"
329 munin_plugin "vmstat"