From 4f9874ebd69c4d4626345266df2b62a7a49df288 Mon Sep 17 00:00:00 2001 From: Kevin Menard Date: Fri, 3 Dec 2010 20:41:13 -0500 Subject: [PATCH] Set up munin for PostgreSQL. --- .../config/rubber/deploy-postgresql.rb | 21 +++++++++++++++++++ .../rubber/role/db/munin-postgresql.conf | 7 +++++++ 2 files changed, 28 insertions(+) create mode 100644 lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/munin-postgresql.conf diff --git a/lib/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb b/lib/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb index 5c76f0dca..80c1d286e 100644 --- a/lib/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb +++ b/lib/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb @@ -86,6 +86,27 @@ end + after "rubber:munin:custom_install", "rubber:postgresql:install_munin_plugins" + after "rubber:postgresql:install_munin_plugins", "rubber:munin:restart" + task :install_munin_plugins, :roles => [:postgresql_master, :postgresql_slave] do + regular_plugins = %w[bgwriter checkpoints connections_db users xlog] + parameterized_plugins = %w[cache connections locks querylength scans transactions tuples] + + commands = ['rm -f /etc/munin/plugins/postgres_*'] + + regular_plugins.each do |name| + commands << "ln -s /usr/share/munin/plugins/postgres_#{name} /etc/munin/plugins/postgres_#{name}" + end + + parameterized_plugins.each do |name| + commands << "ln -s /usr/share/munin/plugins/postgres_#{name}_ /etc/munin/plugins/postgres_#{name}_#{rubber_env.db_name}" + end + + rubber.sudo_script "install_postgresql_munin_plugins", <<-ENDSCRIPT + #{commands.join(';')} + ENDSCRIPT + end + # TODO: Make the setup/update happen just once per host def common_bootstrap(role) # postgresql package install starts postgresql, so stop it diff --git a/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/munin-postgresql.conf b/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/munin-postgresql.conf new file mode 100644 index 000000000..1623db735 --- /dev/null +++ b/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/munin-postgresql.conf @@ -0,0 +1,7 @@ +<% + @path = '/etc/munin/plugin-conf.d/postgresql' +%> + +[postgres_*] + user postgres + env.PGUSER postgres