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
91 if File.exists?("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state")
92 munin_plugin "cpuspeed"
94 munin_plugin "cpuspeed" do
100 munin_plugin "df_inode"
101 munin_plugin "diskstats"
102 munin_plugin "entropy"
105 if File.exists?("/proc/net/ip_conntrack") or File.exists?("/proc/net/nf_conntrack")
106 munin_plugin "fw_conntrack"
107 munin_plugin "fw_forwarded_local"
109 munin_plugin "fw_conntrack" do
113 munin_plugin "fw_forwarded_local" do
118 if %x{sysctl -n net.ipv4.ip_forward}.chomp == "1"
119 munin_plugin "fw_packets"
121 munin_plugin "fw_packets" do
128 if File.exists?("/sbin/hpasmcli")
129 munin_plugin "hpasmcli_temp"
130 munin_plugin "hpasmcli_fans"
132 munin_plugin "hpasmcli_temp" do
136 munin_plugin "hpasmcli_fans" do
141 munin_plugin "http_loadtime" do
145 node[:network][:interfaces].each do |ifname,ifattr|
146 if ifname =~ /^eth\d+$/
147 if ifattr[:flags] and ifattr[:flags].include?("UP")
148 munin_plugin "if_err_#{ifname}" do
152 munin_plugin "if_#{ifname}" do
156 munin_plugin "if_err_#{ifname}" do
160 munin_plugin "if_#{ifname}" do
167 munin_plugin "interrupts"
168 munin_plugin "iostat"
169 munin_plugin "iostat_ios"
171 munin_plugin "irqstats"
173 Dir.new("/sys/block").each do |device|
174 if device.match(/^sd/)
175 munin_plugin "linux_diskstat_iops_#{device}" do
176 target "linux_diskstat_"
179 munin_plugin "linux_diskstat_latency_#{device}" do
180 target "linux_diskstat_"
183 munin_plugin "linux_diskstat_throughput_#{device}" do
184 target "linux_diskstat_"
190 munin_plugin "memory"
193 munin_plugin "netstat"
195 if File.exists?("/proc/net/rpc/nfs")
196 munin_plugin "nfs4_client"
198 munin_plugin "nfs4_client" do
203 if File.exists?("/proc/net/rpc/nfsd")
207 munin_plugin "nfsd" do
211 munin_plugin "nfsd4" do
217 munin_plugin "open_files"
218 munin_plugin "open_inodes"
221 munin_plugin "postfix_mailqueue" do
225 munin_plugin "postfix_mailvolume" do
230 munin_plugin "processes"
231 munin_plugin "proc_pri"
238 munin_plugin "threads"
239 munin_plugin "uptime"
241 munin_plugin "vmstat"