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 action [ :enable, :start ]
26 supports :status => true, :restart => true, :reload => true
29 servers = search(:node, "recipes:munin\\:\\:server")
31 servers.each do |server|
32 server.interfaces(:role => :external) do |interface|
34 firewall_rule "accept-munin-#{server}" do
36 family interface[:family]
37 source "#{interface[:zone]}:#{interface[:address]}"
47 template "/etc/munin/munin-node.conf" do
48 source "munin-node.conf.erb"
52 variables :servers => servers
53 notifies :restart, "service[munin-node]"
56 remote_directory "/usr/local/share/munin/plugins" do
67 remote_directory "/etc/munin/plugin-conf.d" do
68 source "plugin-conf.d"
76 notifies :restart, "service[munin-node]"
79 if node[:dmi] and node[:dmi][:system] and node[:dmi][:system][:manufacturer] == "HP"
80 case node[:dmi][:system][:product_name]
81 when "ProLiant DL360 G6", "ProLiant DL360 G7"
82 template "/etc/sensors.d/disable-bad-acpi-sensor.conf" do
83 source "disable-bad-acpi-sensor.conf.erb"
91 if Dir.glob("/proc/acpi/thermal_zone/*/temperature").empty?
92 munin_plugin "acpi" do
102 if File.exists?("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state")
103 munin_plugin "cpuspeed"
105 munin_plugin "cpuspeed" do
111 munin_plugin "df_inode"
112 munin_plugin "diskstats"
113 munin_plugin "entropy"
116 if node[:kernel][:modules].include?("nf_conntrack")
119 munin_plugin "fw_conntrack"
120 munin_plugin "fw_forwarded_local"
122 munin_plugin "fw_conntrack" do
126 munin_plugin "fw_forwarded_local" do
131 if File.read("/proc/sys/net/ipv4/ip_forward").chomp == "1"
132 munin_plugin "fw_packets"
134 munin_plugin "fw_packets" do
139 disks = node[:block_device].select do |name,attributes|
140 [ "ATA", "FUJITSU", "SEAGATE", "DELL", "COMPAQ", "IBM-ESXS" ].include?(attributes[:vendor])
144 munin_plugin "hddtemp_smartctl" do
148 munin_plugin "hddtemp_smartctl" do
150 conf_variables :disks => disks
154 if File.exists?("/sbin/hpasmcli")
155 munin_plugin "hpasmcli_temp"
156 munin_plugin "hpasmcli_fans"
158 munin_plugin "hpasmcli_temp" do
162 munin_plugin "hpasmcli_fans" do
167 munin_plugin "http_loadtime" do
171 node[:network][:interfaces].each do |ifname,ifattr|
172 if ifname =~ /^eth\d+$/
173 if ifattr[:flags] and ifattr[:flags].include?("UP")
174 munin_plugin "if_err_#{ifname}" do
178 munin_plugin "if_#{ifname}" do
182 munin_plugin "if_err_#{ifname}" do
186 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_fans" do
210 munin_plugin "ipmi_temp" do
215 munin_plugin "irqstats"
217 munin_plugin "memory"
218 munin_plugin "netstat"
220 if node[:kernel][:modules].include?("nfsv3")
221 munin_plugin "nfs_client"
223 munin_plugin "nfs_client" do
228 if node[:kernel][:modules].include?("nfsv4")
229 munin_plugin "nfs4_client"
231 munin_plugin "nfs4_client" do
236 if node[:kernel][:modules].include?("nfsd")
240 munin_plugin "nfsd" do
244 munin_plugin "nfsd4" do
249 munin_plugin "open_files"
250 munin_plugin "open_inodes"
252 munin_plugin "postfix_mailqueue" do
256 munin_plugin "postfix_mailvolume" do
260 munin_plugin "processes"
261 munin_plugin "proc_pri"
267 Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
268 hwmon = "#{hwmon}/device" unless File.exists?("#{hwmon}/name")
270 sensors_fan = true unless Dir.glob("#{hwmon}/fan*_input").empty?
271 sensors_temp = true unless Dir.glob("#{hwmon}/temp*_input").empty?
272 sensors_volt = true unless Dir.glob("#{hwmon}/in*_input").empty?
275 if sensors_fan || sensors_temp || sensors_volt
280 munin_plugin "sensors_fan" do
284 munin_plugin "sensors_fan" do
290 munin_plugin "sensors_temp" do
294 munin_plugin "sensors_temp" do
300 munin_plugin "sensors_volt" do
304 munin_plugin "sensors_volt" do
309 node[:block_device].each do |name,attributes|
310 if attributes[:vendor] == "ATA"
311 munin_plugin "smart_#{name}" do
315 munin_plugin "smart_#{name}" do
323 munin_plugin "threads"
324 munin_plugin "uptime"
326 munin_plugin "vmstat"