]> git.openstreetmap.org Git - chef.git/blob - cookbooks/munin/recipes/plugins.rb
Take memcached stats from the frontends
[chef.git] / cookbooks / munin / recipes / plugins.rb
1 #
2 # Cookbook:: munin
3 # Recipe:: default
4 #
5 # Copyright:: 2010, OpenStreetMap Foundation
6 #
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
10 #
11 #     https://www.apache.org/licenses/LICENSE-2.0
12 #
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.
18 #
19
20 include_recipe "munin"
21
22 remote_directory "/usr/local/share/munin/plugins" do
23   source "plugins"
24   owner "root"
25   group "root"
26   mode "755"
27   files_owner "root"
28   files_group "root"
29   files_mode "755"
30   purge true
31 end
32
33 remote_directory "/etc/munin/plugin-conf.d" do
34   source "plugin-conf.d"
35   owner "root"
36   group "munin"
37   mode "750"
38   files_owner "root"
39   files_group "root"
40   files_mode "644"
41   purge false
42   notifies :restart, "service[munin-node]"
43 end
44
45 if Dir.glob("/proc/acpi/thermal_zone/*/temperature").empty?
46   munin_plugin "acpi" do
47     action :delete
48   end
49 else
50   munin_plugin "acpi"
51 end
52
53 # apcpdu_
54 munin_plugin "cpu"
55
56 if File.exist?("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state")
57   munin_plugin "cpuspeed"
58 else
59   munin_plugin "cpuspeed" do
60     action :delete
61   end
62 end
63
64 munin_plugin_conf "df" do
65   template "df.erb"
66 end
67
68 munin_plugin "df"
69 munin_plugin "df_inode"
70
71 munin_plugin_conf "diskstats" do
72   template "diskstats.erb"
73 end
74
75 munin_plugin "diskstats"
76 munin_plugin "entropy"
77 munin_plugin "forks"
78
79 if node[:kernel][:modules].include?("nf_conntrack")
80   package "conntrack"
81
82   munin_plugin "fw_conntrack"
83   munin_plugin "fw_forwarded_local"
84 else
85   munin_plugin "fw_conntrack" do
86     action :delete
87   end
88
89   munin_plugin "fw_forwarded_local" do
90     action :delete
91   end
92 end
93
94 if File.read("/proc/sys/net/ipv4/ip_forward").chomp == "1"
95   munin_plugin "fw_packets"
96 else
97   munin_plugin "fw_packets" do
98     action :delete
99   end
100 end
101
102 if File.exist?("/sbin/hpasmcli")
103   munin_plugin "hpasmcli2_temp" do
104     target "hpasmcli2_"
105   end
106
107   munin_plugin "hpasmcli2_fans" do
108     target "hpasmcli2_"
109   end
110 else
111   munin_plugin "hpasmcli2_temp" do
112     action :delete
113   end
114
115   munin_plugin "hpasmcli2_fans" do
116     action :delete
117   end
118 end
119
120 munin_plugin "hpasmcli_temp" do
121   action :delete
122 end
123
124 munin_plugin "hpasmcli_fans" do
125   action :delete
126 end
127
128 munin_plugin "http_loadtime" do
129   action :delete
130 end
131
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
138         template "if.erb"
139         variables :ifname => ifname
140       end
141     else
142       munin_plugin_conf "if_#{ifname}" do
143         action :delete
144       end
145     end
146
147     munin_plugin "if_err_#{ifname}" do
148       target "if_err_"
149     end
150
151     munin_plugin "if_#{ifname}" do
152       target "if_"
153     end
154   else
155     munin_plugin "if_err_#{ifname}" do
156       action :delete
157     end
158
159     munin_plugin "if_#{ifname}" do
160       action :delete
161     end
162   end
163 end
164
165 munin_plugin "interrupts"
166 munin_plugin "iostat"
167 munin_plugin "iostat_ios"
168
169 if Dir.glob("/dev/ipmi*").empty?
170   munin_plugin_conf "ipmi" do
171     action :delete
172   end
173
174   munin_plugin "ipmi_fans" do
175     action :delete
176   end
177
178   munin_plugin "ipmi_temp" do
179     action :delete
180   end
181
182   munin_plugin "ipmi_power" do
183     action :delete
184   end
185 else
186   munin_plugin_conf "ipmi" do
187     template "ipmi.erb"
188   end
189
190   munin_plugin "ipmi_fans" do
191     target "ipmi_"
192   end
193
194   munin_plugin "ipmi_temp" do
195     target "ipmi_"
196   end
197
198   munin_plugin "ipmi_power" do
199     target "ipmi_"
200   end
201 end
202
203 munin_plugin "irqstats"
204 munin_plugin "load"
205 munin_plugin "memory"
206 munin_plugin "netstat"
207
208 if node[:kernel][:modules].include?("nfsv3")
209   munin_plugin "nfs_client"
210 else
211   munin_plugin "nfs_client" do
212     action :delete
213   end
214 end
215
216 if node[:kernel][:modules].include?("nfsv4")
217   munin_plugin "nfs4_client"
218 else
219   munin_plugin "nfs4_client" do
220     action :delete
221   end
222 end
223
224 if node[:kernel][:modules].include?("nfsd")
225   munin_plugin "nfsd"
226   munin_plugin "nfsd4"
227 else
228   munin_plugin "nfsd" do
229     action :delete
230   end
231
232   munin_plugin "nfsd4" do
233     action :delete
234   end
235 end
236
237 munin_plugin "open_files"
238 munin_plugin "open_inodes"
239
240 munin_plugin "postfix_mailqueue" do
241   action :delete
242 end
243
244 munin_plugin "postfix_mailvolume" do
245   action :delete
246 end
247
248 munin_plugin "processes"
249 munin_plugin "proc_pri"
250
251 sensors_fan = false
252 sensors_temp = false
253 sensors_volt = false
254
255 Dir.glob("/sys/class/hwmon/hwmon*").each do |hwmon|
256   hwmon = "#{hwmon}/device" unless File.exist?("#{hwmon}/name")
257
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?
261 end
262
263 package "lm-sensors" if sensors_fan || sensors_temp || sensors_volt
264
265 if sensors_fan
266   munin_plugin "sensors_fan" do
267     target "sensors_"
268   end
269 else
270   munin_plugin "sensors_fan" do
271     action :delete
272   end
273 end
274
275 if sensors_temp
276   munin_plugin "sensors_temp" do
277     target "sensors_"
278   end
279 else
280   munin_plugin "sensors_temp" do
281     action :delete
282   end
283 end
284
285 if sensors_volt
286   munin_plugin "sensors_volt" do
287     target "sensors_"
288     conf "sensors_volt.erb"
289   end
290 else
291   munin_plugin "sensors_volt" do
292     action :delete
293   end
294 end
295
296 munin_plugin "swap"
297 munin_plugin "tcp"
298 munin_plugin "threads"
299 munin_plugin "uptime"
300 munin_plugin "users"
301 munin_plugin "vmstat"