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 if node[:kernel][:modules].include?("nfsv3")
209 munin_plugin "nfs_client"
211 munin_plugin "nfs_client" do
216 if node[:kernel][:modules].include?("nfsv4")
217 munin_plugin "nfs4_client"
219 munin_plugin "nfs4_client" do
224 if node[:kernel][:modules].include?("nfsd")
228 munin_plugin "nfsd" do
232 munin_plugin "nfsd4" do
237 munin_plugin "open_files"
238 munin_plugin "open_inodes"
240 munin_plugin "postfix_mailqueue" do
244 munin_plugin "postfix_mailvolume" do
248 munin_plugin "processes"
249 munin_plugin "proc_pri"
255 Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
256 hwmon = "#{hwmon}/device" unless File.exist?("#{hwmon}/name")
258 sensors_fan = true unless Dir.glob("#{hwmon}/fan*_input").empty?
259 sensors_temp = true unless Dir.glob("#{hwmon}/temp*_input").empty?
260 sensors_volt = true unless Dir.glob("#{hwmon}/in*_input").empty?
263 package "lm-sensors" if sensors_fan || sensors_temp || sensors_volt
266 munin_plugin "sensors_fan" do
270 munin_plugin "sensors_fan" do
276 munin_plugin "sensors_temp" do
280 munin_plugin "sensors_temp" do
286 munin_plugin "sensors_volt" do
288 conf "sensors_volt.erb"
291 munin_plugin "sensors_volt" do
298 munin_plugin "threads"
299 munin_plugin "uptime"
301 munin_plugin "vmstat"