2 # Cookbook Name:: postgresql
3 # Definition:: postgresql_munin
5 # Copyright 2012, 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 define :postgresql_munin, :action => :create do
21 cluster = params[:cluster]
22 suffix = cluster.tr("/", ":")
23 database = params[:database]
25 if node[:postgresql][:clusters] and node[:postgresql][:clusters][cluster]
26 munin_plugin "postgres_cache_#{database}:#{suffix}" do
27 action params[:action]
28 target "postgres_cache_"
30 conf_cookbook "postgresql"
31 conf_variables :port => node[:postgresql][:clusters][cluster][:port]
34 munin_plugin "postgres_connections_#{database}:#{suffix}" do
35 action params[:action]
36 target "postgres_connections_"
38 conf_cookbook "postgresql"
39 conf_variables :port => node[:postgresql][:clusters][cluster][:port]
42 munin_plugin "postgres_locks_#{database}:#{suffix}" do
43 action params[:action]
44 target "postgres_locks_"
46 conf_cookbook "postgresql"
47 conf_variables :port => node[:postgresql][:clusters][cluster][:port]
50 munin_plugin "postgres_querylength_#{database}:#{suffix}" do
51 action params[:action]
52 target "postgres_querylength_"
54 conf_cookbook "postgresql"
55 conf_variables :port => node[:postgresql][:clusters][cluster][:port]
58 munin_plugin "postgres_scans_#{database}:#{suffix}" do
59 action params[:action]
60 target "postgres_scans_"
62 conf_cookbook "postgresql"
63 conf_variables :port => node[:postgresql][:clusters][cluster][:port]
66 munin_plugin "postgres_size_#{database}:#{suffix}" do
67 action params[:action]
68 target "postgres_size_"
70 conf_cookbook "postgresql"
71 conf_variables :port => node[:postgresql][:clusters][cluster][:port]
74 munin_plugin "postgres_transactions_#{database}:#{suffix}" do
75 action params[:action]
76 target "postgres_transactions_"
78 conf_cookbook "postgresql"
79 conf_variables :port => node[:postgresql][:clusters][cluster][:port]
82 munin_plugin "postgres_tuples_#{database}:#{suffix}" do
83 action params[:action]
84 target "postgres_tuples_"
86 conf_cookbook "postgresql"
87 conf_variables :port => node[:postgresql][:clusters][cluster][:port]
90 log "Postgres cluster #{cluster} not found" do