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   if node[:lsb][:release].to_f >= 15.10
 
  26     provider Chef::Provider::Service::Systemd
 
  27   elsif node[:lsb][:release].to_f >= 14.04
 
  28     provider Chef::Provider::Service::Upstart
 
  30   action [:enable, :start]
 
  31   supports :status => true, :restart => true, :reload => true
 
  34 servers = search(:node, "recipes:munin\\:\\:server") # ~FC010
 
  36 servers.each do |server|
 
  37   server.interfaces(:role => :external) do |interface|
 
  38     firewall_rule "accept-munin-#{server}" do
 
  40       family interface[:family]
 
  41       source "#{interface[:zone]}:#{interface[:address]}"
 
  50 template "/etc/munin/munin-node.conf" do
 
  51   source "munin-node.conf.erb"
 
  55   variables :servers => servers
 
  56   notifies :restart, "service[munin-node]"
 
  59 remote_directory "/usr/local/share/munin/plugins" do
 
  70 remote_directory "/etc/munin/plugin-conf.d" do
 
  71   source "plugin-conf.d"
 
  79   notifies :restart, "service[munin-node]"
 
  82 if Dir.glob("/proc/acpi/thermal_zone/*/temperature").empty?
 
  83   munin_plugin "acpi" do
 
  93 if File.exist?("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state")
 
  94   munin_plugin "cpuspeed"
 
  96   munin_plugin "cpuspeed" do
 
 102 munin_plugin "df_inode"
 
 103 munin_plugin "diskstats"
 
 104 munin_plugin "entropy"
 
 107 if node[:kernel][:modules].include?("nf_conntrack")
 
 110   munin_plugin "fw_conntrack"
 
 111   munin_plugin "fw_forwarded_local"
 
 113   munin_plugin "fw_conntrack" do
 
 117   munin_plugin "fw_forwarded_local" do
 
 122 if File.read("/proc/sys/net/ipv4/ip_forward").chomp == "1"
 
 123   munin_plugin "fw_packets"
 
 125   munin_plugin "fw_packets" do
 
 130 if File.exist?("/sbin/hpasmcli")
 
 131   munin_plugin "hpasmcli2_temp" do
 
 135   munin_plugin "hpasmcli2_fans" do
 
 139   munin_plugin "hpasmcli2_temp" do
 
 143   munin_plugin "hpasmcli2_fans" do
 
 148 munin_plugin "hpasmcli_temp" do # ~FC005
 
 152 munin_plugin "hpasmcli_fans" do
 
 156 munin_plugin "http_loadtime" do
 
 160 node[:network][:interfaces].each do |ifname, ifattr|
 
 161   if ifattr[:encapsulation] == "Ethernet" && ifattr[:state] == "up"
 
 162     munin_plugin "if_err_#{ifname}" do
 
 166     munin_plugin "if_#{ifname}" do
 
 170     munin_plugin "if_err_#{ifname}" do
 
 174     munin_plugin "if_#{ifname}" do
 
 180 munin_plugin "interrupts"
 
 181 munin_plugin "iostat"
 
 182 munin_plugin "iostat_ios"
 
 184 if Dir.glob("/dev/ipmi*").empty?
 
 185   munin_plugin_conf "ipmi" do
 
 189   munin_plugin "ipmi_fans" do
 
 193   munin_plugin "ipmi_temp" do
 
 197   munin_plugin "ipmi_power" do
 
 199     only_if { node[:lsb][:release].to_f >= 14.04 }
 
 202   munin_plugin_conf "ipmi" do
 
 206   munin_plugin "ipmi_fans" do
 
 210   munin_plugin "ipmi_temp" do
 
 214   munin_plugin "ipmi_power" do
 
 216     only_if { node[:lsb][:release].to_f >= 14.04 }
 
 220 munin_plugin "irqstats"
 
 222 munin_plugin "memory"
 
 223 munin_plugin "netstat"
 
 225 if node[:kernel][:modules].include?("nfsv3")
 
 226   munin_plugin "nfs_client"
 
 228   munin_plugin "nfs_client" do
 
 233 if node[:kernel][:modules].include?("nfsv4")
 
 234   munin_plugin "nfs4_client"
 
 236   munin_plugin "nfs4_client" do
 
 241 if node[:kernel][:modules].include?("nfsd")
 
 245   munin_plugin "nfsd" do
 
 249   munin_plugin "nfsd4" do
 
 254 munin_plugin "open_files"
 
 255 munin_plugin "open_inodes"
 
 257 munin_plugin "postfix_mailqueue" do
 
 261 munin_plugin "postfix_mailvolume" do
 
 265 munin_plugin "processes"
 
 266 munin_plugin "proc_pri"
 
 272 Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
 
 273   hwmon = "#{hwmon}/device" unless File.exist?("#{hwmon}/name")
 
 275   sensors_fan = true unless Dir.glob("#{hwmon}/fan*_input").empty?
 
 276   sensors_temp = true unless Dir.glob("#{hwmon}/temp*_input").empty?
 
 277   sensors_volt = true unless Dir.glob("#{hwmon}/in*_input").empty?
 
 280 if sensors_fan || sensors_temp || sensors_volt
 
 285   munin_plugin "sensors_fan" do
 
 289   munin_plugin "sensors_fan" do
 
 295   munin_plugin "sensors_temp" do
 
 299   munin_plugin "sensors_temp" do
 
 305   munin_plugin "sensors_volt" do
 
 307     conf "sensors_volt.erb"
 
 310   munin_plugin "sensors_volt" do
 
 317 munin_plugin "threads"
 
 318 munin_plugin "uptime"
 
 320 munin_plugin "vmstat"