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")
105 munin_plugin "fw_conntrack"
106 munin_plugin "fw_forwarded_local"
108 munin_plugin "fw_conntrack" do
112 munin_plugin "fw_forwarded_local" do
117 if %x{sysctl -n net.ipv4.ip_forward}.chomp == "1"
118 munin_plugin "fw_packets"
120 munin_plugin "fw_packets" do
127 if File.exists?("/sbin/hpasmcli")
128 munin_plugin "hpasmcli_temp"
129 munin_plugin "hpasmcli_fans"
131 munin_plugin "hpasmcli_temp" do
135 munin_plugin "hpasmcli_fans" do
140 munin_plugin "http_loadtime" do
144 node[:network][:interfaces].each do |ifname,ifattr|
145 if ifname =~ /^eth\d+$/
146 if ifattr[:flags] and ifattr[:flags].include?("UP")
147 munin_plugin "if_err_#{ifname}" do
151 munin_plugin "if_#{ifname}" do
155 munin_plugin "if_err_#{ifname}" do
159 munin_plugin "if_#{ifname}" do
166 munin_plugin "interrupts"
167 munin_plugin "iostat"
168 munin_plugin "iostat_ios"
170 if Dir.glob("/dev/ipmi*").empty?
171 munin_plugin "ipmi_fans" do
175 munin_plugin "ipmi_temp" do
179 munin_plugin "ipmi_fans" do
183 munin_plugin "ipmi_temp" do
188 munin_plugin "irqstats"
190 Dir.new("/sys/block").each do |device|
191 if device.match(/^sd/)
192 munin_plugin "linux_diskstat_iops_#{device}" do
193 target "linux_diskstat_"
196 munin_plugin "linux_diskstat_latency_#{device}" do
197 target "linux_diskstat_"
200 munin_plugin "linux_diskstat_throughput_#{device}" do
201 target "linux_diskstat_"
207 munin_plugin "memory"
208 munin_plugin "netstat"
210 if File.exists?("/proc/net/rpc/nfs")
211 munin_plugin "nfs4_client"
213 munin_plugin "nfs4_client" do
218 if File.exists?("/proc/net/rpc/nfsd")
222 munin_plugin "nfsd" do
226 munin_plugin "nfsd4" do
231 munin_plugin "open_files"
232 munin_plugin "open_inodes"
234 munin_plugin "postfix_mailqueue" do
238 munin_plugin "postfix_mailvolume" do
242 munin_plugin "processes"
243 munin_plugin "proc_pri"
249 Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
252 hwmon = "#{hwmon}/device" unless File.exists?("#{hwmon}/name")
254 sensors_fan = true unless Dir.glob("#{hwmon}/fan*_input").empty?
255 sensors_temp = true unless Dir.glob("#{hwmon}/temp*_input").empty?
256 sensors_volt = true unless Dir.glob("#{hwmon}/in*_input").empty?
260 munin_plugin "sensors_fan" do
264 munin_plugin "sensors_fan" do
270 munin_plugin "sensors_temp" do
274 munin_plugin "sensors_temp" do
280 munin_plugin "sensors_volt" do
284 munin_plugin "sensors_volt" do
291 munin_plugin "threads"
292 munin_plugin "uptime"
294 munin_plugin "vmstat"