Skip to content

Commit

Permalink
Additional tweak(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
djoos committed Jan 25, 2014
1 parent 2bda97d commit 0f0576a
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 48 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Description
===========

This cookbook provides an easy way to install various New Relic agent and the New Relic server monitor.
This cookbook provides an easy way to install various New Relic agents and the New Relic server monitor.

More information?
* https://newrelic.com/docs/server/new-relic-for-server-monitoring
Expand Down Expand Up @@ -138,20 +138,22 @@ Attributes
* `node['newrelic']['log_daily']` - Override other log rolling configuration and roll the logs daily

## nodejs-agent.rb
* node['newrelic']['nodejs']['apps'] - Array of Hash describing the apps to monitor:
* node['newrelic']['nodejs']['apps'] - Array of Hash describing the apps to monitor

eg.
```
[
{ 'app_name' => 'My Application', 'app_path' => "/path/to/app/root" }
]
]
```

You then need to modify your application "main" file to add the following on the first line:

```javascript
```
javascript
require('newrelic');
```


Resources / Providers
=====================

Expand Down
10 changes: 4 additions & 6 deletions attributes/nodejs-agent.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#
# Cookbook Name:: newrelic
# Attributes:: nodejs-agent
#
# MIT Licensed
# Copyright 2012-2013, Escape Studios
#

# Array of Hash describing the apps to monitor:
# [
# { 'app_name' => 'My Application', 'app_path' => "/path/to/app/root" }
# ]
default['newrelic']['nodejs']['apps'] = []

default['newrelic']['nodejs_recipe'] = "nodejs::npm"
4 changes: 2 additions & 2 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
license "MIT"
description "Installs/Configures New Relic"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.5.7"
version "0.5.8"

%w{ debian ubuntu redhat centos fedora scientific amazon windows smartos }.each do |os|
supports os
Expand All @@ -22,4 +22,4 @@
recipe "newrelic::php-agent", "Installs the New Relic PHP agent."
recipe "newrelic::python-agent", "Installs the New Relic Python agent."
recipe "newrelic::dotnet", "Installs New Relic .NET Agent"
recipe "newrelic::nodejs", "Installs New Relic Node.js Agent"
recipe "newrelic::nodejs", "Installs New Relic Node.js Agent"
33 changes: 16 additions & 17 deletions recipes/nodejs-agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@
# Cookbook Name:: newrelic
# Recipe:: nodejs-agent
#
# Copyright 2014, La Presse
# MIT License
# Copyright 2012-2013, Escape Studios
#

include_recipe node['newrelic']['nodejs_recipe']

include_recipe "nodejs::npm"


# Install the newrelic.js file into each projects
#install the newrelic.js file into each projects
node['newrelic']['nodejs']['apps'].each do |nodeapp|
execute "npm-install-nodejs-agent" do
#not_if ""
# creates
cwd nodeapp['app_path']
command "npm install newrelic"
end
template "#{nodeapp['app_path']}/newrelic.js" do
source "newrelic.js.erb"
variables :app_name => nodeapp['app_name'], :app_log_level => "INFO"
end
end
execute "npm-install-nodejs-agent" do
cwd nodeapp['app_path']
command "npm install newrelic"
end

template "#{nodeapp['app_path']}/newrelic.js" do
source "newrelic.js.erb"
variables(
:app_name => nodeapp['app_name'],
:app_log_level => "INFO"
)
end
end
36 changes: 18 additions & 18 deletions templates/default/newrelic.js.erb
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
/**
* THIS FILE IS MANAGED BY CHEF
* ALL MODIFICATIONS WILL BE LOSTS
* TO EDIT, SEE newrelic COOKBOOK AT .../templates/default/newrelic.js.erb
* ###################
* # Generated by Chef
* ###################
*
* New Relic agent configuration.
*
* See lib/config.defaults.js in the agent distribution for a more complete
* description of configuration variables and their potential values.
*/
exports.config = {
/**
* Array of application names.
*/
app_name : ['<%= @app_name %>'],
/**
* Your New Relic license key.
*/
license_key : '<%= node['newrelic']['application_monitoring']['license'] %>',
logging : {
/**
* Level at which to log. 'trace' is most useful to New Relic when diagnosing
* issues with the agent, 'info' and higher will impose the least overhead on
* production applications.
* Array of application names.
*/
level : '<%= @app_log_level %>'
}
};
app_name: ['<%= @app_name %>'],
/**
* Your New Relic license key.
*/
license_key: '<%= node['newrelic']['application_monitoring']['license'] %>',
logging: {
/**
* Level at which to log. 'trace' is most useful to New Relic when diagnosing
* issues with the agent, 'info' and higher will impose the least overhead on
* production applications.
*/
level: '<%= @app_log_level %>'
}
};

0 comments on commit 0f0576a

Please sign in to comment.