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 # https://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.
22 service "munin-node" do
23 action [:enable, :start]
24 supports :status => true, :restart => true, :reload => true
27 servers = search(:node, "recipes:munin\\:\\:server") # ~FC010
29 servers.each do |server|
30 server.interfaces(:role => :external) do |interface|
31 firewall_rule "accept-munin-#{server}" do
33 family interface[:family]
34 source "#{interface[:zone]}:#{interface[:address]}"
43 template "/etc/munin/munin-node.conf" do
44 source "munin-node.conf.erb"
48 variables :servers => servers
49 notifies :restart, "service[munin-node]"
52 remote_directory "/usr/local/share/munin/plugins" do
63 remote_directory "/etc/munin/plugin-conf.d" do
64 source "plugin-conf.d"
72 notifies :restart, "service[munin-node]"
75 if Dir.glob("/proc/acpi/thermal_zone/*/temperature").empty?
76 munin_plugin "acpi" do
86 if File.exist?("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state")
87 munin_plugin "cpuspeed"
89 munin_plugin "cpuspeed" do
94 munin_plugin_conf "df" do
99 munin_plugin "df_inode"
101 munin_plugin_conf "diskstats" do
102 template "diskstats.erb"
105 munin_plugin "diskstats"
106 munin_plugin "entropy"
109 if node[:kernel][:modules].include?("nf_conntrack")
112 munin_plugin "fw_conntrack"
113 munin_plugin "fw_forwarded_local"
115 munin_plugin "fw_conntrack" do
119 munin_plugin "fw_forwarded_local" do
124 if File.read("/proc/sys/net/ipv4/ip_forward").chomp == "1"
125 munin_plugin "fw_packets"
127 munin_plugin "fw_packets" do
132 if File.exist?("/sbin/hpasmcli")
133 munin_plugin "hpasmcli2_temp" do
137 munin_plugin "hpasmcli2_fans" do
141 munin_plugin "hpasmcli2_temp" do
145 munin_plugin "hpasmcli2_fans" do
150 munin_plugin "hpasmcli_temp" do # ~FC005
154 munin_plugin "hpasmcli_fans" do
158 munin_plugin "http_loadtime" do
162 node[:network][:interfaces].each do |ifname, ifattr|
163 if ifattr[:encapsulation] == "Ethernet" && ifattr[:state] == "up"
164 if node[:hardware] &&
165 node[:hardware][:network] &&
166 node[:hardware][:network][ifname][:device] =~ /^virtio/
167 munin_plugin_conf "if_#{ifname}" do
169 variables :ifname => ifname
172 munin_plugin_conf "if_#{ifname}" do
177 munin_plugin "if_err_#{ifname}" do
181 munin_plugin "if_#{ifname}" do
185 munin_plugin "if_err_#{ifname}" do
189 munin_plugin "if_#{ifname}" do
195 munin_plugin "interrupts"
196 munin_plugin "iostat"
197 munin_plugin "iostat_ios"
199 if Dir.glob("/dev/ipmi*").empty?
200 munin_plugin_conf "ipmi" do
204 munin_plugin "ipmi_fans" do
208 munin_plugin "ipmi_temp" do
212 munin_plugin "ipmi_power" do
216 munin_plugin_conf "ipmi" do
220 munin_plugin "ipmi_fans" do
224 munin_plugin "ipmi_temp" do
228 munin_plugin "ipmi_power" do
233 munin_plugin "irqstats"
235 munin_plugin "memory"
236 munin_plugin "netstat"
238 if node[:kernel][:modules].include?("nfsv3")
239 munin_plugin "nfs_client"
241 munin_plugin "nfs_client" do
246 if node[:kernel][:modules].include?("nfsv4")
247 munin_plugin "nfs4_client"
249 munin_plugin "nfs4_client" do
254 if node[:kernel][:modules].include?("nfsd")
258 munin_plugin "nfsd" do
262 munin_plugin "nfsd4" do
267 munin_plugin "open_files"
268 munin_plugin "open_inodes"
270 munin_plugin "postfix_mailqueue" do
274 munin_plugin "postfix_mailvolume" do
278 munin_plugin "processes"
279 munin_plugin "proc_pri"
285 Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
286 hwmon = "#{hwmon}/device" unless File.exist?("#{hwmon}/name")
288 sensors_fan = true unless Dir.glob("#{hwmon}/fan*_input").empty?
289 sensors_temp = true unless Dir.glob("#{hwmon}/temp*_input").empty?
290 sensors_volt = true unless Dir.glob("#{hwmon}/in*_input").empty?
293 package "lm-sensors" if sensors_fan || sensors_temp || sensors_volt
296 munin_plugin "sensors_fan" do
300 munin_plugin "sensors_fan" do
306 munin_plugin "sensors_temp" do
310 munin_plugin "sensors_temp" do
316 munin_plugin "sensors_volt" do
318 conf "sensors_volt.erb"
321 munin_plugin "sensors_volt" do
328 munin_plugin "threads"
329 munin_plugin "uptime"
331 munin_plugin "vmstat"