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, resources(: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, resources(:service => "munin-node")
79 if Dir.glob("/proc/acpi/thermal_zone/*/temperature").empty?
80 munin_plugin "acpi" do
90 if File.exists?("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state")
91 munin_plugin "cpuspeed"
93 munin_plugin "cpuspeed" do
99 munin_plugin "df_inode"
100 munin_plugin "diskstats"
101 munin_plugin "entropy"
104 if node[:kernel][:modules].include?("nf_conntrack")
107 munin_plugin "fw_conntrack"
108 munin_plugin "fw_forwarded_local"
110 munin_plugin "fw_conntrack" do
114 munin_plugin "fw_forwarded_local" do
119 if %x{sysctl -n net.ipv4.ip_forward}.chomp == "1"
120 munin_plugin "fw_packets"
122 munin_plugin "fw_packets" do
129 if File.exists?("/sbin/hpasmcli")
130 munin_plugin "hpasmcli_temp"
131 munin_plugin "hpasmcli_fans"
133 munin_plugin "hpasmcli_temp" do
137 munin_plugin "hpasmcli_fans" do
142 munin_plugin "http_loadtime" do
146 node[:network][:interfaces].each do |ifname,ifattr|
147 if ifname =~ /^eth\d+$/
148 if ifattr[:flags] and ifattr[:flags].include?("UP")
149 munin_plugin "if_err_#{ifname}" do
153 munin_plugin "if_#{ifname}" do
157 munin_plugin "if_err_#{ifname}" do
161 munin_plugin "if_#{ifname}" do
168 munin_plugin "interrupts"
169 munin_plugin "iostat"
170 munin_plugin "iostat_ios"
172 if Dir.glob("/dev/ipmi*").empty?
173 munin_plugin "ipmi_fans" do
177 munin_plugin "ipmi_temp" do
181 munin_plugin "ipmi_fans" do
185 munin_plugin "ipmi_temp" do
190 munin_plugin "irqstats"
192 Dir.new("/sys/block").each do |device|
193 if device.match(/^sd/)
194 munin_plugin "linux_diskstat_iops_#{device}" do
195 target "linux_diskstat_"
198 munin_plugin "linux_diskstat_latency_#{device}" do
199 target "linux_diskstat_"
202 munin_plugin "linux_diskstat_throughput_#{device}" do
203 target "linux_diskstat_"
209 munin_plugin "memory"
210 munin_plugin "netstat"
212 if File.exists?("/proc/net/rpc/nfs")
213 munin_plugin "nfs4_client"
215 munin_plugin "nfs4_client" do
220 if File.exists?("/proc/net/rpc/nfsd")
224 munin_plugin "nfsd" do
228 munin_plugin "nfsd4" do
233 munin_plugin "open_files"
234 munin_plugin "open_inodes"
236 munin_plugin "postfix_mailqueue" do
240 munin_plugin "postfix_mailvolume" do
244 munin_plugin "processes"
245 munin_plugin "proc_pri"
251 Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
254 hwmon = "#{hwmon}/device" unless File.exists?("#{hwmon}/name")
256 sensors_fan = true unless Dir.glob("#{hwmon}/fan*_input").empty?
257 sensors_temp = true unless Dir.glob("#{hwmon}/temp*_input").empty?
258 sensors_volt = true unless Dir.glob("#{hwmon}/in*_input").empty?
262 munin_plugin "sensors_fan" do
266 munin_plugin "sensors_fan" do
272 munin_plugin "sensors_temp" do
276 munin_plugin "sensors_temp" do
282 munin_plugin "sensors_volt" do
286 munin_plugin "sensors_volt" do
293 munin_plugin "threads"
294 munin_plugin "uptime"
296 munin_plugin "vmstat"