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.
 
  20 include_recipe "munin"
 
  22 remote_directory "/usr/local/share/munin/plugins" do
 
  33 remote_directory "/etc/munin/plugin-conf.d" do
 
  34   source "plugin-conf.d"
 
  42   notifies :restart, "service[munin-node]"
 
  45 if Dir.glob("/proc/acpi/thermal_zone/*/temperature").empty?
 
  46   munin_plugin "acpi" do
 
  56 if File.exist?("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state")
 
  57   munin_plugin "cpuspeed"
 
  59   munin_plugin "cpuspeed" do
 
  64 munin_plugin_conf "df" do
 
  69 munin_plugin "df_inode"
 
  71 munin_plugin_conf "diskstats" do
 
  72   template "diskstats.erb"
 
  75 munin_plugin "diskstats"
 
  76 munin_plugin "entropy"
 
  79 if node[:kernel][:modules].include?("nf_conntrack")
 
  82   munin_plugin "fw_conntrack"
 
  83   munin_plugin "fw_forwarded_local"
 
  85   munin_plugin "fw_conntrack" do
 
  89   munin_plugin "fw_forwarded_local" do
 
  94 if File.read("/proc/sys/net/ipv4/ip_forward").chomp == "1"
 
  95   munin_plugin "fw_packets"
 
  97   munin_plugin "fw_packets" do
 
 102 if File.exist?("/sbin/hpasmcli")
 
 103   munin_plugin "hpasmcli2_temp" do
 
 107   munin_plugin "hpasmcli2_fans" do
 
 111   munin_plugin "hpasmcli2_temp" do
 
 115   munin_plugin "hpasmcli2_fans" do
 
 120 munin_plugin "hpasmcli_temp" do
 
 124 munin_plugin "hpasmcli_fans" do
 
 128 munin_plugin "http_loadtime" do
 
 132 node[:network][:interfaces].each do |ifname, ifattr|
 
 133   if ifattr[:flags]&.include?("UP") && !ifattr[:flags].include?("LOOPBACK")
 
 134     if node[:hardware] &&
 
 135        node[:hardware][:network] &&
 
 136        node[:hardware][:network][ifname][:device] =~ /^virtio/
 
 137       munin_plugin_conf "if_#{ifname}" do
 
 139         variables :ifname => ifname
 
 142       munin_plugin_conf "if_#{ifname}" do
 
 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
 
 165 munin_plugin "interrupts"
 
 166 munin_plugin "iostat"
 
 167 munin_plugin "iostat_ios"
 
 169 if Dir.glob("/dev/ipmi*").empty?
 
 170   munin_plugin_conf "ipmi" do
 
 174   munin_plugin "ipmi_fans" do
 
 178   munin_plugin "ipmi_temp" do
 
 182   munin_plugin "ipmi_power" do
 
 186   munin_plugin_conf "ipmi" do
 
 190   munin_plugin "ipmi_fans" do
 
 194   munin_plugin "ipmi_temp" do
 
 198   munin_plugin "ipmi_power" do
 
 203 munin_plugin "irqstats"
 
 205 munin_plugin "memory"
 
 206 munin_plugin "netstat"
 
 208 munin_plugin "nfs_client" do
 
 212 munin_plugin "nfs4_client" do
 
 216 munin_plugin "nfsd" do
 
 220 munin_plugin "nfsd4" do
 
 224 munin_plugin "open_files"
 
 225 munin_plugin "open_inodes"
 
 227 munin_plugin "postfix_mailqueue" do
 
 231 munin_plugin "postfix_mailvolume" do
 
 235 munin_plugin "processes"
 
 236 munin_plugin "proc_pri"
 
 242 Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
 
 243   hwmon = "#{hwmon}/device" unless File.exist?("#{hwmon}/name")
 
 245   sensors_fan = true unless Dir.glob("#{hwmon}/fan*_input").empty?
 
 246   sensors_temp = true unless Dir.glob("#{hwmon}/temp*_input").empty?
 
 247   sensors_volt = true unless Dir.glob("#{hwmon}/in*_input").empty?
 
 250 package "lm-sensors" if sensors_fan || sensors_temp || sensors_volt
 
 253   munin_plugin "sensors_fan" do
 
 257   munin_plugin "sensors_fan" do
 
 263   munin_plugin "sensors_temp" do
 
 267   munin_plugin "sensors_temp" do
 
 273   munin_plugin "sensors_volt" do
 
 275     conf "sensors_volt.erb"
 
 278   munin_plugin "sensors_volt" do
 
 285 munin_plugin "threads"
 
 286 munin_plugin "uptime"
 
 288 munin_plugin "vmstat"