Permalink
Browse files

remove collectd and graphite

  • Loading branch information...
1 parent 9832462 commit f2313132dfdf83ed36ddfefb592628dd4f533a97 @karlbright karlbright committed Oct 19, 2012
@@ -1,48 +0,0 @@
-
-namespace :rubber do
-
- namespace :collectd do
-
- rubber.allow_optional_tasks(self)
-
- after "rubber:bootstrap", "rubber:collectd:bootstrap"
- after "deploy:restart", "rubber:collectd:restart_rubber_plugin"
-
-
- task :bootstrap, :roles => :collectd do
- exists = capture("echo $(grep Rubber /etc/collectd/collectd.conf 2> /dev/null)")
- if exists.strip.size == 0
- rubber.update_code_for_bootstrap
-
- rubber.run_config(:file => "role/collectd", :force => true, :deploy_path => release_path)
-
- restart
- end
- end
-
- desc "Start collectd system monitoring"
- task :start, :roles => :collectd do
- rsudo "service collectd start"
- end
-
- desc "Stop collectd system monitoring"
- task :stop, :roles => :collectd do
- rsudo "service collectd stop || true"
- end
-
- desc "Restart collectd system monitoring"
- task :restart, :roles => :collectd do
- stop
- start
- end
-
- desc "Restart collectd rubber plugin"
- task :restart_rubber_plugin, :roles => :collectd do
- # Need to kill rubber collectd runner script to force collectd to restart
- # it after deploy so that the runner script gets the new paths
- rsudo "pkill -fn #{rubber_env.rubber_collectd_runner.sub(/./, '[\0]')} ; exit 0"
- end
-
- end
-
-end
@@ -1,255 +0,0 @@
-
-namespace :rubber do
-
- namespace :graphite do
-
- rubber.allow_optional_tasks(self)
-
- after "rubber:install_packages", "rubber:graphite:install_collectd_graphite_plugin"
-
- task :install_collectd_graphite_plugin, :roles => :collectd do
- rubber.sudo_script 'install_collectd', <<-ENDSCRIPT
- if [[ ! -f "/usr/local/share/perl/5.10.1/Collectd/Plugins/Graphite.pm" ]]; then
- wget --no-check-certificate -qNO /tmp/joemiller-collectd-graphite.tar.gz https://github.com/joemiller/collectd-graphite/tarball/#{rubber_env.collectd_graphite_plugin_version}
- tar -C /tmp -zxf /tmp/joemiller-collectd-graphite.tar.gz
- cd /tmp/joemiller-collectd-graphite-*
- perl Makefile.PL
- make
- make test
- make install
- fi
- ENDSCRIPT
- end
-
- # graphite collectd plugin needs newer collectd (>= 4.9)
- before "rubber:install_packages", "rubber:graphite:setup_apt_backport_of_collectd"
-
- task :setup_apt_backport_of_collectd do
- sources = <<-EOF
- deb http://gb.archive.ubuntu.com/ubuntu/ maverick main universe
- deb-src http://gb.archive.ubuntu.com/ubuntu/ maverick main universe
- EOF
- sources.gsub!(/^[ \t]*/, '')
-
- prefs = <<-EOF
- Package: *
- Pin: release a=maverick
- Pin-Priority: 400
-
- Package: libxml2
- Pin: release a=maverick
- Pin-Priority: 900
-
- Package: libxml2-dev
- Pin: release a=maverick
- Pin-Priority: 900
-
- Package: collectd-core
- Pin: release a=maverick
- Pin-Priority: 900
-
- Package: collectd-utils
- Pin: release a=maverick
- Pin-Priority: 900
-
- Package: collectd
- Pin: release a=maverick
- Pin-Priority: 900
- EOF
- prefs.gsub!(/^[ \t]*/, '')
-
- rubber.sudo_script 'setup_apt_backport_of_collectd', <<-ENDSCRIPT
- release=`lsb_release -sr`
- needs_backport=`echo "$release <= 10.04" | bc`
- if [[ $needs_backport == 1 && ! -f /etc/apt/preferences.d/rubber-collectd ]]; then
- echo -e #{sources.inspect} > /etc/apt/sources.list.d/rubber-collectd.list
- echo -e #{prefs.inspect} > /etc/apt/preferences.d/rubber-collectd
- fi
- ENDSCRIPT
- end
-
- task :install_graphite_from_repo, :roles => [:graphite_server, :graphite_web] do
- rubber.sudo_script 'install_graphite_from_repo', <<-ENDSCRIPT
- if [[ ! -d "/opt/graphite" ]]; then
- mkdir -p /tmp/graphite_install
- cd /tmp/graphite_install
- bzr branch lp:graphite -r #{rubber_env.graphite_repo_version}
-
- pushd graphite/whisper
- python setup.py install
- popd
-
- pushd graphite/carbon
- python setup.py install
- popd
-
- pushd graphite
- python setup.py install
- popd
- fi
- ENDSCRIPT
- end
-
- desc <<-DESC
- Cleans out old whisper storage files for non-existant instances so they don't show in webui
- DESC
- task :clean_storage, :roles => [:graphite_server] do
- active_instances = rubber_instances.collect {|ic| ic.name }.sort
- stored_instances = capture("ls /opt/graphite/storage/whisper/servers/").split.sort
- cleaning_instances = stored_instances - active_instances
-
- if cleaning_instances.size > 0
- logger.info "Cleaning dead instances from graphite storage: #{cleaning_instances.join(',')}"
-
- do_clean = true
- if (cleaning_instances.size.to_f / stored_instances.size) > 0.01
- value = Capistrano::CLI.ui.ask("Graphite storage files to be cleaned exceeds threshold, proceed? [y/N]?: ")
- do_clean = (value =~ /^y/)
- end
-
- if do_clean
- rsudo "rm -rf /opt/graphite/storage/whisper/servers/{#{cleaning_instances.join(',')}}"
- end
-
- end
- end
-
- namespace :server do
-
- rubber.allow_optional_tasks(self)
-
- if Rubber::Configuration.rubber_env.graphite_repo_version
- after "rubber:install_packages", "rubber:graphite:install_graphite_from_repo"
- else
- after "rubber:install_packages", "rubber:graphite:server:install"
- end
-
- after "rubber:bootstrap", "rubber:graphite:server:bootstrap"
-
- desc <<-DESC
- Installs graphite server components
- DESC
- task :install, :roles => :graphite_server do
- rubber.sudo_script 'install_graphite_server', <<-ENDSCRIPT
- if [[ ! -f "/opt/graphite/bin/carbon-cache.py" ]]; then
- wget -qNP /tmp #{rubber_env.graphite_whisper_package_url}
- tar -C /tmp -zxf /tmp/#{rubber_env.graphite_whisper_package_url.gsub(/.*\//, '')}
- cd /tmp/#{rubber_env.graphite_whisper_package_url.gsub(/.*\//, '').gsub('.tar.gz', '')}
- python setup.py install
-
- wget -qNP /tmp #{rubber_env.graphite_carbon_package_url}
- tar -C /tmp -zxf /tmp/#{rubber_env.graphite_carbon_package_url.gsub(/.*\//, '')}
- cd /tmp/#{rubber_env.graphite_carbon_package_url.gsub(/.*\//, '').gsub('.tar.gz', '')}
- python setup.py install
-
- fi
- ENDSCRIPT
- end
-
- task :bootstrap, :roles => :graphite_server do
- exists = capture("echo $(ls /opt/graphite/storage/whisper/ 2> /dev/null)")
- if exists.strip.size == 0
- rubber.update_code_for_bootstrap
-
- rubber.run_config(:file => "role/graphite_server", :force => true, :deploy_path => release_path)
-
- restart
- end
- end
-
- desc "Start graphite system monitoring"
- task :start, :roles => :graphite_server do
- rsudo "service graphite-server start"
- end
-
- desc "Stop graphite system monitoring"
- task :stop, :roles => :graphite_server do
- rsudo "service graphite-server stop || true"
- end
-
- desc "Restart graphite system monitoring"
- task :restart, :roles => :graphite_server do
- stop
- start
- end
- end
-
- namespace :web do
-
- rubber.allow_optional_tasks(self)
-
- if Rubber::Configuration.rubber_env.graphite_repo_version
- after "rubber:graphite:server:install", "rubber:graphite:install_graphite_from_repo"
- else
- after "rubber:graphite:server:install", "rubber:graphite:web:install"
- end
-
- after "rubber:graphite:server:bootstrap", "rubber:graphite:web:bootstrap"
-
- desc <<-DESC
- Installs graphite web components
- DESC
- task :install, :roles => :graphite_web do
- rubber.sudo_script 'install_graphite_web', <<-ENDSCRIPT
- if [[ ! -d "/opt/graphite/webapp" ]]; then
- wget -qNP /tmp #{rubber_env.graphite_web_package_url}
- tar -C /tmp -zxf /tmp/#{rubber_env.graphite_web_package_url.gsub(/.*\//, '')}
- cd /tmp/#{rubber_env.graphite_web_package_url.gsub(/.*\//, '').gsub('.tar.gz', '')}
- # python check-dependencies.py
- python setup.py install
- fi
- ENDSCRIPT
- end
-
- task :bootstrap, :roles => :graphite_web do
- exists = capture("echo $(ls /opt/graphite/storage/graphite.db 2> /dev/null)")
- if exists.strip.size == 0
- rubber.update_code_for_bootstrap
-
- rubber.run_config(:file => "role/graphite_web", :force => true, :deploy_path => release_path)
-
- # django email validation barfs on localhost, but for full_host to work
- # in admin_email, we need a env with host defined
- web_instance = rubber_instances.for_role("graphite_web").first
- env = rubber_cfg.environment.bind("graphite_web", web_instance.name)
- email = env.admin_email
-
- rubber.sudo_script 'bootstrap_graphite_web', <<-ENDSCRIPT
- cd /opt/graphite/webapp/graphite
- python manage.py syncdb --noinput
- python manage.py createsuperuser --username admin --email #{email} --noinput
- python manage.py shell <<EOF
-from django.contrib.auth.models import User
-u = User.objects.get(username__exact='admin')
-u.set_password('admin1')
-u.save()
-EOF
- mkdir -p /opt/graphite/storage/log/webapp/
- chown -R www-data:www-data /opt/graphite/storage/
- ENDSCRIPT
-
- restart
- end
- end
-
- desc "Start graphite system monitoring"
- task :start, :roles => :graphite_web do
- rsudo "service apache2 start"
- end
-
- desc "Stop graphite system monitoring"
- task :stop, :roles => :graphite_web do
- rsudo "service apache2 stop || true"
- end
-
- desc "Restart graphite system monitoring"
- task :restart, :roles => :graphite_web do
- stop
- start
- end
-
- end
-
- end
-
-end
@@ -1,21 +0,0 @@
-<%
- @path = '/etc/collectd/conf.d/collectd-ping.conf'
-
- ping_hosts = []
- if rubber_instances[rubber_env.host].role_names.include?('graphite_server')
- # monitor all servers from graphite_server
- ping_hosts = rubber_instances.collect {|ic| ic.full_name }.select {|h| h != rubber_env.full_host }
- elsif rubber_instances[rubber_env.host].role_names.include?('web_tools')
- # monitor just graphite_server from tools
- ping_hosts = Array((rubber_instances.for_role('graphite_server').first.full_name rescue nil))
- end
-
- @skip = (ping_hosts.size == 0)
-%>
-
-LoadPlugin ping
-<Plugin "ping">
- <% ping_hosts.each do |h| %>
- Host "<%= h %>"
- <% end %>
-</Plugin>
@@ -1,69 +0,0 @@
-<%
- rubber_scripts = `#{Rubber.root}/#{rubber_env.rubber_collectd_runner} config`.split("\n") rescue []
-
- @path = '/etc/collectd/collectd.conf'
- @post = "mkdir -p /etc/collectd/conf.d/ /etc/collectd/thresholds.d/ /etc/collectd/filters.d/ /etc/collectd/plugins/ "
-%>
-# Config file for collectd(1). Generated by Rubber
-#
-# Some plugins need additional configuration and are disabled by default.
-# Please read collectd.conf(5) for details.
-#
-# You should also read /usr/share/doc/collectd-core/README.Debian.plugins
-# before enabling any more plugins.
-
-Hostname "<%= rubber_env.host %>"
-#BaseDir "/var/lib/collectd"
-#PluginDir "/usr/lib/collectd"
-TypesDB "/usr/share/collectd/types.db" "/etc/collectd/types.db"
-Interval 60
-#Timeout 2
-#ReadThreads 5
-
-LoadPlugin syslog
-
-<Plugin syslog>
- LogLevel info
-</Plugin>
-
-LoadPlugin cpu
-LoadPlugin df
-LoadPlugin disk
-LoadPlugin exec
-LoadPlugin entropy
-LoadPlugin interface
-LoadPlugin irq
-LoadPlugin load
-LoadPlugin memory
-LoadPlugin processes
-#LoadPlugin python
-LoadPlugin rrdtool
-<% if `swapon -s | wc -l`.to_i > 1 %>
-LoadPlugin swap
-<% end %>
-#LoadPlugin table
-#LoadPlugin tail
-#LoadPlugin tcpconns
-LoadPlugin users
-
-LoadPlugin notify_email
-
-<Plugin "notify_email">
- From "collectd@<%= rubber_env.full_host %>"
- Recipient "<%= rubber_env.admin_email %>"
- Subject "Collectd notify: %s@%s"
-</Plugin>
-
-<%
- if rubber_scripts.size > 0
-%>
-
-<Plugin exec>
- Exec <%= rubber_env.app_user %> "/bin/bash" "-l" "-c" "cd <%= "/mnt/#{rubber_env.app_name}-#{Rubber.env}/current" %> && bundle exec <%= rubber_env.rubber_collectd_runner %>"
-</Plugin>
-
-<% end %>
-
-Include "/etc/collectd/conf.d/*.conf"
-Include "/etc/collectd/thresholds.d/*.conf"
-Include "/etc/collectd/filters.d/*.conf"
Oops, something went wrong.

0 comments on commit f231313

Please sign in to comment.