Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

initial commit of nrsysmond.rb

  • Loading branch information...
commit 8b43d52dad93f94a9bb8f604eff4af466a4e6093 1 parent 2446cc2
David Collom authored

Showing 1 changed file with 46 additions and 0 deletions. Show diff stats Hide diff stats

  1. +46 0 nrsysmond.rb
46 nrsysmond.rb
... ... @@ -0,0 +1,46 @@
  1 +set :newrelic_licencekey, 'NEWRELIC LICENCE KEY HERE'
  2 +
  3 +namespace :newrelic do
  4 + desc 'Installs the newrelic sysmond'
  5 + namespace :sysmond do
  6 + task :default do
  7 + unless remote_file_exists? '/etc/newrelic/nrsysmond.cfg'
  8 + debian if remote_file_exists? '/etc/debian_version'
  9 + redhat if remote_file_exists? '/etc/redhat-release'
  10 + end
  11 + end
  12 + task :debian do
  13 + run 'if [! -e /etc/apt/sources.list.d/newrelic.list ]; then echo "deb http://apt.newrelic.com/debian/ newrelic non-free" > /etc/apt/sources.list.d/newrelic.list; fi'
  14 + run 'wget -O- http://download.newrelic.com/548C16BF.gpg | sudo apt-key add -'
  15 + sudo 'apt-get update && apt-get install newrelic-sysmond'
  16 + configure
  17 + end
  18 + task :redhat do
  19 + sudo "rpm -Uvh http://yum.newrelic.com/pub/newrelic/el5/$(uname -m)/newrelic-repo-5-3.noarch.rpm || true"
  20 + sudo "yum install -y newrelic-sysmond"
  21 + configure
  22 + end
  23 + desc 'configure the newrelic-sysmond service with the :newrelic_licencekey'
  24 + task :configure do
  25 + sudo "/usr/sbin/nrsysmond-config --set license_key=#{newrelic_licencekey}"
  26 + restart
  27 + end
  28 +
  29 + %W{stop start restart}.each do |com|
  30 + desc "#{com}'s the newrelic-sysmond service"
  31 + task com.to_sym do
  32 + sudo "/etc/init.d/newrelic-sysmond #{com}"
  33 + end
  34 + end
  35 + end
  36 +end
  37 +
  38 +def remote_file_exists?(path)
  39 + results = []
  40 +
  41 + invoke_command("if [ -e '#{path}' ]; then echo -n 'true'; fi") do |ch, stream, out|
  42 + results << (out == 'true')
  43 + end
  44 +
  45 + results == [true]
  46 +end

0 comments on commit 8b43d52

Please sign in to comment.
Something went wrong with that request. Please try again.