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 node[:network][:interfaces].each do |ifname, ifattr|
121 if ifattr[:flags]&.include?("UP") && !ifattr[:flags].include?("LOOPBACK")
122 if node[:hardware] &&
123 node[:hardware][:network] &&
124 node[:hardware][:network][ifname][:device] =~ /^virtio/
125 munin_plugin_conf "if_#{ifname}" do
127 variables :ifname => ifname
130 munin_plugin_conf "if_#{ifname}" do
135 munin_plugin "if_err_#{ifname}" do
139 munin_plugin "if_#{ifname}" do
143 munin_plugin "if_err_#{ifname}" do
147 munin_plugin "if_#{ifname}" do
153 munin_plugin "interrupts"
154 munin_plugin "iostat"
155 munin_plugin "iostat_ios"
157 if Dir.glob("/dev/ipmi*").empty?
158 munin_plugin_conf "ipmi" do
162 munin_plugin "ipmi_fans" do
166 munin_plugin "ipmi_temp" do
170 munin_plugin "ipmi_power" do
174 munin_plugin_conf "ipmi" do
178 munin_plugin "ipmi_fans" do
182 munin_plugin "ipmi_temp" do
186 munin_plugin "ipmi_power" do
191 munin_plugin "irqstats"
193 munin_plugin "memory"
194 munin_plugin "netstat"
196 munin_plugin "nfs_client" do
200 munin_plugin "nfs4_client" do
204 munin_plugin "nfsd" do
208 munin_plugin "nfsd4" do
212 munin_plugin "open_files"
213 munin_plugin "open_inodes"
215 munin_plugin "postfix_mailqueue" do
219 munin_plugin "postfix_mailvolume" do
223 munin_plugin "processes"
224 munin_plugin "proc_pri"
230 Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
231 hwmon = "#{hwmon}/device" unless File.exist?("#{hwmon}/name")
233 sensors_fan = true unless Dir.glob("#{hwmon}/fan*_input").empty?
234 sensors_temp = true unless Dir.glob("#{hwmon}/temp*_input").empty?
235 sensors_volt = true unless Dir.glob("#{hwmon}/in*_input").empty?
238 package "lm-sensors" if sensors_fan || sensors_temp || sensors_volt
241 munin_plugin "sensors_fan" do
245 munin_plugin "sensors_fan" do
251 munin_plugin "sensors_temp" do
255 munin_plugin "sensors_temp" do
261 munin_plugin "sensors_volt" do
263 conf "sensors_volt.erb"
266 munin_plugin "sensors_volt" do
273 munin_plugin "threads"
274 munin_plugin "uptime"
276 munin_plugin "vmstat"