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.
 
  22 service "munin-node" do
 
  23   if node[:lsb][:release].to_f >= 15.10
 
  24     provider Chef::Provider::Service::Systemd
 
  25   elsif 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") # ~FC010
 
  34 servers.each do |server|
 
  35   server.interfaces(:role => :external) do |interface|
 
  36     firewall_rule "accept-munin-#{server}" do
 
  38       family interface[:family]
 
  39       source "#{interface[:zone]}:#{interface[:address]}"
 
  48 template "/etc/munin/munin-node.conf" do
 
  49   source "munin-node.conf.erb"
 
  53   variables :servers => servers
 
  54   notifies :restart, "service[munin-node]"
 
  57 remote_directory "/usr/local/share/munin/plugins" do
 
  68 remote_directory "/etc/munin/plugin-conf.d" do
 
  69   source "plugin-conf.d"
 
  77   notifies :restart, "service[munin-node]"
 
  80 if Dir.glob("/proc/acpi/thermal_zone/*/temperature").empty?
 
  81   munin_plugin "acpi" do
 
  91 if File.exist?("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state")
 
  92   munin_plugin "cpuspeed"
 
  94   munin_plugin "cpuspeed" do
 
  99 munin_plugin_conf "df" do
 
 104 munin_plugin "df_inode"
 
 106 munin_plugin "diskstats"
 
 107 munin_plugin "entropy"
 
 110 if node[:kernel][:modules].include?("nf_conntrack")
 
 113   munin_plugin "fw_conntrack"
 
 114   munin_plugin "fw_forwarded_local"
 
 116   munin_plugin "fw_conntrack" do
 
 120   munin_plugin "fw_forwarded_local" do
 
 125 if File.read("/proc/sys/net/ipv4/ip_forward").chomp == "1"
 
 126   munin_plugin "fw_packets"
 
 128   munin_plugin "fw_packets" do
 
 133 if File.exist?("/sbin/hpasmcli")
 
 134   munin_plugin "hpasmcli2_temp" do
 
 138   munin_plugin "hpasmcli2_fans" do
 
 142   munin_plugin "hpasmcli2_temp" do
 
 146   munin_plugin "hpasmcli2_fans" do
 
 151 munin_plugin "hpasmcli_temp" do # ~FC005
 
 155 munin_plugin "hpasmcli_fans" do
 
 159 munin_plugin "http_loadtime" do
 
 163 node[:network][:interfaces].each do |ifname, ifattr|
 
 164   if ifattr[:encapsulation] == "Ethernet" && ifattr[:state] == "up"
 
 165     munin_plugin "if_err_#{ifname}" do
 
 169     munin_plugin "if_#{ifname}" do
 
 173     munin_plugin "if_err_#{ifname}" do
 
 177     munin_plugin "if_#{ifname}" do
 
 183 munin_plugin "interrupts"
 
 184 munin_plugin "iostat"
 
 185 munin_plugin "iostat_ios"
 
 187 if Dir.glob("/dev/ipmi*").empty?
 
 188   munin_plugin_conf "ipmi" do
 
 192   munin_plugin "ipmi_fans" do
 
 196   munin_plugin "ipmi_temp" do
 
 200   munin_plugin "ipmi_power" do
 
 202     only_if { node[:lsb][:release].to_f >= 14.04 }
 
 205   munin_plugin_conf "ipmi" do
 
 209   munin_plugin "ipmi_fans" do
 
 213   munin_plugin "ipmi_temp" do
 
 217   munin_plugin "ipmi_power" do
 
 219     only_if { node[:lsb][:release].to_f >= 14.04 }
 
 223 munin_plugin "irqstats"
 
 225 munin_plugin "memory"
 
 226 munin_plugin "netstat"
 
 228 if node[:kernel][:modules].include?("nfsv3")
 
 229   munin_plugin "nfs_client"
 
 231   munin_plugin "nfs_client" do
 
 236 if node[:kernel][:modules].include?("nfsv4")
 
 237   munin_plugin "nfs4_client"
 
 239   munin_plugin "nfs4_client" do
 
 244 if node[:kernel][:modules].include?("nfsd")
 
 248   munin_plugin "nfsd" do
 
 252   munin_plugin "nfsd4" do
 
 257 munin_plugin "open_files"
 
 258 munin_plugin "open_inodes"
 
 260 munin_plugin "postfix_mailqueue" do
 
 264 munin_plugin "postfix_mailvolume" do
 
 268 munin_plugin "processes"
 
 269 munin_plugin "proc_pri"
 
 275 Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
 
 276   hwmon = "#{hwmon}/device" unless File.exist?("#{hwmon}/name")
 
 278   sensors_fan = true unless Dir.glob("#{hwmon}/fan*_input").empty?
 
 279   sensors_temp = true unless Dir.glob("#{hwmon}/temp*_input").empty?
 
 280   sensors_volt = true unless Dir.glob("#{hwmon}/in*_input").empty?
 
 283 if sensors_fan || sensors_temp || sensors_volt
 
 288   munin_plugin "sensors_fan" do
 
 292   munin_plugin "sensors_fan" do
 
 298   munin_plugin "sensors_temp" do
 
 302   munin_plugin "sensors_temp" do
 
 308   munin_plugin "sensors_volt" do
 
 310     conf "sensors_volt.erb"
 
 313   munin_plugin "sensors_volt" do
 
 320 munin_plugin "threads"
 
 321 munin_plugin "uptime"
 
 323 munin_plugin "vmstat"