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.exists?("/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 |name,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.exists?("/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 ifname =~ /^eth\d+$/
177 if ifattr[:flags] and ifattr[:flags].include?("UP")
178 munin_plugin "if_err_#{ifname}" do
182 munin_plugin "if_#{ifname}" do
186 munin_plugin "if_err_#{ifname}" do
190 munin_plugin "if_#{ifname}" do
197 munin_plugin "interrupts"
198 munin_plugin "iostat"
199 munin_plugin "iostat_ios"
201 if Dir.glob("/dev/ipmi*").empty?
202 munin_plugin "ipmi_fans" do
206 munin_plugin "ipmi_temp" do
210 munin_plugin "ipmi_power" do
212 only_if { node[:lsb][:release].to_f >= 14.04 }
215 munin_plugin "ipmi_fans" do
219 munin_plugin "ipmi_temp" do
223 munin_plugin "ipmi_power" do
225 only_if { node[:lsb][:release].to_f >= 14.04 }
229 munin_plugin "irqstats"
231 munin_plugin "memory"
232 munin_plugin "netstat"
234 if node[:kernel][:modules].include?("nfsv3")
235 munin_plugin "nfs_client"
237 munin_plugin "nfs_client" do
242 if node[:kernel][:modules].include?("nfsv4")
243 munin_plugin "nfs4_client"
245 munin_plugin "nfs4_client" do
250 if node[:kernel][:modules].include?("nfsd")
254 munin_plugin "nfsd" do
258 munin_plugin "nfsd4" do
263 munin_plugin "open_files"
264 munin_plugin "open_inodes"
266 munin_plugin "postfix_mailqueue" do
270 munin_plugin "postfix_mailvolume" do
274 munin_plugin "processes"
275 munin_plugin "proc_pri"
281 Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
282 hwmon = "#{hwmon}/device" unless File.exists?("#{hwmon}/name")
284 sensors_fan = true unless Dir.glob("#{hwmon}/fan*_input").empty?
285 sensors_temp = true unless Dir.glob("#{hwmon}/temp*_input").empty?
286 sensors_volt = true unless Dir.glob("#{hwmon}/in*_input").empty?
289 if sensors_fan || sensors_temp || sensors_volt
294 munin_plugin "sensors_fan" do
298 munin_plugin "sensors_fan" do
304 munin_plugin "sensors_temp" do
308 munin_plugin "sensors_temp" do
314 munin_plugin "sensors_volt" do
316 conf "sensors_volt.erb"
319 munin_plugin "sensors_volt" do
324 node[:block_device].each do |name,attributes|
325 if attributes[:vendor] == "ATA"
326 munin_plugin "smart_#{name}" do
329 conf_variables :disk => name
332 munin_plugin "smart_#{name}" do
340 munin_plugin "threads"
341 munin_plugin "uptime"
343 munin_plugin "vmstat"