├── .category ├── .foodcritic ├── .gitignore ├── .kitchen.yml ├── .travis.yml ├── Berksfile ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── Rakefile ├── TESTING.md ├── attributes ├── default.rb ├── dotnet_agent.rb ├── java_agent.rb ├── nodejs_agent.rb ├── php_agent.rb ├── python_agent.rb ├── repository.rb ├── ruby_agent.rb └── server_monitor_agent.rb ├── libraries ├── helpers.rb ├── matchers.rb ├── newrelic.rb └── server_monitor_helpers.rb ├── metadata.rb ├── providers ├── agent_dotnet.rb ├── agent_infrastructure.rb ├── agent_java.rb ├── agent_nodejs.rb ├── agent_php.rb ├── agent_python.rb ├── agent_ruby.rb ├── deployment.rb ├── server_monitor.rb └── yml.rb ├── recipes ├── default.rb ├── dotnet_agent.rb ├── infrastructure_agent.rb ├── java_agent.rb ├── nodejs_agent.rb ├── php_agent.rb ├── python_agent.rb ├── repository.rb ├── ruby_agent.rb └── server_monitor_agent.rb ├── resources ├── agent_dotnet.rb ├── agent_infrastructure.rb ├── agent_java.rb ├── agent_nodejs.rb ├── agent_php.rb ├── agent_python.rb ├── agent_ruby.rb ├── deployment.rb ├── server_monitor.rb └── yml.rb ├── spec ├── spec_helper.rb └── unit │ ├── agent_dotnet_spec.rb │ ├── agent_infrastructure_spec.rb │ ├── agent_java_spec.rb │ ├── agent_nodejs_spec.rb │ ├── agent_php_spec.rb │ ├── agent_python_spec.rb │ ├── agent_ruby_spec.rb │ ├── default_spec.rb │ ├── license_spec.rb │ ├── repository_spec.rb │ └── server_monitor_spec.rb ├── templates └── default │ └── agent │ ├── dotnet │ └── newrelic.config.erb │ ├── infrastructure │ └── newrelic.yml.erb │ ├── newrelic.yml.erb │ ├── nodejs │ └── newrelic.js.erb │ ├── php │ ├── newrelic.cfg.erb │ └── newrelic.ini.erb │ ├── python │ └── newrelic.ini.erb │ └── server_monitor │ └── nrsysmond.cfg.erb └── test ├── fixtures └── cookbooks │ └── newrelic_lwrp_test │ ├── README.md │ ├── metadata.rb │ └── recipes │ ├── agent_dotnet.rb │ ├── agent_infrastructure.rb │ ├── agent_java.rb │ ├── agent_nodejs.rb │ ├── agent_nodejs_recipe.rb │ ├── agent_php.rb │ ├── agent_python.rb │ ├── agent_python_recipe.rb │ ├── agent_ruby.rb │ ├── lwrp_yml.rb │ └── server_monitor.rb └── integration ├── default └── serverspec │ └── default_spec.rb ├── helpers └── serverspec │ └── spec_helper.rb ├── infrastructure-agent └── serverspec │ └── default_spec.rb ├── java-agent └── serverspec │ └── default_spec.rb ├── nodejs-agent-recipe └── serverspec │ └── default_spec.rb ├── nodejs-agent └── serverspec │ └── default_spec.rb ├── php-agent-php5enmod └── serverspec │ └── default_spec.rb ├── php-agent └── serverspec │ └── default_spec.rb ├── python-agent-recipe └── serverspec │ └── default_spec.rb ├── python-agent └── serverspec │ └── default_spec.rb ├── ruby-agent └── serverspec │ └── default_spec.rb └── server-monitor └── serverspec └── default_spec.rb /.category: -------------------------------------------------------------------------------- 1 | Monitoring & Trending 2 | -------------------------------------------------------------------------------- /.foodcritic: -------------------------------------------------------------------------------- 1 | ~FC037 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .vagrant 2 | Berksfile.lock 3 | *~ 4 | *# 5 | .#* 6 | \#*# 7 | .*.sw[a-z] 8 | *.un~ 9 | 10 | # Bundler 11 | Gemfile.lock 12 | bin/* 13 | .bundle/* 14 | 15 | .kitchen/ 16 | .kitchen.local.yml 17 | .idea 18 | -------------------------------------------------------------------------------- /.kitchen.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver_plugin: vagrant 3 | 4 | provisioner: 5 | name: chef_zero 6 | client_rb: 7 | chef_license: accept 8 | attributes: 9 | newrelic: 10 | license: '0000ffff0000ffff0000ffff0000ffff0000ffff' 11 | 12 | platforms: 13 | - name: ubuntu-18.04 14 | run_list: 15 | - recipe[apt] 16 | attributes: 17 | rubygems: 'rubygems-integration' 18 | java: 19 | jdk_version: 8 20 | newrelic: 21 | php_agent: 22 | web_server: 23 | service_name: apache2 24 | php_config: '/etc/php/7.0/mods-available/newrelic.ini' 25 | nodejs: 26 | repo: 'https://deb.nodesource.com/node_6.x' 27 | php: 28 | packages: 29 | - php7.4-cgi 30 | - php7.4 31 | - php7.4-dev 32 | - php7.4-cli 33 | - php-pear 34 | conf_dir: '/etc/php/7.4/cli' 35 | - name: ubuntu-20.04 36 | run_list: 37 | - recipe[apt] 38 | attributes: 39 | rubygems: 'rubygems-integration' 40 | java: 41 | jdk_version: 8 42 | newrelic: 43 | php_agent: 44 | web_server: 45 | service_name: apache2 46 | php_config: '/etc/php/7.0/mods-available/newrelic.ini' 47 | nodejs: 48 | repo: 'https://deb.nodesource.com/node_6.x' 49 | php: 50 | packages: 51 | - php7.4-cgi 52 | - php7.4 53 | - php7.4-dev 54 | - php7.4-cli 55 | - php-pear 56 | conf_dir: '/etc/php/7.4/cli' 57 | - name: centos-7 58 | attributes: 59 | rubygems: 'rubygems' 60 | newrelic: 61 | php_agent: 62 | web_server: 63 | service_name: httpd 64 | php_config: '/etc/php.d/newrelic.ini' 65 | - name: centos-8 66 | attributes: 67 | rubygems: 'rubygems' 68 | newrelic: 69 | php_agent: 70 | web_server: 71 | service_name: httpd 72 | php_config: '/etc/php.d/newrelic.ini' 73 | 74 | suites: 75 | - name: default 76 | run_list: 77 | - recipe[newrelic::default] 78 | attributes: 79 | newrelic: 80 | server_monitor_agent: 81 | service_notify_action: nothing 82 | service_actions: 83 | - nothing 84 | - name: php-agent 85 | run_list: "recipe[newrelic_lwrp_test::agent_php]" 86 | attributes: 87 | newrelic: 88 | php_agent: 89 | enable_module: false 90 | - name: php-agent-enable-module 91 | run_list: "recipe[newrelic_lwrp_test::agent_php]" 92 | attributes: 93 | newrelic: 94 | php_agent: 95 | enable_module: true 96 | - name: php-agent-php5enmod 97 | run_list: "recipe[newrelic_lwrp_test::agent_php]" 98 | attributes: 99 | newrelic: 100 | php_agent: 101 | execute_php5enmod: true 102 | - name: server-monitor 103 | run_list: "recipe[newrelic_lwrp_test::server_monitor]" 104 | - name: infrastructure-agent 105 | run_list: "recipe[newrelic_lwrp_test::agent_infrastructure]" 106 | excludes: 107 | - ubuntu-17.04 # @07/2017: [12.04, 14.04, 16.04](https://docs.newrelic.com/docs/infrastructure/new-relic-infrastructure/getting-started/compatibility-requirements-new-relic-infrastructure#operating-systems) 108 | - name: java-agent 109 | run_list: "recipe[newrelic_lwrp_test::agent_java]" 110 | attributes: 111 | newrelic: 112 | java_agent: 113 | install_dir: '/opt/tomcat_java_test_app' 114 | - name: java-agent-not-latest-version 115 | run_list: "recipe[newrelic_lwrp_test::agent_java]" 116 | attributes: 117 | newrelic: 118 | java_agent: 119 | version: 3.31.1 120 | install_dir: '/opt/tomcat_java_test_app' 121 | - name: ruby-agent 122 | run_list: "recipe[newrelic_lwrp_test::agent_ruby]" 123 | attributes: 124 | newrelic: 125 | ruby_agent: 126 | install_dir: '/opt/newrelic/ruby' 127 | - name: python-agent 128 | run_list: "recipe[newrelic_lwrp_test::agent_python]" 129 | - name: python-agent-recipe 130 | run_list: "recipe[newrelic_lwrp_test::agent_python_recipe]" 131 | - name: nodejs-agent 132 | run_list: "recipe[newrelic_lwrp_test::agent_nodejs]" 133 | - name: nodejs-agent-recipe 134 | run_list: "recipe[newrelic_lwrp_test::agent_nodejs_recipe]" 135 | - name: lwrp_yml 136 | run_list: "recipe[newrelic_lwrp_test::lwrp_yml]" 137 | attributes: 138 | newrelic: 139 | java_agent: 140 | install_dir: '/opt/tomcat_java_test_app' 141 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # use chef-current-focal to install the pre-release 2 | addons: 3 | apt: 4 | sources: 5 | - chef-stable-focal 6 | packages: 7 | - chef-workstation 8 | 9 | services: docker 10 | 11 | # https://docs.travis-ci.com/user/customizing-the-build/#Skipping-the-Installation-Step 12 | install: true 13 | 14 | env: 15 | - CHEF_LICENSE="accept" 16 | 17 | before_script: 18 | - eval "$(/opt/chef-workstation/bin/chef shell-init bash)" # make Chef workstation's Ruby the default 19 | - chef --version 20 | - chef exec berks install 21 | 22 | script: 23 | - chef exec rake travis 24 | 25 | branches: 26 | only: 27 | - master 28 | - /^release\/.*$/ 29 | - /^feature\/.*$/ 30 | - /^bugfix\/.*$/ 31 | 32 | notifications: 33 | email: 34 | - development@davidjoos.com 35 | -------------------------------------------------------------------------------- /Berksfile: -------------------------------------------------------------------------------- 1 | source 'https://supermarket.chef.io' 2 | 3 | # uninitialized constant Win32 caused by ark-cookbook change in v1.2.0 4 | # (https://github.com/chef-cookbooks/ark/commit/0012c57188ff6e7df2ac69883c029bb88ce001e2) 5 | cookbook 'ark', '= 1.1.0' 6 | 7 | group :integration do 8 | cookbook 'newrelic_lwrp_test', path: 'test/fixtures/cookbooks/newrelic_lwrp_test' 9 | end 10 | 11 | metadata 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # newrelic cookbook CHANGELOG 2 | 3 | This file is used to list changes made in each version (>= 2.11.0) of the newrelic cookbook. 4 | 5 | ## v2.45.6 6 | - update install command to not break on non-ARM architectures 7 | 8 | ## v2.45.5 9 | - allow support for the ARM repository in Debian 10 | 11 | ## v2.45.4 12 | - added version to string handling for newer Ubuntu version(s) 13 | 14 | ## v2.45.3 15 | - include version into PHP (ARM) agent archive repository url 16 | 17 | ## v2.45.2 18 | - cut over from /release to /archive as PHP (ARM) agent installation repository 19 | 20 | ## v2.45.1 21 | - fixed PHP agent ARM installation 22 | 23 | ## v2.45.0 24 | - support for installation of the PHP agent on ARM architecture 25 | 26 | ## v2.44.0 27 | - OS refresh 28 | - remove dependency on archived/deprecated poise cookbook(s) 29 | 30 | ## v2.43.0 31 | - lazy evaluation of default properties in yml.rb 32 | 33 | ## v2.42.0 34 | - adds PHP agent version attribute to allow pinning the version 35 | - fixed PHP agent distributed tracing 36 | - Ubuntu 20.04 support 37 | 38 | ## v2.41.0 39 | - add distributed tracing to php agent resource 40 | 41 | ## v2.40.5 42 | - update default value for windows_checksum 43 | 44 | ## v2.40.4 45 | - addition of circuit breaker configuration to java_agent recipe 46 | 47 | ## v2.40.3 48 | - circuit breaker configuration for YML LWRP 49 | 50 | ## v2.40.2 51 | - trim_stats for YML LWRP 52 | 53 | ## v2.40.1 54 | - add explicit circuit breaker configuration for Ruby agent 55 | 56 | ## v2.40.0 57 | - support strip_command_line flag for the infra agent 58 | - add explicit circuit breaker configuration for Java agent 59 | - trim_stats config item for Java/Ruby agent 60 | - add Distributed Tracing support for the .NET Agent 61 | 62 | ## v2.39.1 63 | - Fix distributed tracing issues 64 | 65 | ## v2.39.0 66 | - add distributed_tracing attribute for Java and Ruby APM 67 | 68 | ## v2.38.2 69 | - Fix linux service provider for Amazon Linux 2 support 70 | 71 | ## v2.38.1 72 | - Fix .NET agent configuration when a proxy is specified 73 | 74 | ## v2.38.0 75 | - update file permission for infra agent YML config file 76 | 77 | ## v2.37.0 78 | - lazy evaluation of license attribute(s) 79 | 80 | ## v2.36.1 81 | - download path to DotNet agent has changed, again... 82 | 83 | ## v2.36.0 84 | - support for amazon linux 2018 85 | - allow installing on-host integrations package 86 | - repository attribute for java agent download 87 | - multiple application names for Windows 88 | 89 | ## v2.35.1 90 | - fix Travis CI build 91 | 92 | ## v2.35.0 93 | - add error_collector_ignore_classes attribute for java_agent 94 | 95 | ## v2.34.0 96 | - allow custom attributes for infrastructure agent 97 | 98 | ## v2.33.0 99 | - bring dotnet agent's README, attribute and recipe in sync 100 | - fix dotnet MSI download url, given New Relic changed it all of a sudden... 101 | 102 | ## v2.32.0 103 | - add error_collector_ignore_errors attribute for php_agent 104 | - fixed location of closing tag for service element 105 | 106 | ## v2.31.2 107 | - added upstart support for Amazon Linux (infrastructure agent) 108 | 109 | ## v2.31.1 110 | - download server monitor msi over https 111 | - ChefSpec update(s) - version bumps 112 | 113 | ## v2.31.0 114 | - write infrastructure license before package 115 | - set service provisioner to Upstart for ubuntu < 16.04 116 | - bump Chef version in README (caused by poise-python dependency) 117 | - ChefSpec fix(es) - String (or Array) key on apt_repository is treated as Array upon inspection 118 | - FoodCritic fix(es) - FC028: Incorrect #platform? usage 119 | 120 | ## v2.30.0 121 | - logic for repository proxy for RHEL 122 | - support for Amazon Linux in Chef 13 123 | 124 | ## v2.29.0 125 | - implementation of the New Relic Infrastructure Agent 126 | 127 | ## v2.28.1 128 | - addition of CHANGELOG entry for version 2.28.0 129 | 130 | ## v2.28.0 131 | - addition of ssl verify on yum_repository for those that have a mirror yum repo with a self-signed certificate 132 | 133 | ## v2.27.1 134 | 135 | - integration test fix(es) 136 | 137 | ## v2.27.0 138 | 139 | - swapping out python for poise-python as its deprecated 140 | - additional (integration) test suite: python-agent 141 | - added the ability to specify New Relic NodeJS agent version 142 | - rename test fixture cookbook: newrelic_poc > newrelic_lwrp_test 143 | - adding other_options to server_monitor 144 | 145 | ## v2.26.0 146 | 147 | - (feature) class transformer configuration support for Java agent 148 | - (bugfix) default agent_actions converted to strings 149 | - (bugfix) for missing erb tag for feature_flag variable (#289) 150 | 151 | ## v2.25.0 152 | 153 | - don't verify the Python agent configuration on every Chef run 154 | - Rubocop fix(es) for cops in latest Chef DK version 155 | 156 | ## v2.24.2 157 | 158 | - updated version constraint for apt cookbook 159 | 160 | ## v2.24.1 161 | 162 | - fix for enable_custom_tracing when using newrelic_yml-LWRP directly 163 | 164 | ## v2.24.0 165 | 166 | - support for PHP7 167 | - parameterize dotnet agent config file 168 | - properly follow through with hostname 169 | - make documentation more consistent 170 | 171 | ## v2.23.3 172 | 173 | - version incorrectly used and filename unused 174 | 175 | ## v2.23.2 176 | 177 | - workaround inconsistencies in .zip file naming of New Relic download 178 | 179 | ## v2.23.1 180 | 181 | - unzipping the agent with sudo broke when user didn't have sudo rights 182 | 183 | ## v2.23.0 184 | 185 | - remove parsing of download page for Java-agent download 186 | - include unzip-package for extracting newrelic.jar from zip 187 | - addition of CentOS 7.2 platform integration tests 188 | 189 | ## v2.22.4 190 | 191 | - minor syntax correction (server monitor) 192 | - README.md fix(es) 193 | 194 | ## v2.22.3 (2016-08-23) 195 | 196 | - get rid of confusing chefignore in cookbook repo, as it is actually only respected in the cookbook_path 197 | - reimplementation of cookbook-path in Rakefile 198 | - rework of version in metadata.rb 199 | 200 | ## v2.22.2 (2016-08-23) 201 | 202 | - addition of quotes around cookbook name and cookbook category 203 | 204 | ## v2.22.1 (2016-08-23) 205 | 206 | - workaround for [CHEF-3627](http://tickets.opscode.com/browse/CHEF-3627) in CI-setup 207 | - adjustment to upload complete-matcher when uploading to the Chef Supermarket 208 | 209 | ## v2.22.0 (2016-08-23) 210 | 211 | - CI-improvements 212 | - fix for typo 213 | 214 | ## v2.21.0 (2016-08-03) 215 | 216 | - remove friction and run tests via ChefDK 217 | 218 | ## v2.20.0 (2016-07-03) 219 | 220 | - add usage of Java agent_action attribute 221 | - ensure setting execute_php5enmod is meaningful 222 | - DRY up Test Kitchen spec_helper 223 | - bugfix: forward slashes must be escaped 224 | 225 | ## v2.19.0 (2016-04-01) 226 | 227 | - MIA 228 | 229 | ## v2.18.0 (2016-01-22) 230 | 231 | - MIA 232 | 233 | ## v2.17.0 (2015-11-18) 234 | 235 | - MIA 236 | 237 | ## v2.16.0 (2015-09-17) 238 | 239 | - Add verify_agent_config virtualenv support 240 | - Refactoring: set agent_type and license as default in resources 241 | 242 | ## v2.15.1 (2015-09-17) 243 | 244 | - Bugfix: Fedora is [not](https://github.com/chef/ohai/blob/master/lib/ohai/plugins/linux/platform.rb#L180) part of the RedHat platform_family 245 | 246 | ## v2.15.0 (2015-09-12) 247 | 248 | - Make service action configurable; service_action will be restart by default as per New Relic docs 249 | - Ability to add additional config 250 | 251 | ## v2.14.2 (2015-08-07) 252 | 253 | - Trigger apt-get update run 254 | 255 | ## v2.14.1 (2015-07-27) 256 | 257 | - Do not stop newrelic-daemon unnecessarily when using agent mode 258 | 259 | ## v2.14.0 (2015-07-23) 260 | 261 | - Addition of matcher methods for resources 262 | - Cleanup documentation on newrelic_deployment LWRP 263 | 264 | ## v2.13.0 (2015-06-19) 265 | 266 | - Ability to configure the alert policy group when installing/removing server monitor 267 | 268 | ## v2.12.5 (2015-06-19) 269 | 270 | - nodejs template update - make use of LWRP attributes 271 | - Cleanup of unused attribute(s) in agent_java LWRP: owner > app_user and group > app_group 272 | 273 | ## v2.12.4 (2015-06-18) 274 | 275 | - Bugfix: broken YML LWRP after 2.11.0 276 | 277 | ## v2.12.3 (2015-06-18) 278 | 279 | - Bugfix: newrelic_lwrp_test::agent_java failed due to incorrect remote_file usage 280 | - Bugfix: NodeJS cookbook default attribute to avoid capitalization issue with the New Relic agent 281 | - Bugfix: Java agent provider was throwing a uninitialized constant Chef::Provider::File::SEPARATOR error due to a missing Ruby namespace resolution operator 282 | - php -> python typo 283 | - Take out unnecessary disabling of Metrics/AbcSize 284 | 285 | ## v2.12.2 (2015-06-01) 286 | 287 | - Bugfix: illegal to set resource values during the provider execution 288 | 289 | ## v2.12.1 (2015-06-01) 290 | 291 | - Bugfix: fixed detection of the java_agent execute_agent_action node attribute 292 | 293 | ## v2.12.0 (2015-05-23) 294 | 295 | - Refactoring: convert other agents to lwrp 296 | - Removal of non-ASCII characters in README.md 297 | - Java agent upgrades: 'latest' 298 | - support for labels in Java and Ruby agents 299 | 300 | ## v2.11.2 (2015-04-18) 301 | 302 | - Bugfix: ssl attribute in server monitor, see issue #179 303 | - General: 2.11.x cleanup 304 | 305 | ## v2.11.1 (2015-04-17) 306 | 307 | - Bugfix: attribute that was previously potentially a TrueClass or FalseClass must be of type String, see issue #175 308 | 309 | ## v2.11.0 (2015-04-17) 310 | 311 | - Refactoring: convert php agent and server monitor to lwrp 312 | - Housekeeping: copyright 313 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ========= 3 | 4 | 1. Fork it 5 | 2. Create your feature branch (`git checkout -b my-new-feature`) 6 | 3. Commit your changes (`git commit -am 'Add some feature'`) 7 | 4. [Add tests for your changes](https://github.com/djoos-cookbooks/newrelic/blob/master/TESTING.md) 8 | 4. Push your changes to your feature branch (`git push origin my-new-feature`) 9 | 5. Create a new PR (Pull Request) 10 | 11 | ## Testing 12 | Contributions will only be accepted if they are fully tested as specified in [TESTING.md](https://github.com/djoos-cookbooks/newrelic/blob/master/TESTING.md). 13 | 14 | ## metadata.rb 15 | Please do not modify the version number in the metadata.rb; not all changes to the cookbook may be merged and released in the same version. We will handle the version updates during the release process. 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2012-2017 David Joos 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rspec/core/rake_task' 2 | require 'chef/cookbook/metadata' 3 | require 'yaml' 4 | 5 | environment = ENV['ENVIRONMENT'] || '' 6 | 7 | # this module groups useful general commands together 8 | module GeneralCommands 9 | @logging = ENV['LOGGING'] || true 10 | 11 | def self.run(cmd, *expected_exitstatuses) 12 | puts "+ #{cmd}" if @logging 13 | output = `#{cmd} 2>&1` 14 | puts output.gsub(/^/, '- ') if @logging 15 | expected_exitstatuses << 0 if expected_exitstatuses.empty? 16 | error_message = "ERROR: '#{cmd}' failed with exit status #{$CHILD_STATUS.exitstatus}" 17 | raise StandardError, error_message unless [expected_exitstatuses].flatten.include?($CHILD_STATUS.exitstatus) 18 | output 19 | end 20 | 21 | def self.parse_metadata(metadata_file = 'metadata.rb') 22 | metadata = Chef::Cookbook::Metadata.new 23 | metadata.from_file(metadata_file) 24 | 25 | metadata 26 | end 27 | end 28 | 29 | # this module groups useful release commands together 30 | module ReleaseCommands 31 | def self.ensure_working_directory_state(allowed_modified_files = []) 32 | modified_files = GeneralCommands.run('git diff --name-only', 0, 1) 33 | modified_files = modified_files.split(/\n+/) 34 | 35 | return if allowed_modified_files.uniq.sort == modified_files.uniq.sort 36 | raise '[RELEASE] Working directory is in an unexpected state' 37 | end 38 | 39 | def self.verify_tag(should_exist = false) 40 | return if GeneralCommands.run("git rev-parse -q --verify \"refs/tags/#{version}\"", 0, 1).empty? != should_exist 41 | 42 | suffix = if should_exist == true 43 | 'does not exist' 44 | else 45 | 'already exists' 46 | end 47 | 48 | raise "[RELEASE] Tag (#{version}) #{suffix}" 49 | end 50 | 51 | def self.version 52 | GeneralCommands.parse_metadata.version 53 | end 54 | 55 | def self.name 56 | GeneralCommands.parse_metadata.name 57 | end 58 | 59 | def self.category 60 | file_name = '.category' 61 | 62 | if File.exist?(file_name) 63 | File.read(file_name).strip 64 | else 65 | '' 66 | end 67 | end 68 | 69 | def self.pre_publish 70 | GitCommands.ensure_branch('master') 71 | 72 | ReleaseCommands.ensure_working_directory_state 73 | end 74 | 75 | def self.publish_to_scm 76 | ReleaseCommands.pre_publish 77 | 78 | ReleaseCommands.verify_tag(false) 79 | 80 | puts 'Creating an annotated tag...' 81 | GitCommands.tag(ReleaseCommands.version) 82 | 83 | puts 'Push tag to remote repository...' 84 | GitCommands.push_tags('origin', 'master', ReleaseCommands.version) 85 | end 86 | 87 | def self.publish_to_chef_server 88 | ReleaseCommands.pre_publish 89 | 90 | ReleaseCommands.verify_tag(true) 91 | 92 | puts 'Updating Berkshelf...' 93 | BerkshelfCommands.update 94 | 95 | puts 'Packaging cookbooks (creating a single archive containing all of your required cookbooks)' 96 | BerkshelfCommands.package('cookbooks.tar.gz') 97 | 98 | puts 'Installing packaged cookbooks into Chef Server' 99 | BerkflowCommands.install('cookbooks.tar.gz') 100 | end 101 | 102 | def self.publish_to_chef_supermarket 103 | ReleaseCommands.pre_publish 104 | 105 | ReleaseCommands.verify_tag(true) 106 | 107 | cookbook_name = ReleaseCommands.name 108 | cookbook_category = ReleaseCommands.category 109 | 110 | if cookbook_name.blank? || cookbook_category.blank? 111 | puts 'Skipped sharing to the Chef Supermarket - cookbook name and/or category not set. Set it and run \'publish:chef:supermarket\' separately if needed.' 112 | else 113 | puts 'Sharing to the Chef Supermarket...' 114 | 115 | KnifeCommands.share(cookbook_name, cookbook_category) 116 | end 117 | end 118 | 119 | def self.release(environment = '') 120 | raise 'You must specify an environment name.' if environment.blank? 121 | 122 | ReleaseCommands.ensure_working_directory_state 123 | ReleaseCommands.verify_tag(true) 124 | 125 | puts "Applying the cookbook version locks to the '#{environment}'-Chef environment" 126 | BerkshelfCommands.apply(environment) 127 | end 128 | end 129 | 130 | # this module groups useful berkshelf commands together 131 | module BerkshelfCommands 132 | def self.update 133 | return if GeneralCommands.run('chef exec berks update', 0, 1) 134 | raise '[BERKSHELF] Failed to update' 135 | end 136 | 137 | def self.package(archive_filename = 'cookbooks.tar.gz') 138 | raise '[BERKSHELF] You must specify an archive filename.' if archive_filename.blank? 139 | 140 | return if GeneralCommands.run("chef exec berks package #{archive_filename}", 0, 1) 141 | raise "[BERKSHELF] Failed to create #{archive_filename}-archive" 142 | end 143 | 144 | def self.apply(environment = '') 145 | raise '[BERKSHELF] You must specify an environment.' if environment.blank? 146 | 147 | return unless GeneralCommands.run("chef exec berks apply #{environment}", 0, 1).empty? 148 | raise "[BERKSHELF] Failed to apply the cookbook version locks to the '#{environment}'-Chef environment" 149 | end 150 | end 151 | 152 | # this module groups useful berkflow commands together 153 | module BerkflowCommands 154 | def self.install(archive_filename = 'cookbooks.tar.gz') 155 | raise '[BERKFLOW] You must specify an archive filename.' if archive_filename.blank? 156 | 157 | return if /Done./ =~ GeneralCommands.run("chef exec blo in #{archive_filename}", 0, 1) 158 | raise "[BERKFLOW] Failed to install packaged cookbooks #{archive_filename} into Chef Server" 159 | end 160 | end 161 | 162 | # this module groups useful git commands together 163 | module GitCommands 164 | def self.ensure_branch(branch = 'master') 165 | raise '[GIT] You must specify a branch.' if branch.empty? 166 | 167 | return if /#{branch}/ =~ GeneralCommands.run('git rev-parse --abbrev-ref HEAD', 0, 1) 168 | raise '[GIT] Currently working on unexpected branch' 169 | end 170 | 171 | def self.tag(tag = '') 172 | raise '[GIT] You must specify a tag.' if tag.blank? 173 | 174 | return if GeneralCommands.run("git tag -a #{tag} -m '#{tag}'", 0, 1) 175 | raise '[GIT] Failed to tag' 176 | end 177 | 178 | def self.push_tags(remote = 'origin', branch = 'master', tag = '') 179 | raise '[GIT] You must specify a remote.' if remote.blank? 180 | raise '[GIT] You must specify a branch.' if branch.blank? 181 | raise '[GIT] You must specify a tag.' if tag.blank? 182 | 183 | return if GeneralCommands.run("git push #{remote} #{branch} --tags", 0, 1) 184 | raise '[GIT] Failed to push to remote' 185 | end 186 | end 187 | 188 | # this module groups useful knife commands together 189 | module KnifeCommands 190 | def self.share(cookbook_name = '', cookbook_category = '') 191 | raise '[KNIFE] Missing cookbook name.' if cookbook_name.blank? 192 | raise '[KNIFE] Missing cookbook category.' if cookbook_category.blank? 193 | 194 | return if /Upload complete/ =~ GeneralCommands.run("chef exec knife supermarket share '#{cookbook_name}' '#{cookbook_category}' --cookbook-path ../", 0, 1) 195 | raise "[KNIFE] Failed to publish the #{cookbook_name}-cookbook on the Chef Supermarket" 196 | end 197 | end 198 | 199 | namespace :style do 200 | require 'cookstyle' 201 | require 'rubocop/rake_task' 202 | 203 | desc 'Run Cookstyle checks' 204 | RuboCop::RakeTask.new(:cookstyle) 205 | end 206 | 207 | desc 'Run all syntax/lint checks' 208 | task style: ['style:cookstyle'] 209 | 210 | desc 'Run ChefSpec tests' 211 | RSpec::Core::RakeTask.new(:spec) 212 | 213 | namespace :integration do 214 | require 'kitchen' 215 | 216 | desc 'Run integration tests (Test Kitchen & Vagrant)' 217 | task :vagrant do 218 | Kitchen.logger = Kitchen.default_file_logger 219 | Kitchen::Config.new.instances.each do |instance| 220 | instance.test(:always) 221 | end 222 | end 223 | end 224 | 225 | namespace :publish do 226 | desc 'Publish to SCM' 227 | task :scm do 228 | ReleaseCommands.publish_to_scm 229 | end 230 | 231 | namespace :chef do 232 | desc 'Publish to Chef Server' 233 | task :server do 234 | ReleaseCommands.publish_to_chef_server 235 | end 236 | 237 | desc 'Publish to Chef Supermarket' 238 | task :supermarket do 239 | ReleaseCommands.publish_to_chef_supermarket 240 | end 241 | end 242 | 243 | task all: ['scm', 'chef:supermarket', 'chef:server'] 244 | end 245 | 246 | desc 'Run lint checks' 247 | task lint: %w(style) 248 | 249 | desc 'Run unit tests' 250 | task unit: %w(spec) 251 | 252 | desc 'Run Travis CI tests' 253 | task travis: %w(lint unit) 254 | 255 | desc 'Run all integration tests' 256 | task integration: %w(integration:vagrant) 257 | 258 | desc 'Publish' 259 | task publish: %w(publish:scm publish:chef:supermarket publish:chef:server) 260 | 261 | desc 'Release' 262 | task :release do 263 | ReleaseCommands.release(environment) 264 | end 265 | 266 | task default: %w(lint unit integration) 267 | -------------------------------------------------------------------------------- /TESTING.md: -------------------------------------------------------------------------------- 1 | # Testing the cookbook 2 | 3 | Contributions to this cookbook will only be accepted if all tests pass successfully. 4 | 5 | ## Setting up the test environment 6 | 7 | Install the latest stable version of [ChefDK](https://downloads.chef.io/chef-dk/). You'll need [Vagrant](http://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads) for running integration tests. 8 | 9 | ## Running tests 10 | 11 | ### Style checks 12 | 13 | `chef exec rake style` 14 | 15 | ### Unit tests 16 | 17 | `chef exec rake unit` 18 | 19 | ## Integration tests 20 | 21 | `chef exec rake integration` 22 | 23 | ## All checks/tests 24 | 25 | `chef exec rake` 26 | -------------------------------------------------------------------------------- /attributes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Attributes:: default 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | ############## 9 | # BASIC CONFIG 10 | ############## 11 | # license(s), all default to node['newrelic']['license'] 12 | default['newrelic']['license'] = nil 13 | default['newrelic']['server_monitoring']['license'] = nil 14 | default['newrelic']['application_monitoring']['license'] = nil 15 | default['newrelic']['api_key'] = nil 16 | 17 | # proxy 18 | default['newrelic']['proxy'] = nil 19 | default['newrelic']['server_monitoring']['proxy'] = node['newrelic']['proxy'] 20 | default['newrelic']['application_monitoring']['daemon']['proxy'] = node['newrelic']['proxy'] 21 | 22 | ################# 23 | # ADVANCED CONFIG 24 | ################# 25 | # server monitoring 26 | default['newrelic']['server_monitoring']['logfile'] = nil 27 | default['newrelic']['server_monitoring']['loglevel'] = nil 28 | default['newrelic']['server_monitoring']['ssl'] = nil 29 | default['newrelic']['server_monitoring']['ssl_ca_bundle'] = nil 30 | default['newrelic']['server_monitoring']['ssl_ca_path'] = nil 31 | default['newrelic']['server_monitoring']['hostname'] = nil 32 | default['newrelic']['server_monitoring']['pidfile'] = nil 33 | default['newrelic']['server_monitoring']['collector_host'] = nil 34 | default['newrelic']['server_monitoring']['timeout'] = nil 35 | default['newrelic']['server_monitoring']['other_options'] = {} 36 | 37 | # application monitoring 38 | default['newrelic']['application_monitoring']['enabled'] = nil 39 | default['newrelic']['application_monitoring']['logfile'] = nil 40 | default['newrelic']['application_monitoring']['logfile_path'] = nil 41 | default['newrelic']['application_monitoring']['loglevel'] = nil 42 | default['newrelic']['application_monitoring']['app_name'] = nil 43 | default['newrelic']['application_monitoring']['high_security'] = nil 44 | default['newrelic']['application_monitoring']['daemon']['logfile'] = '/var/log/newrelic/newrelic-daemon.log' 45 | default['newrelic']['application_monitoring']['daemon']['loglevel'] = nil 46 | default['newrelic']['application_monitoring']['daemon']['port'] = nil 47 | default['newrelic']['application_monitoring']['daemon']['max_threads'] = nil 48 | default['newrelic']['application_monitoring']['daemon']['ssl'] = nil 49 | default['newrelic']['application_monitoring']['daemon']['ssl_ca_path'] = nil 50 | default['newrelic']['application_monitoring']['daemon']['ssl_ca_bundle'] = nil 51 | default['newrelic']['application_monitoring']['daemon']['pidfile'] = nil 52 | default['newrelic']['application_monitoring']['daemon']['location'] = nil 53 | default['newrelic']['application_monitoring']['daemon']['collector_host'] = nil 54 | default['newrelic']['application_monitoring']['daemon']['dont_launch'] = nil 55 | default['newrelic']['application_monitoring']['capture_params'] = nil 56 | default['newrelic']['application_monitoring']['cross_application_tracer']['enable'] = nil 57 | default['newrelic']['application_monitoring']['thread_profiler']['enable'] = nil 58 | default['newrelic']['application_monitoring']['labels'] = nil 59 | default['newrelic']['application_monitoring']['ignored_params'] = nil 60 | default['newrelic']['application_monitoring']['error_collector']['enable'] = nil 61 | default['newrelic']['application_monitoring']['error_collector']['ignore_errors'] = nil 62 | default['newrelic']['application_monitoring']['error_collector']['ignore_classes'] = nil 63 | default['newrelic']['application_monitoring']['error_collector']['ignore_status_codes'] = nil 64 | default['newrelic']['application_monitoring']['error_collector']['record_database_errors'] = nil 65 | default['newrelic']['application_monitoring']['error_collector']['prioritize_api_errors'] = nil 66 | default['newrelic']['application_monitoring']['browser_monitoring']['auto_instrument'] = nil 67 | default['newrelic']['application_monitoring']['transaction_tracer']['enable'] = nil 68 | default['newrelic']['application_monitoring']['transaction_tracer']['threshold'] = nil 69 | default['newrelic']['application_monitoring']['transaction_tracer']['detail'] = nil 70 | default['newrelic']['application_monitoring']['transaction_tracer']['slow_sql'] = nil 71 | default['newrelic']['application_monitoring']['transaction_tracer']['stack_trace_threshold'] = nil 72 | default['newrelic']['application_monitoring']['transaction_tracer']['explain_threshold'] = nil 73 | default['newrelic']['application_monitoring']['transaction_tracer']['record_sql'] = nil 74 | default['newrelic']['application_monitoring']['transaction_tracer']['custom'] = nil 75 | default['newrelic']['application_monitoring']['framework'] = nil 76 | default['newrelic']['application_monitoring']['webtransaction']['name']['remove_trailing_path'] = nil 77 | default['newrelic']['application_monitoring']['webtransaction']['name']['functions'] = nil 78 | default['newrelic']['application_monitoring']['webtransaction']['name']['files'] = nil 79 | -------------------------------------------------------------------------------- /attributes/dotnet_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Attributes:: dotnet_agent 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | default['newrelic']['dotnet_agent']['https_download'] = nil 9 | default['newrelic']['dotnet_agent']['install_level'] = nil 10 | -------------------------------------------------------------------------------- /attributes/java_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Attributes:: java_agent 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | default['newrelic']['java_agent']['version'] = 'latest' 9 | default['newrelic']['java_agent']['install_dir'] = '/opt/newrelic/java' 10 | default['newrelic']['java_agent']['app_user'] = 'newrelic' 11 | default['newrelic']['java_agent']['app_group'] = 'newrelic' 12 | default['newrelic']['java_agent']['repository'] = 'https://download.newrelic.com/newrelic/java-agent/newrelic-agent' 13 | default['newrelic']['java_agent']['audit_mode'] = false 14 | default['newrelic']['java_agent']['log_file_count'] = 1 15 | default['newrelic']['java_agent']['log_limit_in_kbytes'] = 0 16 | default['newrelic']['java_agent']['log_daily'] = true 17 | default['newrelic']['java_agent']['agent_action'] = 'install' 18 | default['newrelic']['java_agent']['execute_agent_action'] = true 19 | default['newrelic']['java_agent']['enable_custom_tracing'] = false 20 | default['newrelic']['java_agent']['class_transformer_config'] = {} 21 | default['newrelic']['java_agent']['trim_stats'] = false 22 | # Example: 23 | # default['newrelic']['java_agent']['class_transformer_config'] = { 24 | # 'classloader_blacklist' => ['org.codehaus.groovy.runtime.callsite.CallSiteClassLoader'], 25 | # 'instrumentation_classes' => { 26 | # 'wildfly-8' => { 'enabled' => false }, 27 | # 'wildfly-8-CAT' => { 'enabled' => false }, 28 | # 'wildfly-8-PORT' => { 'enabled' => false } 29 | # } 30 | # } 31 | # 32 | default['newrelic']['java_agent']['app_location'] = node['newrelic']['java_agent']['install_dir'] 33 | default['newrelic']['java_agent']['template']['cookbook'] = 'newrelic' 34 | default['newrelic']['java_agent']['template']['source'] = 'agent/newrelic.yml.erb' 35 | -------------------------------------------------------------------------------- /attributes/nodejs_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Attributes:: nodejs_agent 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | default['newrelic']['nodejs_agent']['agent_action'] = 'install' 9 | default['newrelic']['nodejs_agent']['apps'] = [] 10 | default['newrelic']['nodejs_agent']['template']['cookbook'] = 'newrelic' 11 | default['newrelic']['nodejs_agent']['template']['source'] = 'agent/nodejs/newrelic.js.erb' 12 | default['newrelic']['nodejs_agent']['default_app_log_level'] = 'info' 13 | -------------------------------------------------------------------------------- /attributes/php_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Attributes:: php_agent 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | default['newrelic']['php_agent']['version'] = nil 9 | default['newrelic']['php_agent']['agent_action'] = nil 10 | default['newrelic']['php_agent']['install_silently'] = nil 11 | default['newrelic']['php_agent']['startup_mode'] = nil 12 | default['newrelic']['php_agent']['web_server']['service_name'] = nil 13 | default['newrelic']['php_agent']['web_server']['service_action'] = nil 14 | default['newrelic']['php_agent']['config_file'] = nil 15 | default['newrelic']['php_agent']['config_file_to_be_deleted'] = nil 16 | 17 | # @todo take out deprecated execute_php5enmod logic: use enable_module instead 18 | default['newrelic']['php_agent']['execute_php5enmod'] = nil 19 | 20 | default['newrelic']['php_agent']['enable_module'] = nil 21 | default['newrelic']['php_agent']['template']['cookbook_ini'] = nil 22 | default['newrelic']['php_agent']['template']['source_ini'] = nil 23 | default['newrelic']['php_agent']['template']['cookbook'] = nil 24 | default['newrelic']['php_agent']['template']['source'] = nil 25 | default['newrelic']['php_agent']['additional_config'] = {} 26 | 27 | # for non-package based installations (eg. ARM) 28 | default['newrelic']['php_agent']['repository'] = "https://download.newrelic.com/php_agent/release" 29 | -------------------------------------------------------------------------------- /attributes/python_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Attributes:: python_agent 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | default['newrelic']['python_agent']['agent_action'] = 'install' 9 | default['newrelic']['python_agent']['config_file'] = '/etc/newrelic/newrelic.ini' 10 | default['newrelic']['python_agent']['template']['cookbook'] = 'newrelic' 11 | default['newrelic']['python_agent']['template']['source'] = 'agent/python/newrelic.ini.erb' 12 | default['newrelic']['python_agent']['feature_flag'] = nil 13 | -------------------------------------------------------------------------------- /attributes/repository.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Attributes:: repository 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | default['newrelic']['repository']['key'] = 'http://download.newrelic.com/548C16BF.gpg' 9 | default['newrelic']['repository']['ssl_verify'] = true 10 | case node['platform_family'] 11 | when 'debian' 12 | default['newrelic']['repository']['uri'] = 'http://download.newrelic.com/debian/' 13 | default['newrelic']['repository']['distribution'] = 'newrelic' 14 | default['newrelic']['repository']['components'] = ['non-free'] 15 | when 'rhel', 'fedora', 'amazon' 16 | default['newrelic']['repository']['uri'] = 'http://download.newrelic.com/pub/newrelic/el5/$basearch/' 17 | default['newrelic']['repository']['proxy'] = node['newrelic']['proxy'] 18 | default['newrelic']['repository']['proxy_username'] = nil 19 | default['newrelic']['repository']['proxy_password'] = nil 20 | end 21 | 22 | # New Relic infrastructure repository 23 | default['newrelic']['repository']['infrastructure']['key'] = 'https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg' 24 | default['newrelic']['repository']['infrastructure']['ssl_verify'] = true 25 | case node['platform_family'] 26 | when 'debian' 27 | default['newrelic']['repository']['infrastructure']['uri'] = 'https://download.newrelic.com/infrastructure_agent/linux/apt' 28 | default['newrelic']['repository']['infrastructure']['components'] = ['main'] 29 | when 'rhel', 'fedora' 30 | rhel_version = node['platform_version'].to_i 31 | default['newrelic']['repository']['infrastructure']['uri'] = "https://download.newrelic.com/infrastructure_agent/linux/yum/el/#{rhel_version}/x86_64" 32 | when 'amazon' 33 | case node['platform_version'].to_i 34 | when 2 35 | rhel_version = 7 36 | when 2013, 2014, 2015, 2016, 2017, 2018 37 | rhel_version = 6 38 | end 39 | default['newrelic']['repository']['infrastructure']['uri'] = "https://download.newrelic.com/infrastructure_agent/linux/yum/el/#{rhel_version}/x86_64" 40 | end 41 | -------------------------------------------------------------------------------- /attributes/ruby_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Attributes:: ruby_agent 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | default['newrelic']['ruby_agent']['agent_action'] = 'install' 9 | default['newrelic']['ruby_agent']['version'] = 'latest' 10 | default['newrelic']['ruby_agent']['install_dir'] = '' 11 | default['newrelic']['ruby_agent']['app_user'] = 'newrelic' 12 | default['newrelic']['ruby_agent']['app_group'] = 'newrelic' 13 | default['newrelic']['ruby_agent']['audit_mode'] = false 14 | default['newrelic']['ruby_agent']['log_file_count'] = 1 15 | default['newrelic']['ruby_agent']['log_limit_in_kbytes'] = 0 16 | default['newrelic']['ruby_agent']['log_daily'] = true 17 | default['newrelic']['ruby_agent']['template']['cookbook'] = 'newrelic' 18 | default['newrelic']['ruby_agent']['template']['source'] = 'agent/newrelic.yml.erb' 19 | default['newrelic']['java_agent']['trim_stats'] = false 20 | -------------------------------------------------------------------------------- /attributes/server_monitor_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Attributes:: server_monitor_agent 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | default['newrelic']['server_monitor_agent']['agent_action'] = nil 9 | 10 | default['newrelic']['server_monitor_agent']['service_notify_action'] = nil 11 | default['newrelic']['server_monitor_agent']['service_actions'] = nil 12 | default['newrelic']['server_monitor_agent']['config_file_user'] = nil 13 | default['newrelic']['server_monitor_agent']['windows_version'] = nil 14 | default['newrelic']['server_monitor_agent']['windows64_checksum'] = nil 15 | default['newrelic']['server_monitor_agent']['windows32_checksum'] = nil 16 | default['newrelic']['server_monitor_agent']['template']['cookbook'] = nil 17 | default['newrelic']['server_monitor_agent']['template']['source'] = nil 18 | -------------------------------------------------------------------------------- /libraries/helpers.rb: -------------------------------------------------------------------------------- 1 | # NewRelic helpers 2 | module NewRelic 3 | # helpers module 4 | module Helpers 5 | def newrelic_repository 6 | install_newrelic_repo 7 | end 8 | 9 | def newrelic_repository_infrastructure 10 | install_newrelic_repo_infrastructure 11 | end 12 | 13 | def check_license 14 | # check license key provided 15 | raise 'The NewRelic key is required.' if new_resource.license.nil? 16 | end 17 | 18 | def install_newrelic_repo 19 | case node['platform_family'] 20 | when 'debian' 21 | install_newrelic_repo_debian 22 | when 'rhel', 'fedora', 'amazon' 23 | install_newrelic_repo_rhel 24 | end 25 | end 26 | 27 | def install_newrelic_repo_debian 28 | apt_repository 'newrelic' do 29 | uri node['newrelic']['repository']['uri'] 30 | distribution node['newrelic']['repository']['distribution'] 31 | components node['newrelic']['repository']['components'] 32 | key node['newrelic']['repository']['key'] 33 | end 34 | end 35 | 36 | def install_newrelic_repo_rhel 37 | yum_repository 'newrelic' do 38 | description 'New Relic packages for Enterprise Linux 5 - $basearch' 39 | baseurl node['newrelic']['repository']['uri'] 40 | gpgkey node['newrelic']['repository']['key'] 41 | sslverify node['newrelic']['repository']['ssl_verify'] 42 | proxy node['newrelic']['repository']['proxy'] unless node['newrelic']['repository']['proxy'].nil? 43 | proxy_username node['newrelic']['repository']['proxy_username'] unless node['newrelic']['repository']['proxy_username'].nil? 44 | proxy_password node['newrelic']['repository']['proxy_password'] unless node['newrelic']['repository']['proxy_password'].nil? 45 | end 46 | end 47 | 48 | def install_newrelic_repo_infrastructure 49 | case node['platform_family'] 50 | when 'debian' 51 | install_newrelic_repo_infrastructure_debian 52 | when 'rhel', 'fedora', 'amazon' 53 | install_newrelic_repo_infrastructure_rhel 54 | end 55 | end 56 | 57 | def install_newrelic_repo_infrastructure_debian 58 | apt_repository 'newrelic-infra' do 59 | uri node['newrelic']['repository']['infrastructure']['uri'] 60 | distribution deb_version_to_codename(node['platform_version'].to_i) 61 | components node['newrelic']['repository']['infrastructure']['components'] 62 | key node['newrelic']['repository']['infrastructure']['key'] 63 | end 64 | end 65 | 66 | def install_newrelic_repo_infrastructure_rhel 67 | yum_repository 'newrelic-infra' do 68 | description 'New Relic Infrastructure' 69 | baseurl node['newrelic']['repository']['infrastructure']['uri'] 70 | gpgkey node['newrelic']['repository']['infrastructure']['key'] 71 | sslverify node['newrelic']['repository']['infrastructure']['ssl_verify'] 72 | gpgcheck true 73 | repo_gpgcheck true 74 | end 75 | end 76 | 77 | def deb_version_to_codename(version) 78 | deb_version_to_codename = { 79 | 7 => 'wheezy', 80 | 8 => 'jessie', 81 | 9 => 'stretch', 82 | 10 => 'buster', 83 | 12 => 'precise', 84 | 14 => 'trusty', 85 | 16 => 'xenial', 86 | 18 => 'bionic', 87 | 20 => 'focal', 88 | 22 => 'jammy', 89 | 24 => 'noble' 90 | } 91 | 92 | deb_version_to_codename[version] 93 | end 94 | 95 | def directory_exists?(dir) 96 | return false unless ::File.exist?(dir) 97 | true 98 | end 99 | end 100 | end 101 | -------------------------------------------------------------------------------- /libraries/matchers.rb: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libraries/newrelic.rb: -------------------------------------------------------------------------------- 1 | # NewRelic module 2 | module NewRelic 3 | def self.license(node) 4 | node['newrelic'] && node['newrelic']['license'] 5 | end 6 | 7 | def self.server_monitoring_license(node) 8 | node['newrelic'] && node['newrelic']['server_monitoring'] && node['newrelic']['server_monitoring']['license'] || license(node) 9 | end 10 | 11 | def self.application_monitoring_license(node) 12 | node['newrelic'] && node['newrelic']['application_monitoring'] && node['newrelic']['application_monitoring']['license'] || license(node) 13 | end 14 | 15 | def self.to_boolean(variable) 16 | if variable.is_a?(TrueClass) || variable.is_a?(FalseClass) 17 | variable 18 | else 19 | variable == 'true' || variable == 1 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /libraries/server_monitor_helpers.rb: -------------------------------------------------------------------------------- 1 | require 'net/http' 2 | require 'net/https' 3 | require 'json' 4 | 5 | # NewRelic module 6 | module NewRelic 7 | # Server monitor helper module 8 | module ServerMonitorHelpers 9 | def update_alert_policy(alert_policy_id, hostname = nil) 10 | api_path = 'https://api.newrelic.com/v2' 11 | api_alert_path = api_path + '/alert_policies' 12 | new_server_ids = [] 13 | 14 | # Get the current list of server ids 15 | result_policy = make_api_get_request("#{api_alert_path}/#{alert_policy_id}.json") 16 | current_server_ids = JSON.parse(result_policy.body)['alert_policy']['links']['servers'] 17 | 18 | # Loop 60 times waiting for the installed server to be registered on service or timeout 19 | 60.times.each do |i| 20 | hostname = Mixlib::ShellOut.new('hostname').run_command.stdout if hostname.nil? 21 | 22 | result_servers = make_api_get_request("#{api_path}/servers.json?filter[name]=#{hostname}") 23 | 24 | if result_servers.is_a?(Net::HTTPSuccess) 25 | new_server_ids = JSON.parse(result_servers.body)['servers'].map { |s| s['id'] } 26 | else 27 | exit(-1) if i == 59 28 | sleep(1) 29 | end 30 | end 31 | 32 | result_server_put = make_api_put_request( 33 | "#{api_alert_path}/#{alert_policy_id}.json", 34 | JSON.generate( 35 | alert_policy: { 36 | links: { 37 | servers: new_server_ids + current_server_ids, 38 | }, 39 | } 40 | ) 41 | ) 42 | 43 | exit(-1) unless result_server_put.is_a?(Net::HTTPSuccess) 44 | end 45 | 46 | def make_api_get_request(url) 47 | url = URI.parse(url) 48 | req = Net::HTTP::Get.new(url.to_s) 49 | make_api_request(url, req) 50 | end 51 | 52 | def make_api_put_request(url, body) 53 | url = URI.parse(url) 54 | req = Net::HTTP::Put.new(url.to_s) 55 | req.body = body 56 | make_api_request(url, req) 57 | end 58 | 59 | def make_api_request(url, req) 60 | req['X-Api-Key'] = node['newrelic']['api_key'] 61 | req['Content-Type'] = 'application/json' 62 | Net::HTTP.start(url.host, url.port, use_ssl: (url.scheme == 'https')) do |http| 63 | http.request(req) 64 | end 65 | end 66 | end 67 | end 68 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | name 'newrelic' 2 | maintainer 'David Joos' 3 | maintainer_email 'development@davidjoos.com' 4 | license 'MIT' 5 | description 'Installs/Configures New Relic' 6 | version '2.45.6' 7 | chef_version '>= 0.10.0' 8 | 9 | %w(debian ubuntu redhat centos fedora scientific amazon windows smartos oracle).each do |os| 10 | supports os 11 | end 12 | 13 | source_url 'https://github.com/djoos-cookbooks/newrelic' 14 | issues_url 'https://github.com/djoos-cookbooks/newrelic/issues' 15 | 16 | depends 'curl' 17 | depends 'apt' 18 | depends 'yum' 19 | -------------------------------------------------------------------------------- /providers/agent_dotnet.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Recipe:: agent_dotnet 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | # include helper methods 9 | include NewRelic::Helpers 10 | 11 | action :install do 12 | check_license 13 | install_newrelic 14 | end 15 | 16 | action :remove do 17 | remove_newrelic 18 | end 19 | 20 | def install_newrelic 21 | windows_package 'Install New Relic .NET Agent' do 22 | source new_resource.https_download 23 | options "/qb NR_LICENSE_KEY=#{new_resource.license} INSTALLLEVEL=#{new_resource.install_level}" 24 | installer_type :msi 25 | action :install 26 | not_if { ::File.exist?('C:\\Program Files\\New Relic\\.NET Agent') } 27 | end 28 | 29 | template "#{new_resource.config_dir}/newrelic.config" do 30 | cookbook new_resource.cookbook 31 | source new_resource.source 32 | variables( 33 | resource: new_resource 34 | ) 35 | sensitive true 36 | end 37 | end 38 | 39 | def remove_newrelic 40 | windows_package 'Remove New Relic .NET Agent' do 41 | source new_resource.https_download 42 | action :remove 43 | end 44 | end 45 | -------------------------------------------------------------------------------- /providers/agent_infrastructure.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Provider:: agent_infrastructure 4 | # 5 | # Copyright:: (c) 2017, David Joos 6 | # 7 | 8 | # include helper methods 9 | include NewRelic::Helpers 10 | 11 | action :install do 12 | check_license 13 | newrelic_repository_infrastructure 14 | case node['platform_family'] 15 | when 'debian', 'rhel', 'amazon' 16 | install_newrelic_infrastructure_service_linux 17 | when 'windows' 18 | install_newrelic_infrastructure_service_windows 19 | end 20 | end 21 | 22 | def install_newrelic_infrastructure_service_linux 23 | # lay down newrelic-infra agent config 24 | template '/etc/newrelic-infra.yml' do 25 | cookbook new_resource.template_cookbook 26 | source new_resource.template_source 27 | owner 'root' 28 | group 'root' 29 | mode '0600' 30 | variables( 31 | resource: new_resource 32 | ) 33 | sensitive true 34 | notifies :restart, 'service[newrelic-infra]', :delayed 35 | end 36 | 37 | # install the newrelic infrastructure agent 38 | package 'newrelic-infra' do 39 | action new_resource.action 40 | version new_resource.version unless new_resource.version.nil? 41 | end 42 | 43 | # install the newrelic infrastructure on-host integration 44 | if new_resource.on_host_integrations_enable 45 | package 'newrelic-infra-integrations' do 46 | action new_resource.action 47 | end 48 | end 49 | 50 | service_provider = linux_service_provider 51 | 52 | # setup newrelic infrastructure service 53 | service 'newrelic-infra' do 54 | provider service_provider unless service_provider.nil? 55 | action new_resource.service_actions 56 | end 57 | end 58 | 59 | def linux_service_provider 60 | service_provider = Chef::Provider::Service::Systemd 61 | 62 | # upstart workaround(s) 63 | case node['platform_family'] 64 | when 'amazon' 65 | # Amazon 1.x version format is 'YEAR.MONTH' 66 | if node['platform_version'].to_i > 2000 67 | service_provider = Chef::Provider::Service::Upstart 68 | end 69 | when 'rhel' 70 | if node['platform_version'] =~ /^6/ 71 | service_provider = Chef::Provider::Service::Upstart 72 | end 73 | end 74 | 75 | if node['platform'] == 'ubuntu' 76 | if node['platform_version'].to_f < 16.04 77 | service_provider = Chef::Provider::Service::Upstart 78 | end 79 | end 80 | 81 | service_provider 82 | end 83 | 84 | def install_newrelic_infrastructure_service_windows 85 | windows_package 'newrelic-infra' do 86 | source "https://download.newrelic.com/infrastructure_agent/windows/newrelic-infra.#{new_resource.windows_version}.msi" 87 | installer_type :msi 88 | version new_resource.windows_version 89 | action new_resource.action 90 | checksum new_resource.windows_checksum 91 | end 92 | 93 | # lay down newrelic-infra agent config 94 | template 'C:\Program Files\New Relic\newrelic-infra\newrelic-infra.yml' do 95 | cookbook new_resource.template_cookbook 96 | source new_resource.template_source 97 | variables( 98 | resource: new_resource 99 | ) 100 | sensitive true 101 | notifies :restart, 'service[newrelic-infra]', :delayed 102 | end 103 | 104 | # setup newrelic-infra service 105 | service 'newrelic-infra' do 106 | action new_resource.service_actions 107 | end 108 | end 109 | -------------------------------------------------------------------------------- /providers/agent_java.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Recipe:: agent_java 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | require 'uri' 9 | 10 | # include helper methods 11 | include NewRelic::Helpers 12 | 13 | action :install do 14 | # Check license key provided 15 | check_license 16 | create_install_directory 17 | agent_jar 18 | generate_agent_config 19 | allow_app_group_write_to_log_file_path 20 | install_newrelic 21 | end 22 | 23 | action :remove do 24 | remove_newrelic 25 | end 26 | 27 | def create_install_directory 28 | directory new_resource.install_dir do 29 | owner new_resource.app_user 30 | group new_resource.app_group 31 | recursive true 32 | mode '0775' 33 | action :create 34 | end 35 | end 36 | 37 | def agent_jar 38 | package 'unzip' 39 | 40 | version = if new_resource.version == 'latest' 41 | 'current' 42 | else 43 | new_resource.version 44 | end 45 | 46 | filename = if new_resource.version == 'latest' 47 | 'newrelic-java.zip' 48 | else 49 | "newrelic-java-#{new_resource.version}.zip" 50 | end 51 | 52 | remote_file "#{new_resource.install_dir}/newrelic.zip" do 53 | source "#{new_resource.repository}/#{version}/#{filename}" 54 | user new_resource.app_user 55 | group new_resource.app_group 56 | mode '0664' 57 | action :create 58 | notifies :run, 'execute[newrelic-extract-jar]', :immediately 59 | end 60 | 61 | execute 'newrelic-extract-jar' do 62 | cwd new_resource.install_dir 63 | user new_resource.app_user 64 | group new_resource.app_group 65 | command 'unzip -oj newrelic.zip newrelic/newrelic.jar' 66 | action :nothing 67 | end 68 | end 69 | 70 | def generate_agent_config 71 | template "#{new_resource.install_dir}/newrelic.yml" do 72 | cookbook new_resource.template_cookbook 73 | source new_resource.template_source 74 | owner new_resource.app_user 75 | group new_resource.app_group 76 | mode '0644' 77 | variables( 78 | resource: new_resource 79 | ) 80 | sensitive true 81 | action :create 82 | end 83 | end 84 | 85 | def allow_app_group_write_to_log_file_path 86 | path = new_resource.logfile_path 87 | until path.nil? || path.empty? || path == ::File::SEPARATOR 88 | directory path do 89 | group new_resource.app_group 90 | mode '0775' 91 | action :create 92 | end 93 | path = ::File.dirname(path) 94 | end 95 | end 96 | 97 | def install_newrelic 98 | jar_file = 'newrelic.jar' 99 | app_location = if new_resource.app_location.nil? 100 | new_resource.install_dir 101 | else 102 | new_resource.app_location 103 | end 104 | execute "newrelic_install_#{jar_file}" do 105 | cwd new_resource.install_dir 106 | command "sudo java -jar newrelic.jar -s #{app_location} #{new_resource.agent_action}" 107 | only_if { new_resource.execute_agent_action == true } 108 | end 109 | end 110 | 111 | def remove_newrelic 112 | app_location = if new_resource.app_location.nil? 113 | new_resource.install_dir 114 | else 115 | new_resource.app_location 116 | end 117 | if app_location == '/opt/newrelic/java' 118 | execute 'newrelic-remove-default' do 119 | command 'sudo rm -rf /opt/newrelic' 120 | only_if { ::File.exist?('/opt/newrelic/newrelic.yml') } 121 | end 122 | else 123 | execute 'newrelic-remove' do 124 | command "sudo rm -rf #{app_location}/newrelic" 125 | only_if { ::File.exist?("#{app_location}/newrelic/newrelic.yml") } 126 | end 127 | end 128 | end 129 | -------------------------------------------------------------------------------- /providers/agent_nodejs.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Provider:: agent_nodejs 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | # include helper methods 9 | include NewRelic::Helpers 10 | 11 | action :install do 12 | # Check license key provided 13 | check_license 14 | raise 'Cannot install newrelic nodejs agent. Missing npm. Please ensure nodejs and npm are installed before calling this resource.' unless npm_installed? 15 | raise "Cannot install newrelic nodejs agent. app_path #{new_resource.app_path} directory does not exist." unless directory_exists?(new_resource.app_path) 16 | newrelic_repository 17 | install_nodejs_agent 18 | end 19 | 20 | action :remove do 21 | execute 'npm-uninstall-nodejs_agent' do 22 | cwd new_resource.app_path 23 | command 'npm uninstall newrelic' 24 | end 25 | end 26 | 27 | def install_nodejs_agent 28 | execute 'npm-install-nodejs_agent' do 29 | cwd new_resource.app_path 30 | command "npm install newrelic@#{new_resource.version}" 31 | end 32 | 33 | template "#{new_resource.app_path}/newrelic.js" do 34 | cookbook new_resource.cookbook 35 | source new_resource.source 36 | variables( 37 | resource: new_resource 38 | ) 39 | sensitive true 40 | end 41 | end 42 | 43 | def npm_installed? 44 | # check if npm is installed 45 | cmd = Mixlib::ShellOut.new('which npm') 46 | cmd.run_command 47 | 48 | return true unless cmd.error? 49 | false 50 | end 51 | -------------------------------------------------------------------------------- /providers/agent_php.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Provider:: agent_php 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | # include helper methods 9 | include NewRelic::Helpers 10 | 11 | action :install do 12 | # Check license key provided 13 | check_license 14 | 15 | # check config_file attribute value 16 | raise "Please specify the path to your New Relic php agent config file (#{new_resource.config_file})" if new_resource.config_file.nil? 17 | 18 | current_working_directory = nil 19 | 20 | if arm? 21 | dir = Chef::Config[:file_cache_path] 22 | filename = "newrelic-php5-#{new_resource.version}-linux" 23 | 24 | newrelic_tar(dir, new_resource.version, filename) 25 | 26 | current_working_directory = "#{dir}/#{filename}" 27 | else 28 | newrelic_repository 29 | newrelic_php5_broken 30 | newrelic_php_agent 31 | end 32 | 33 | webserver_service if new_resource.service_name 34 | 35 | newrelic_install(current_working_directory) 36 | newrelic_daemon 37 | newrelic_php_enable_module 38 | generate_agent_config 39 | delete_config_file 40 | startup_mode_config 41 | stub_service 42 | 43 | # https://newrelic.com/docs/php/newrelic-daemon-startup-modes 44 | Chef::Log.info "newrelic-daemon startup mode: #{new_resource.startup_mode}" 45 | end 46 | 47 | action :remove do 48 | newrelic_remove 49 | end 50 | 51 | def newrelic_php5_broken 52 | # the older version (3.0) had a bug in the init scripts that when it shut down the daemon 53 | # it would also kill dpkg as it was trying to upgrade let's remove the old package before continuing 54 | package 'newrelic-php5-broken' do 55 | # set package_name attribute explicitly as the name attribute is *not* the correct package name 56 | # so not to clash with the package resource block below... (see issue #109 for more information) 57 | package_name 'newrelic-php5' 58 | action :remove 59 | version '3.0.5.95' 60 | end 61 | end 62 | 63 | def newrelic_php_agent 64 | # install/update latest php agent 65 | package 'newrelic-php5' do 66 | action new_resource.action 67 | notifies :run, 'execute[newrelic-install]', :immediately 68 | version new_resource.version 69 | end 70 | end 71 | 72 | def newrelic_tar(dir, version, filename, extension="tar.gz") 73 | file = "#{filename}.#{extension}" 74 | 75 | remote_file "#{dir}/#{filename}.tar.gz" do 76 | source "#{new_resource.repository}/#{version}/#{file}" 77 | owner 'root' 78 | group 'root' 79 | mode '0664' 80 | action :create 81 | notifies :run, 'execute[newrelic-extract-archive]', :immediately 82 | end 83 | 84 | execute 'newrelic-extract-archive' do 85 | cwd dir 86 | command "tar xvfz #{file}" 87 | notifies :run, 'execute[newrelic-install]', :immediately 88 | end 89 | end 90 | 91 | def newrelic_install(current_working_directory = nil) 92 | install_silently = new_resource.install_silently ? 'true' : 'false' 93 | install_command = arm? ? './newrelic-install install' : 'newrelic-install install' 94 | 95 | execute 'newrelic-install' do 96 | cwd current_working_directory unless current_working_directory.nil? 97 | command install_command 98 | if install_silently 99 | environment( 100 | 'NR_INSTALL_SILENT' => '1' 101 | ) 102 | end 103 | action :nothing 104 | notifies new_resource.service_action, "service[#{new_resource.service_name}]", :delayed if new_resource.service_name 105 | end 106 | end 107 | 108 | def newrelic_daemon 109 | service 'newrelic-daemon' do 110 | supports status: true, start: true, stop: true, restart: true 111 | end 112 | end 113 | 114 | def webserver_service 115 | service new_resource.service_name do 116 | supports status: true, start: true, stop: true, restart: true, reload: true 117 | end 118 | end 119 | 120 | def newrelic_php_enable_module 121 | execute 'newrelic-enable-module' do 122 | command "#{enable_module_command} newrelic" 123 | action :nothing 124 | only_if { enable_module == true && !module_enabled? && !enable_module_command.nil? } 125 | end 126 | end 127 | 128 | def enable_module 129 | enable_module = new_resource.enable_module 130 | 131 | unless new_resource.execute_php5enmod.nil? 132 | Chef::Log.warn "The 'execute_php5enmod'-attribute has been deprecated. Please make use of the 'enable_module' attribute instead." 133 | enable_module = new_resource.execute_php5enmod 134 | end 135 | 136 | enable_module 137 | end 138 | 139 | def enable_module_command 140 | cmd = Mixlib::ShellOut.new('php -r "echo PHP_MAJOR_VERSION;"') 141 | cmd.run_command 142 | php_version_major = cmd.stdout.to_i 143 | 144 | cmd = Mixlib::ShellOut.new('php -r "echo PHP_MINOR_VERSION;"') 145 | cmd.run_command 146 | php_version_minor = cmd.stdout.to_i 147 | 148 | if php_version_major >= 7 149 | 'phpenmod' 150 | elsif php_version_major == 5 && php_version_minor > 3 151 | 'php5enmod' 152 | end 153 | end 154 | 155 | def module_enabled? 156 | cmd = Mixlib::ShellOut.new('php --modules') 157 | cmd.run_command 158 | cmd.stdout.lines.grep(/^newrelic$/).any? 159 | end 160 | 161 | def generate_agent_config 162 | # configure New Relic INI file and set the daemon related options (documented at /usr/lib/newrelic-php5/scripts/newrelic.ini.template) 163 | # and reload/restart (determined by service_action) the web server in order to pick up the new settings 164 | template new_resource.config_file do 165 | cookbook new_resource.cookbook_ini 166 | source new_resource.source_ini 167 | owner 'root' 168 | group 'root' 169 | mode '0644' 170 | variables( 171 | resource: new_resource 172 | ) 173 | sensitive true 174 | action :create 175 | 176 | notifies :run, 'execute[newrelic-enable-module]', :immediately if enable_module == true 177 | notifies new_resource.service_action, "service[#{new_resource.service_name}]", :delayed if new_resource.service_name 178 | end 179 | end 180 | 181 | def delete_config_file 182 | if new_resource.config_file_to_be_deleted 183 | # delete the New Relic PHP agent-generated config file 184 | # see issues #119 and #143 185 | file new_resource.config_file_to_be_deleted do 186 | action :delete 187 | end 188 | else 189 | Chef::Log.warn 'You\'ve opted not to delete any PHP agent-generated config file.' 190 | end 191 | end 192 | 193 | def startup_mode_config 194 | case new_resource.startup_mode 195 | when 'agent' 196 | # agent startup mode 197 | # ensure that the daemon isn't currently running 198 | # only stop the daemon if it has not been run by the agent (with a newrelic.cfg) 199 | service 'newrelic-daemon' do 200 | action %i(disable stop) # stops the service if it's running and disables it from starting at system boot time 201 | only_if { ::File.exist?('/etc/newrelic/newrelic.cfg') } 202 | end 203 | # ensure that the file /etc/newrelic/newrelic.cfg does not exist if it does, move it aside (or remove it) 204 | execute 'newrelic-backup-cfg' do 205 | command 'mv /etc/newrelic/newrelic.cfg /etc/newrelic/newrelic.cfg.external' 206 | only_if { ::File.exist?('/etc/newrelic/newrelic.cfg') } 207 | end 208 | # ensure that the file /etc/newrelic/upgrade_please.key does not exist if it does, move it aside (or remove it) 209 | execute 'newrelic-backup-key' do 210 | command 'mv /etc/newrelic/upgrade_please.key /etc/newrelic/upgrade_please.key.external' 211 | only_if { ::File.exist?('/etc/newrelic/upgrade_please.key') } 212 | end 213 | when 'external' 214 | # external startup mode 215 | # configure proxy daemon settings 216 | template '/etc/newrelic/newrelic.cfg' do 217 | cookbook new_resource.cookbook 218 | source new_resource.source 219 | owner 'root' 220 | group 'root' 221 | mode '0644' 222 | variables( 223 | resource: new_resource 224 | ) 225 | action :create 226 | notifies :restart, 'service[newrelic-daemon]', :immediately 227 | notifies new_resource.service_action, "service[#{new_resource.service_name}]", :delayed if new_resource.service_name 228 | end 229 | service 'newrelic-daemon' do 230 | action %i(enable start) # starts the service if it's not running and enables it to start at system boot time 231 | end 232 | else 233 | raise "#{new_resource.startup_mode} is not a valid newrelic-daemon startup mode." 234 | end 235 | end 236 | 237 | def newrelic_remove 238 | package 'newrelic-php5' do 239 | package_name 'newrelic-php5' 240 | action :remove 241 | end 242 | end 243 | 244 | def stub_service 245 | # only used for ChefSpec-purposes 246 | # we don't want to redeclare node['newrelic']['php_agent']['web_server']['service_name'] (eg. apache2) 247 | # so decided to add a 'stub_service' to the resource collection which can then be used in the unit test(s) 248 | service 'stub_service' do 249 | action :nothing 250 | end 251 | end 252 | -------------------------------------------------------------------------------- /providers/agent_python.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Provider:: agent_python 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | # include helper methods 9 | include NewRelic::Helpers 10 | 11 | action :install do 12 | # Check license key provided 13 | check_license 14 | newrelic_repository 15 | install_python_agent 16 | create_config_dir 17 | generate_agent_config 18 | end 19 | 20 | action :remove do 21 | newrelic_python_agent = 'newrelic' 22 | 23 | execute 'remove_python_agent' do 24 | command "pip uninstall #{newrelic_python_agent}" 25 | only_if "pip list | grep #{newrelic_python_agent}" 26 | end 27 | end 28 | 29 | def install_python_agent 30 | if node['platform_family'] == 'debian' && node['platform_version'] == '20.04' 31 | package 'python3-pip' 32 | else 33 | package 'python-pip' 34 | end 35 | 36 | newrelic_python_agent = 'newrelic' 37 | 38 | execute 'install_python_agent' do 39 | command "pip install #{newrelic_python_agent}" 40 | not_if "pip list | grep #{newrelic_python_agent}" 41 | end 42 | end 43 | 44 | def generate_agent_config 45 | template new_resource.config_file do 46 | cookbook new_resource.cookbook 47 | source new_resource.source 48 | owner 'root' 49 | group 'root' 50 | mode '0644' 51 | variables( 52 | resource: new_resource 53 | ) 54 | sensitive true 55 | action :create 56 | end 57 | end 58 | 59 | def create_config_dir 60 | dir = ::File.dirname(new_resource.config_file) 61 | directory dir do 62 | owner 'root' 63 | group 'root' 64 | recursive true 65 | end 66 | end 67 | -------------------------------------------------------------------------------- /providers/agent_ruby.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Recipe:: agent_ruby 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | # include helper methods 9 | include NewRelic::Helpers 10 | 11 | action :install do 12 | # Check license key provided 13 | check_license 14 | create_install_directory 15 | install_newrelic 16 | generate_agent_config 17 | end 18 | 19 | action :remove do 20 | remove_newrelic 21 | end 22 | 23 | def create_install_directory 24 | directory new_resource.install_dir do 25 | owner new_resource.app_user 26 | group new_resource.app_group 27 | recursive true 28 | mode '0775' 29 | action :create 30 | end 31 | end 32 | 33 | def install_newrelic 34 | gem_package 'newrelic_rpm' do 35 | version new_resource.version unless new_resource.version == 'latest' 36 | action :install 37 | end 38 | end 39 | 40 | def generate_agent_config 41 | template "#{new_resource.install_dir}/newrelic.yml" do 42 | cookbook new_resource.template_cookbook 43 | source new_resource.template_source 44 | owner 'root' 45 | group 'root' 46 | mode '0644' 47 | variables( 48 | resource: new_resource 49 | ) 50 | sensitive true 51 | action :create 52 | end 53 | end 54 | 55 | def remove_newrelic 56 | execute "remove #{new_resource.install_dir}/newrelic.yml" do 57 | command "sudo rm #{new_resource.install_dir}/newrelic.yml" 58 | only_if { ::File.exist?("#{new_resource.install_dir}/newrelic.yml") } 59 | end 60 | gem_package 'newrelic_rpm' do 61 | action :remove 62 | end 63 | end 64 | -------------------------------------------------------------------------------- /providers/deployment.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Provider:: deployment 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | action :notify do 9 | key = new_resource.key 10 | 11 | # @todo take out deprecated api_key logic 12 | unless new_resource.api_key.nil? 13 | Chef::Log.warn "The 'api_key'-attribute has been deprecated. Please make use of the key and key_type attributes instead." 14 | key = new_resource.api_key 15 | end 16 | 17 | if key.nil? 18 | Chef::Log.fatal "The #{key_type} is required to notify New Relic of a deployment." 19 | end 20 | 21 | if new_resource.url && (new_resource.app_name || new_resource.app_id) 22 | Chef::Log.debug 'notify New Relic of deployment' 23 | 24 | data = [] 25 | 26 | data << if new_resource.key_type == 'license_key' 27 | '"x-license-key:' + key + '"' 28 | else 29 | '"x-api-key:' + key + '"' 30 | end 31 | 32 | unless new_resource.app_name.nil? 33 | data << '-d "deployment[app_name]=' + new_resource.app_name + '"' 34 | end 35 | 36 | unless new_resource.app_id.nil? 37 | data << '-d "deployment[app_id]=' + new_resource.app_id.to_s + '"' 38 | end 39 | 40 | unless new_resource.description.nil? 41 | data << '-d "deployment[description]=' + clean(new_resource.description) + '"' 42 | end 43 | 44 | unless new_resource.revision.nil? 45 | data << '-d "deployment[revision]=' + new_resource.revision + '"' 46 | end 47 | 48 | unless new_resource.changelog.nil? 49 | data << '-d "deployment[changelog]=' + clean(new_resource.changelog) + '"' 50 | end 51 | 52 | unless new_resource.user.nil? 53 | data << '-d "deployment[user]=' + new_resource.user + '"' 54 | end 55 | 56 | command_curl = "curl -H #{data.join(' ')} #{new_resource.url}" 57 | 58 | Chef::Log.debug "curl command: #{command_curl}" 59 | 60 | execute 'newrelic-deployment-notify' do 61 | command command_curl 62 | action :run 63 | end 64 | end 65 | end 66 | 67 | private 68 | 69 | def clean(string) 70 | string.tr('"', '\"').tr("'", "\'") 71 | end 72 | -------------------------------------------------------------------------------- /providers/server_monitor.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Provider:: server_monitor 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | # include helper methods 9 | include NewRelic::Helpers 10 | include NewRelic::ServerMonitorHelpers 11 | 12 | action :install do 13 | check_license 14 | newrelic_repository 15 | case node['platform_family'] 16 | when 'debian', 'rhel', 'fedora', 'amazon' 17 | install_newrelic_service_linux 18 | when 'windows' 19 | install_newrelic_service_windows 20 | end 21 | end 22 | 23 | action :remove do 24 | case node['platform_family'] 25 | when 'debian', 'rhel', 'fedora', 'amazon' 26 | remove_newrelic_service_linux 27 | when 'windows' 28 | remove_newrelic_service_windows 29 | end 30 | end 31 | 32 | def install_newrelic_service_linux 33 | package new_resource.service_name do 34 | action new_resource.action 35 | end 36 | # configure your New Relic license key 37 | template "#{new_resource.config_path}/nrsysmond.cfg" do 38 | cookbook new_resource.cookbook 39 | source new_resource.source 40 | owner new_resource.config_file_user 41 | group new_resource.config_file_group 42 | mode '0640' 43 | variables( 44 | resource: new_resource 45 | ) 46 | sensitive true 47 | notifies new_resource.service_notify_action, "service[#{new_resource.service_name}]" 48 | end 49 | service new_resource.service_name do 50 | supports status: true, start: true, stop: true, restart: true, enable: true 51 | action new_resource.service_actions 52 | end 53 | 54 | update_newrelic_alert_policy_linux(new_resource.alert_policy_id, new_resource.hostname) if new_resource.alert_policy_id 55 | end 56 | 57 | def install_newrelic_service_windows 58 | if node['kernel']['machine'] == 'x86_64' 59 | windows_package 'New Relic Server Monitor' do 60 | source "https://download.newrelic.com/windows_server_monitor/release/NewRelicServerMonitor_x64_#{new_resource.windows_version}.msi" 61 | options "/L*v install.log /qn NR_LICENSE_KEY=#{new_resource.license}" 62 | action new_resource.action 63 | version new_resource.windows_version 64 | checksum new_resource.windows64_checksum 65 | end 66 | else 67 | windows_package 'New Relic Server Monitor' do 68 | source "https://download.newrelic.com/windows_server_monitor/release/NewRelicServerMonitor_x86_#{new_resource.windows_version}.msi" 69 | options "/L*v install.log /qn NR_LICENSE_KEY=#{new_resource.license}" 70 | action new_resource.action 71 | version new_resource.windows_version 72 | checksum new_resource.windows32_checksum 73 | end 74 | end 75 | # on Windows service creation/startup is done by the installer 76 | end 77 | 78 | def remove_newrelic_service_linux 79 | update_newrelic_alert_policy_linux(new_resource.alert_policy_id, new_resource.hostname) if new_resource.alert_policy_id 80 | 81 | package new_resource.service_name do 82 | action new_resource.action 83 | end 84 | end 85 | 86 | def remove_newrelic_service_windows 87 | windows_package 'New Relic Server Monitor' do 88 | action new_resource.action 89 | end 90 | end 91 | 92 | def update_newrelic_alert_policy_linux(alert_policy_id, hostname = nil) 93 | ruby_block 'Move server to newrelic decommissioned policy' do 94 | block do 95 | update_alert_policy(alert_policy_id, hostname) 96 | end 97 | 98 | not_if do 99 | node['newrelic']['api_key'].empty? 100 | end 101 | end 102 | end 103 | -------------------------------------------------------------------------------- /providers/yml.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Provider:: yml 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | require 'uri' 9 | 10 | action :generate do 11 | template new_resource.yml_path do 12 | cookbook new_resource.template_cookbook 13 | source new_resource.template_source 14 | owner new_resource.owner 15 | group new_resource.group 16 | mode '0644' 17 | variables( 18 | resource: new_resource 19 | ) 20 | sensitive true 21 | action :create 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Recipe:: default 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | include_recipe 'newrelic::server_monitor_agent' 9 | -------------------------------------------------------------------------------- /recipes/dotnet_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Recipe:: dotnet_agent 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | newrelic_agent_dotnet 'Install' do 9 | https_download node['newrelic']['dotnet_agent']['https_download'] unless node['newrelic']['dotnet_agent']['https_download'].nil? 10 | install_level node['newrelic']['dotnet_agent']['install_level'] unless node['newrelic']['dotnet_agent']['install_level'].nil? 11 | license lazy { NewRelic.application_monitoring_license(node) } 12 | end 13 | -------------------------------------------------------------------------------- /recipes/infrastructure_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Recipe:: infrastructure_agent 4 | # 5 | # Copyright:: (c) 2017, David Joos 6 | # 7 | 8 | newrelic_agent_infrastructure 'Install' 9 | -------------------------------------------------------------------------------- /recipes/java_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Recipe:: java_agent 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | newrelic_agent_java 'Install' do 9 | license lazy { NewRelic.application_monitoring_license(node) } 10 | version node['newrelic']['java_agent']['version'] unless node['newrelic']['java_agent']['version'].nil? 11 | install_dir node['newrelic']['java_agent']['install_dir'] unless node['newrelic']['java_agent']['install_dir'].nil? 12 | repository node['newrelic']['java_agent']['repository'] unless node['newrelic']['java_agent']['repository'].nil? 13 | app_location node['newrelic']['java_agent']['app_location'] unless node['newrelic']['java_agent']['app_location'].nil? 14 | template_cookbook node['newrelic']['java_agent']['template_cookbook'] unless node['newrelic']['java_agent']['template_cookbook'].nil? 15 | template_source node['newrelic']['java_agent']['template_source'] unless node['newrelic']['java_agent']['template_source'].nil? 16 | enable_custom_tracing node['newrelic']['java_agent']['enable_custom_tracing'] unless node['newrelic']['java_agent']['enable_custom_tracing'].nil? 17 | enabled node['newrelic']['application_monitoring']['enabled'] unless node['newrelic']['application_monitoring']['enabled'].nil? 18 | app_name node['newrelic']['application_monitoring']['app_name'] unless node['newrelic']['application_monitoring']['app_name'].nil? 19 | high_security NewRelic.to_boolean(node['newrelic']['application_monitoring']['high_security']) unless node['newrelic']['application_monitoring']['high_security'].nil? 20 | app_user node['newrelic']['java_agent']['app_user'] unless node['newrelic']['java_agent']['app_user'].nil? 21 | app_group node['newrelic']['java_agent']['app_group'] unless node['newrelic']['java_agent']['app_group'].nil? 22 | logfile node['newrelic']['application_monitoring']['logfile'] unless node['newrelic']['application_monitoring']['logfile'].nil? 23 | logfile_path node['newrelic']['application_monitoring']['logfile_path'] unless node['newrelic']['application_monitoring']['logfile_path'].nil? 24 | loglevel node['newrelic']['application_monitoring']['loglevel'] unless node['newrelic']['application_monitoring']['loglevel'].nil? 25 | audit_mode node['newrelic']['java_agent']['audit_mode'] unless node['newrelic']['java_agent']['audit_mode'].nil? 26 | log_file_count node['newrelic']['java_agent']['log_file_count'] unless node['newrelic']['java_agent']['log_file_count'].nil? 27 | log_limit_in_kbytes node['newrelic']['java_agent']['log_limit_in_kbytes'] unless node['newrelic']['java_agent']['log_limit_in_kbytes'].nil? 28 | log_daily node['newrelic']['java_agent']['log_daily'] unless node['newrelic']['java_agent']['log_daily'].nil? 29 | daemon_ssl NewRelic.to_boolean(node['newrelic']['application_monitoring']['daemon']['ssl']) unless node['newrelic']['application_monitoring']['daemon']['ssl'].nil? 30 | daemon_proxy node['newrelic']['application_monitoring']['daemon']['proxy'] unless node['newrelic']['application_monitoring']['daemon']['proxy'].nil? 31 | daemon_proxy_host node['newrelic']['application_monitoring']['daemon']['proxy_host'] unless node['newrelic']['application_monitoring']['daemon']['proxy_host'].nil? 32 | daemon_proxy_port node['newrelic']['application_monitoring']['daemon']['proxy_port'] unless node['newrelic']['application_monitoring']['daemon']['proxy_port'].nil? 33 | daemon_proxy_user node['newrelic']['application_monitoring']['daemon']['proxy_user'] unless node['newrelic']['application_monitoring']['daemon']['proxy_user'].nil? 34 | daemon_proxy_password node['newrelic']['application_monitoring']['daemon']['proxy_password'] unless node['newrelic']['application_monitoring']['daemon']['proxy_password'].nil? 35 | distributed_tracing_enable node['newrelic']['java_agent']['distributed_tracing_enable'] unless node['newrelic']['java_agent']['distributed_tracing_enable'].nil? 36 | capture_params node['newrelic']['application_monitoring']['capture_params'] unless node['newrelic']['application_monitoring']['capture_params'].nil? 37 | ignored_params node['newrelic']['application_monitoring']['ignored_params'] unless node['newrelic']['application_monitoring']['ignored_params'].nil? 38 | transaction_tracer_enable node['newrelic']['application_monitoring']['transaction_tracer']['enable'] unless node['newrelic']['application_monitoring']['transaction_tracer']['enable'].nil? 39 | transaction_tracer_threshold node['newrelic']['application_monitoring']['transaction_tracer']['threshold'] unless node['newrelic']['application_monitoring']['transaction_tracer']['threshold'].nil? 40 | transaction_tracer_record_sql node['newrelic']['application_monitoring']['transaction_tracer']['record_sql'] unless node['newrelic']['application_monitoring']['transaction_tracer']['record_sql'].nil? 41 | transaction_tracer_stack_trace_threshold node['newrelic']['application_monitoring']['transaction_tracer']['stack_trace_threshold'] unless node['newrelic']['application_monitoring']['transaction_tracer']['stack_trace_threshold'].nil? 42 | transaction_tracer_slow_sql node['newrelic']['application_monitoring']['transaction_tracer']['slow_sql'] unless node['newrelic']['application_monitoring']['transaction_tracer']['slow_sql'].nil? 43 | transaction_tracer_explain_threshold node['newrelic']['application_monitoring']['transaction_tracer']['explain_threshold'] unless node['newrelic']['application_monitoring']['transaction_tracer']['explain_threshold'].nil? 44 | error_collector_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['error_collector']['enable']) unless node['newrelic']['application_monitoring']['error_collector']['enable'].nil? 45 | error_collector_ignore_errors node['newrelic']['application_monitoring']['error_collector']['ignore_errors'] unless node['newrelic']['application_monitoring']['error_collector']['ignore_errors'].nil? 46 | error_collector_ignore_classes node['newrelic']['application_monitoring']['error_collector']['ignore_classes'] unless node['newrelic']['application_monitoring']['error_collector']['ignore_classes'].nil? 47 | error_collector_ignore_status_codes node['newrelic']['application_monitoring']['error_collector']['ignore_status_codes'] unless node['newrelic']['application_monitoring']['error_collector']['ignore_status_codes'].nil? 48 | browser_monitoring_auto_instrument node['newrelic']['application_monitoring']['browser_monitoring']['auto_instrument'] unless node['newrelic']['application_monitoring']['browser_monitoring']['auto_instrument'].nil? 49 | cross_application_tracer_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['cross_application_tracer']['enable']) unless node['newrelic']['application_monitoring']['cross_application_tracer']['enable'].nil? 50 | thread_profiler_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['thread_profiler']['enable']) unless node['newrelic']['application_monitoring']['thread_profiler']['enable'].nil? 51 | class_transformer_config node['newrelic']['java_agent']['class_transformer_config'] unless node['newrelic']['java_agent']['class_transformer_config'].empty? 52 | labels node['newrelic']['application_monitoring']['labels'] unless node['newrelic']['application_monitoring']['labels'].nil? 53 | trim_stats node['newrelic']['java_agent']['trim_stats'] unless node['newrelic']['java_agent']['trim_stats'].nil? 54 | agent_action node['newrelic']['java_agent']['agent_action'] unless node['newrelic']['java_agent']['agent_action'].nil? 55 | execute_agent_action node['newrelic']['java_agent']['execute_agent_action'] unless node['newrelic']['java_agent']['execute_agent_action'].nil? 56 | circuitbreaker_enabled node['newrelic']['java_agent']['circuitbreaker_enabled'] unless node['newrelic']['java_agent']['circuitbreaker_enabled'].nil? 57 | circuitbreaker_memory_threshold node['newrelic']['java_agent']['circuitbreaker_memory_threshold'] unless node['newrelic']['java_agent']['circuitbreaker_memory_threshold'].nil? 58 | circuitbreaker_gc_cpu_threshold node['newrelic']['java_agent']['circuitbreaker_gc_cpu_threshold'] unless node['newrelic']['java_agent']['circuitbreaker_gc_cpu_threshold'].nil? 59 | end 60 | -------------------------------------------------------------------------------- /recipes/nodejs_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Recipe:: nodejs_agent 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | node['newrelic']['nodejs_agent']['apps'].each do |nodeapp| 9 | newrelic_agent_nodejs nodeapp['app_path'] do 10 | license lazy { NewRelic.application_monitoring_license(node) } 11 | version nodeapp['version'] unless nodeapp['version'].nil? 12 | app_name nodeapp['app_name'] unless nodeapp['app_name'].nil? 13 | app_log_level nodeapp['app_log_level'] unless nodeapp['app_log_level'].nil? 14 | app_log_filepath nodeapp['app_log_filepath'] unless nodeapp['app_log_filepath'].nil? 15 | capture_params nodeapp['capture_params'] unless nodeapp['capture_params'].nil? 16 | ignored_params nodeapp['ignored_params'] unless nodeapp['ignored_params'].nil? 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /recipes/php_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Recipe:: php_agent 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | newrelic_agent_php 'Install' do 9 | license lazy { NewRelic.application_monitoring_license(node) } 10 | version node['newrelic']['php_agent']['version'] unless node['newrelic']['php_agent']['version'].nil? 11 | config_file node['newrelic']['php_agent']['config_file'] unless node['newrelic']['php_agent']['config_file'].nil? 12 | startup_mode node['newrelic']['php_agent']['startup_mode'] unless node['newrelic']['php_agent']['startup_mode'].nil? 13 | app_name node['newrelic']['application_monitoring']['app_name'] unless node['newrelic']['application_monitoring']['app_name'].nil? 14 | high_security NewRelic.to_boolean(node['newrelic']['application_monitoring']['high_security']) unless node['newrelic']['application_monitoring']['high_security'].nil? 15 | install_silently node['newrelic']['php_agent']['install_silently'] unless node['newrelic']['php_agent']['install_silently'].nil? 16 | config_file_to_be_deleted node['newrelic']['php_agent']['config_file_to_be_deleted'] unless node['newrelic']['php_agent']['config_file_to_be_deleted'].nil? 17 | service_name node['newrelic']['php_agent']['web_server']['service_name'] unless node['newrelic']['php_agent']['web_server']['service_name'].nil? 18 | service_action node['newrelic']['php_agent']['web_server']['service_action'] unless node['newrelic']['php_agent']['web_server']['service_action'].nil? 19 | # @todo take out deprecated execute_php5enmod logic: use enable_module instead 20 | execute_php5enmod NewRelic.to_boolean(node['newrelic']['php_agent']['execute_php5enmod']) unless node['newrelic']['php_agent']['execute_php5enmod'].nil? 21 | enable_module NewRelic.to_boolean(node['newrelic']['php_agent']['enable_module']) unless node['newrelic']['php_agent']['enable_module'].nil? 22 | cookbook_ini node['newrelic']['php_agent']['template']['cookbook_ini'] unless node['newrelic']['php_agent']['template']['cookbook_ini'].nil? 23 | source_ini node['newrelic']['php_agent']['template']['source_ini'] unless node['newrelic']['php_agent']['template']['source_ini'].nil? 24 | cookbook node['newrelic']['php_agent']['template']['cookbook'] unless node['newrelic']['php_agent']['template']['cookbook'].nil? 25 | source node['newrelic']['php_agent']['template']['source'] unless node['newrelic']['php_agent']['template']['source'].nil? 26 | enabled node['newrelic']['application_monitoring']['enabled'] unless node['newrelic']['application_monitoring']['enabled'].nil? 27 | logfile node['newrelic']['application_monitoring']['logfile'] unless node['newrelic']['application_monitoring']['logfile'].nil? 28 | loglevel node['newrelic']['application_monitoring']['loglevel'] unless node['newrelic']['application_monitoring']['loglevel'].nil? 29 | daemon_logfile node['newrelic']['application_monitoring']['daemon']['logfile'] unless node['newrelic']['application_monitoring']['daemon']['logfile'].nil? 30 | daemon_loglevel node['newrelic']['application_monitoring']['daemon']['loglevel'] unless node['newrelic']['application_monitoring']['daemon']['loglevel'].nil? 31 | daemon_port node['newrelic']['application_monitoring']['daemon']['port'] unless node['newrelic']['application_monitoring']['daemon']['port'].nil? 32 | daemon_max_threads node['newrelic']['application_monitoring']['daemon']['max_threads'] unless node['newrelic']['application_monitoring']['daemon']['max_threads'].nil? 33 | daemon_ssl NewRelic.to_boolean(node['newrelic']['application_monitoring']['daemon']['ssl']) unless node['newrelic']['application_monitoring']['daemon']['ssl'].nil? 34 | daemon_ssl_ca_path node['newrelic']['application_monitoring']['daemon']['ssl_ca_path'] unless node['newrelic']['application_monitoring']['daemon']['ssl_ca_path'].nil? 35 | daemon_ssl_ca_bundle node['newrelic']['application_monitoring']['daemon']['ssl_ca_bundle'] unless node['newrelic']['application_monitoring']['daemon']['ssl_ca_bundle'].nil? 36 | daemon_proxy node['newrelic']['application_monitoring']['daemon']['proxy'] unless node['newrelic']['application_monitoring']['daemon']['proxy'].nil? 37 | daemon_pidfile node['newrelic']['application_monitoring']['daemon']['pidfile'] unless node['newrelic']['application_monitoring']['daemon']['pidfile'].nil? 38 | daemon_location node['newrelic']['application_monitoring']['daemon']['location'] unless node['newrelic']['application_monitoring']['daemon']['location'].nil? 39 | daemon_collector_host node['newrelic']['application_monitoring']['daemon']['collector_host'] unless node['newrelic']['application_monitoring']['daemon']['collector_host'].nil? 40 | daemon_dont_launch node['newrelic']['application_monitoring']['daemon']['dont_launch'] unless node['newrelic']['application_monitoring']['daemon']['dont_launch'].nil? 41 | distributed_tracing_enabled NewRelic.to_boolean(node['newrelic']['application_monitoring']['distributed_tracing_enabled']) unless node['newrelic']['application_monitoring']['distributed_tracing_enabled'].nil? 42 | distributed_tracing_exclude_newrelic_header NewRelic.to_boolean(node['newrelic']['application_monitoring']['distributed_tracing_exclude_newrelic_header']) unless node['newrelic']['application_monitoring']['distributed_tracing_exclude_newrelic_header'].nil? 43 | capture_params NewRelic.to_boolean(node['newrelic']['application_monitoring']['capture_params']) unless node['newrelic']['application_monitoring']['capture_params'].nil? 44 | ignored_params node['newrelic']['application_monitoring']['ignored_params'] unless node['newrelic']['application_monitoring']['ignored_params'].nil? 45 | error_collector_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['error_collector']['enable']) unless node['newrelic']['application_monitoring']['error_collector']['enable'].nil? 46 | error_collector_record_database_errors NewRelic.to_boolean(node['newrelic']['application_monitoring']['error_collector']['record_database_errors']) unless node['newrelic']['application_monitoring']['error_collector']['record_database_errors'].nil? 47 | error_collector_prioritize_api_errors NewRelic.to_boolean(node['newrelic']['application_monitoring']['error_collector']['prioritize_api_errors']) unless node['newrelic']['application_monitoring']['error_collector']['prioritize_api_errors'].nil? 48 | error_collector_ignore_errors node['newrelic']['application_monitoring']['error_collector']['ignore_errors'] unless node['newrelic']['application_monitoring']['error_collector']['ignore_errors'].nil? 49 | browser_monitoring_auto_instrument NewRelic.to_boolean(node['newrelic']['application_monitoring']['browser_monitoring']['auto_instrument']) unless node['newrelic']['application_monitoring']['browser_monitoring']['auto_instrument'].nil? 50 | transaction_tracer_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['transaction_tracer']['enable']) unless node['newrelic']['application_monitoring']['transaction_tracer']['enable'].nil? 51 | transaction_tracer_threshold node['newrelic']['application_monitoring']['transaction_tracer']['threshold'] unless node['newrelic']['application_monitoring']['transaction_tracer']['threshold'].nil? 52 | transaction_tracer_detail node['newrelic']['application_monitoring']['transaction_tracer']['detail'] unless node['newrelic']['application_monitoring']['transaction_tracer']['detail'].nil? 53 | transaction_tracer_slow_sql NewRelic.to_boolean(node['newrelic']['application_monitoring']['transaction_tracer']['slow_sql']) unless node['newrelic']['application_monitoring']['transaction_tracer']['slow_sql'].nil? 54 | transaction_tracer_stack_trace_threshold node['newrelic']['application_monitoring']['transaction_tracer']['stack_trace_threshold'] unless node['newrelic']['application_monitoring']['transaction_tracer']['stack_trace_threshold'].nil? 55 | transaction_tracer_explain_threshold node['newrelic']['application_monitoring']['transaction_tracer']['explain_threshold'] unless node['newrelic']['application_monitoring']['transaction_tracer']['explain_threshold'].nil? 56 | transaction_tracer_record_sql node['newrelic']['application_monitoring']['transaction_tracer']['record_sql'] unless node['newrelic']['application_monitoring']['transaction_tracer']['record_sql'].nil? 57 | transaction_tracer_custom node['newrelic']['application_monitoring']['transaction_tracer']['custom'] unless node['newrelic']['application_monitoring']['transaction_tracer']['custom'].nil? 58 | framework node['newrelic']['application_monitoring']['framework'] unless node['newrelic']['application_monitoring']['framework'].nil? 59 | webtransaction_name_remove_trailing_path NewRelic.to_boolean(node['newrelic']['application_monitoring']['webtransaction']['name']['remove_trailing_path']) unless node['newrelic']['application_monitoring']['webtransaction']['name']['remove_trailing_path'].nil? 60 | webtransaction_name_functions node['newrelic']['application_monitoring']['webtransaction']['name']['functions'] unless node['newrelic']['application_monitoring']['webtransaction']['name']['functions'].nil? 61 | webtransaction_name_files node['newrelic']['application_monitoring']['webtransaction']['name']['files'] unless node['newrelic']['application_monitoring']['webtransaction']['name']['files'].nil? 62 | cross_application_tracer_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['cross_application_tracer']['enable']) unless node['newrelic']['application_monitoring']['cross_application_tracer']['enable'].nil? 63 | additional_config node['newrelic']['php_agent']['additional_config'] unless node['newrelic']['php_agent']['additional_config'].empty? 64 | end 65 | -------------------------------------------------------------------------------- /recipes/python_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Recipe:: python_agent 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | newrelic_agent_python 'new python agent' do 9 | license lazy { NewRelic.application_monitoring_license(node) } 10 | config_file node['newrelic']['python_agent']['config_file'] unless node['newrelic']['python_agent']['config_file'].nil? 11 | cookbook node['newrelic']['python_agent']['template']['cookbook'] unless node['newrelic']['python_agent']['template']['cookbook'].nil? 12 | source node['newrelic']['python_agent']['template']['source'] unless node['newrelic']['python_agent']['template']['source'].nil? 13 | app_name node['newrelic']['application_monitoring']['app_name'] unless node['newrelic']['application_monitoring']['app_name'].nil? 14 | high_security NewRelic.to_boolean(node['newrelic']['application_monitoring']['high_security']) unless node['newrelic']['application_monitoring']['high_security'].nil? 15 | enabled NewRelic.to_boolean(node['newrelic']['application_monitoring']['enabled']) unless node['newrelic']['application_monitoring']['enabled'].nil? 16 | logfile node['newrelic']['application_monitoring']['logfile'] unless node['newrelic']['application_monitoring']['logfile'].nil? 17 | loglevel node['newrelic']['application_monitoring']['loglevel'] unless node['newrelic']['application_monitoring']['loglevel'].nil? 18 | daemon_ssl NewRelic.to_boolean(node['newrelic']['application_monitoring']['daemon']['ssl']) unless node['newrelic']['application_monitoring']['daemon']['ssl'].nil? 19 | capture_params NewRelic.to_boolean(node['newrelic']['application_monitoring']['capture_params']) unless node['newrelic']['application_monitoring']['capture_params'].nil? 20 | ignored_params node['newrelic']['application_monitoring']['ignored_params'] unless node['newrelic']['application_monitoring']['ignored_params'].nil? 21 | transaction_tracer_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['transaction_tracer']['enable']) unless node['newrelic']['application_monitoring']['transaction_tracer']['enable'].nil? 22 | transaction_tracer_threshold node['newrelic']['application_monitoring']['transaction_tracer']['threshold'] unless node['newrelic']['application_monitoring']['transaction_tracer']['threshold'].nil? 23 | transaction_tracer_record_sql node['newrelic']['application_monitoring']['transaction_tracer']['record_sql'] unless node['newrelic']['application_monitoring']['transaction_tracer']['record_sql'].nil? 24 | transaction_tracer_stack_trace_threshold node['newrelic']['application_monitoring']['transaction_tracer']['stack_trace_threshold'] unless node['newrelic']['application_monitoring']['transaction_tracer']['stack_trace_threshold'].nil? 25 | transaction_tracer_slow_sql NewRelic.to_boolean(node['newrelic']['application_monitoring']['transaction_tracer']['slow_sql']) unless node['newrelic']['application_monitoring']['transaction_tracer']['slow_sql'].nil? 26 | transaction_tracer_explain_threshold node['newrelic']['application_monitoring']['transaction_tracer']['explain_threshold'] unless node['newrelic']['application_monitoring']['transaction_tracer']['explain_threshold'].nil? 27 | error_collector_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['error_collector']['enable']) unless node['newrelic']['application_monitoring']['error_collector']['enable'].nil? 28 | error_collector_ignore_errors node['newrelic']['application_monitoring']['error_collector']['ignore_errors'] unless node['newrelic']['application_monitoring']['error_collector']['ignore_errors'].nil? 29 | browser_monitoring_auto_instrument NewRelic.to_boolean(node['newrelic']['application_monitoring']['browser_monitoring']['auto_instrument']) unless node['newrelic']['application_monitoring']['browser_monitoring']['auto_instrument'].nil? 30 | cross_application_tracer_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['cross_application_tracer']['enable']) unless node['newrelic']['application_monitoring']['cross_application_tracer']['enable'] 31 | feature_flag node['newrelic']['python_agent']['feature_flag'] unless node['newrelic']['python_agent']['feature_flag'].nil? 32 | thread_profiler_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['thread_profiler']['enable']) unless node['newrelic']['application_monitoring']['thread_profiler']['enable'].nil? 33 | end 34 | -------------------------------------------------------------------------------- /recipes/repository.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Recipe:: repository 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | case node['platform_family'] 9 | when 'debian' 10 | apt_repository 'newrelic' do 11 | uri node['newrelic']['repository']['uri'] 12 | distribution node['newrelic']['repository']['distribution'] 13 | components node['newrelic']['repository']['components'] 14 | key node['newrelic']['repository']['key'] 15 | end 16 | when 'rhel', 'fedora', 'amazon' 17 | yum_repository 'newrelic' do 18 | description 'New Relic packages for Enterprise Linux 5 - $basearch' 19 | baseurl node['newrelic']['repository']['uri'] 20 | gpgkey node['newrelic']['repository']['key'] 21 | sslverify node['newrelic']['repository']['ssl_verify'] 22 | proxy node['newrelic']['repository']['proxy'] unless node['newrelic']['repository']['proxy'].nil? 23 | proxy_username node['newrelic']['repository']['proxy_username'] unless node['newrelic']['repository']['proxy_username'].nil? 24 | proxy_password node['newrelic']['repository']['proxy_password'] unless node['newrelic']['repository']['proxy_password'].nil? 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /recipes/ruby_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Recipe:: ruby_agent 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | newrelic_agent_ruby 'Install' do 9 | license lazy { NewRelic.application_monitoring_license(node) } 10 | version node['newrelic']['ruby_agent']['version'] unless node['newrelic']['ruby_agent']['version'] 11 | template_cookbook node['newrelic']['ruby_agent']['template_cookbook'] unless node['newrelic']['ruby_agent']['template_cookbook'] 12 | template_source node['newrelic']['ruby_agent']['template_source'] unless node['newrelic']['ruby_agent']['template_source'] 13 | enabled NewRelic.to_boolean(node['newrelic']['application_monitoring']['enabled']) unless node['newrelic']['application_monitoring']['enabled'] 14 | app_name node['newrelic']['application_monitoring']['app_name'] unless node['newrelic']['application_monitoring']['app_name'] 15 | high_security NewRelic.to_boolean(node['newrelic']['application_monitoring']['high_security']) unless node['newrelic']['application_monitoring']['high_security'] 16 | owner node['newrelic']['ruby_agent']['app_user'] unless node['newrelic']['ruby_agent']['app_user'] 17 | group node['newrelic']['ruby_agent']['app_group'] unless node['newrelic']['ruby_agent']['app_group'] 18 | logfile node['newrelic']['application_monitoring']['logfile'] unless node['newrelic']['application_monitoring']['logfile'] 19 | logfile_path node['newrelic']['application_monitoring']['logfile_path'] unless node['newrelic']['application_monitoring']['logfile_path'] 20 | loglevel node['newrelic']['application_monitoring']['loglevel'] unless node['newrelic']['application_monitoring']['loglevel'] 21 | audit_mode node['newrelic']['ruby_agent']['audit_mode'] unless node['newrelic']['ruby_agent']['audit_mode'] 22 | log_file_count node['newrelic']['ruby_agent']['log_file_count'] unless node['newrelic']['ruby_agent']['log_file_count'] 23 | log_limit_in_kbytes node['newrelic']['ruby_agent']['log_limit_in_kbytes'] unless node['newrelic']['ruby_agent']['log_limit_in_kbytes'] 24 | log_daily node['newrelic']['ruby_agent']['log_daily'] unless node['newrelic']['ruby_agent']['log_daily'] 25 | daemon_ssl NewRelic.to_boolean(node['newrelic']['application_monitoring']['daemon']['ssl']) unless node['newrelic']['application_monitoring']['daemon']['ssl'] 26 | daemon_proxy node['newrelic']['application_monitoring']['daemon']['proxy'] unless node['newrelic']['application_monitoring']['daemon']['proxy'] 27 | distributed_tracing_enable node['newrelic']['ruby_agent']['distributed_tracing_enable'] unless node['newrelic']['ruby_agent']['distributed_tracing_enable'].nil? 28 | capture_params node['newrelic']['application_monitoring']['capture_params'] unless node['newrelic']['application_monitoring']['capture_params'] 29 | ignored_params node['newrelic']['application_monitoring']['ignored_params'] unless node['newrelic']['application_monitoring']['ignored_params'] 30 | transaction_tracer_enable node['newrelic']['application_monitoring']['transaction_tracer']['enable'] unless node['newrelic']['application_monitoring']['transaction_tracer']['enable'] 31 | transaction_tracer_threshold node['newrelic']['application_monitoring']['transaction_tracer']['threshold'] unless node['newrelic']['application_monitoring']['transaction_tracer']['threshold'] 32 | transaction_tracer_record_sql node['newrelic']['application_monitoring']['transaction_tracer']['record_sql'] unless node['newrelic']['application_monitoring']['transaction_tracer']['record_sql'] 33 | transaction_tracer_stack_trace_threshold node['newrelic']['application_monitoring']['transaction_tracer']['stack_trace_threshold'] unless node['newrelic']['application_monitoring']['transaction_tracer']['stack_trace_threshold'] 34 | transaction_tracer_slow_sql node['newrelic']['application_monitoring']['transaction_tracer']['slow_sql'] unless node['newrelic']['application_monitoring']['transaction_tracer']['stack_trace_threshold'] 35 | transaction_tracer_explain_threshold node['newrelic']['application_monitoring']['transaction_tracer']['explain_threshold'] unless node['newrelic']['application_monitoring']['transaction_tracer']['explain_threshold'] 36 | error_collector_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['error_collector']['enable']) unless node['newrelic']['application_monitoring']['error_collector']['enable'] 37 | error_collector_ignore_errors node['newrelic']['application_monitoring']['error_collector']['ignore_errors'] unless node['newrelic']['application_monitoring']['error_collector']['ignore_errors'] 38 | error_collector_ignore_status_codes node['newrelic']['application_monitoring']['error_collector']['ignore_status_codes'] unless node['newrelic']['application_monitoring']['error_collector']['ignore_status_codes'] 39 | browser_monitoring_auto_instrument node['newrelic']['application_monitoring']['browser_monitoring']['auto_instrument'] unless node['newrelic']['application_monitoring']['browser_monitoring']['auto_instrument'] 40 | cross_application_tracer_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['cross_application_tracer']['enable']) unless node['newrelic']['application_monitoring']['cross_application_tracer']['enable'] 41 | thread_profiler_enable NewRelic.to_boolean(node['newrelic']['application_monitoring']['thread_profiler']['enable']) unless node['newrelic']['application_monitoring']['thread_profiler']['enable'] 42 | trim_stats node['newrelic']['java_agent']['trim_stats'] unless node['newrelic']['java_agent']['trim_stats'].nil? 43 | labels node['newrelic']['application_monitoring']['labels'] unless node['newrelic']['application_monitoring']['labels'].nil? 44 | end 45 | -------------------------------------------------------------------------------- /recipes/server_monitor_agent.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Recipe:: server_monitor_agent 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | newrelic_server_monitor 'Install' do 9 | license lazy { NewRelic.server_monitoring_license(node) } 10 | logfile node['newrelic']['server_monitoring']['logfile'] unless node['newrelic']['server_monitoring']['logfile'].nil? 11 | loglevel node['newrelic']['server_monitoring']['loglevel'] unless node['newrelic']['server_monitoring']['loglevel'].nil? 12 | proxy node['newrelic']['server_monitoring']['proxy'] unless node['newrelic']['server_monitoring']['proxy'].nil? 13 | ssl NewRelic.to_boolean(node['newrelic']['server_monitoring']['ssl']) unless node['newrelic']['server_monitoring']['ssl'].nil? 14 | ssl_ca_bundle node['newrelic']['server_monitoring']['ssl_ca_bundle'] unless node['newrelic']['server_monitoring']['ssl_ca_bundle'].nil? 15 | ssl_ca_path node['newrelic']['server_monitoring']['ssl_ca_path'] unless node['newrelic']['server_monitoring']['ssl_ca_path'].nil? 16 | hostname node['newrelic']['server_monitoring']['hostname'] unless node['newrelic']['server_monitoring']['hostname'].nil? 17 | labels node['newrelic']['server_monitoring']['labels'] unless node['newrelic']['server_monitoring']['labels'].nil? 18 | pidfile node['newrelic']['server_monitoring']['pidfile'] unless node['newrelic']['server_monitoring']['pidfile'].nil? 19 | collector_host node['newrelic']['server_monitoring']['collector_host'] unless node['newrelic']['server_monitoring']['collector_host'].nil? 20 | timeout node['newrelic']['server_monitoring']['timeout'] unless node['newrelic']['server_monitoring']['timeout'].nil? 21 | other_options node['newrelic']['server_monitoring']['other_options'] unless node['newrelic']['server_monitoring']['other_options'].nil? 22 | alert_policy_id node['newrelic']['server_monitoring']['alert_policy_id'] unless node['newrelic']['server_monitoring']['alert_policy_id'].nil? 23 | config_file_user node['newrelic']['server_monitor_agent']['config_file_user'] unless node['newrelic']['server_monitor_agent']['config_file_user'].nil? 24 | config_file_group node['newrelic']['server_monitor_agent']['config_file_group'] unless node['newrelic']['server_monitor_agent']['config_file_group'].nil? 25 | service_notify_action node['newrelic']['server_monitor_agent']['service_notify_action'] unless node['newrelic']['server_monitor_agent']['service_notify_action'].nil? 26 | service_actions node['newrelic']['server_monitor_agent']['service_actions'] unless node['newrelic']['server_monitor_agent']['service_actions'].nil? 27 | windows_version node['newrelic']['server_monitor_agent']['windows_version'] unless node['newrelic']['server_monitor_agent']['windows_version'].nil? 28 | windows32_checksum node['newrelic']['server_monitor_agent']['windows32_checksum'] unless node['newrelic']['server_monitor_agent']['windows32_checksum'].nil? 29 | windows64_checksum node['newrelic']['server_monitor_agent']['windows64_checksum'] unless node['newrelic']['server_monitor_agent']['windows64_checksum'].nil? 30 | cookbook node['newrelic']['server_monitor_agent']['template']['cookbook'] unless node['newrelic']['server_monitor_agent']['template']['cookbook'].nil? 31 | source node['newrelic']['server_monitor_agent']['template']['source'] unless node['newrelic']['server_monitor_agent']['template']['source'].nil? 32 | service_name node['newrelic']['server_monitor_agent']['service_name'] unless node['newrelic']['server_monitor_agent']['service_name'].nil? 33 | config_path node['newrelic']['server_monitor_agent']['config_path'] unless node['newrelic']['server_monitor_agent']['config_path'].nil? 34 | end 35 | -------------------------------------------------------------------------------- /resources/agent_dotnet.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Resource:: agent_dotnet 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | actions :install, :remove 9 | default_action :install 10 | 11 | attribute :https_download, kind_of: String, default: 'https://download.newrelic.com/dot_net_agent/latest_release/NewRelicDotNetAgent_x64.msi' 12 | attribute :install_level, kind_of: String, default: '1' 13 | attribute :config_dir, kind_of: String, default: 'C:\ProgramData\New Relic\.NET Agent' 14 | attribute :cookbook, kind_of: String, default: 'newrelic' 15 | attribute :source, kind_of: String, default: 'agent/dotnet/newrelic.config.erb' 16 | 17 | attribute :enabled, kind_of: [TrueClass, FalseClass], default: true 18 | attribute :max_stack_trace_lines, kind_of: Integer, default: 80 19 | attribute :timing_precision, kind_of: String, default: 'low' 20 | 21 | attribute :license, kind_of: String, default: lazy { NewRelic.application_monitoring_license(node) } 22 | attribute :daemon_ssl, kind_of: [TrueClass, FalseClass], default: true 23 | attribute :svc_send_env_info, kind_of: [TrueClass, FalseClass], default: true 24 | attribute :svc_sync_startup, kind_of: [TrueClass, FalseClass], default: false 25 | attribute :svc_send_data_on_exit, kind_of: [TrueClass, FalseClass], default: false 26 | attribute :svc_send_data_on_exit_threshold, kind_of: Integer, default: 60_000 27 | attribute :svc_auto_start, kind_of: [TrueClass, FalseClass], default: true 28 | 29 | attribute :use_proxy, kind_of: [TrueClass, FalseClass], default: false 30 | attribute :proxy_host, kind_of: String, default: '' 31 | attribute :proxy_port, kind_of: Integer, default: 8080 32 | attribute :proxy_domain, kind_of: String, default: '' 33 | attribute :proxy_user, kind_of: String, default: '' 34 | attribute :proxy_password, kind_of: String, default: '' 35 | 36 | attribute :app_log_level, kind_of: String, default: 'info' 37 | attribute :audit_log_enabled, kind_of: [TrueClass, FalseClass], default: false 38 | attribute :log_to_console, kind_of: [TrueClass, FalseClass], default: false 39 | attribute :log_directory, kind_of: String, default: 'C:\ProgramData\New Relic\.NET Agent\Logs' 40 | attribute :log_file_name, kind_of: String, default: 'newrelic.log' 41 | 42 | attribute :app_name, kind_of: String, default: 'My Application' 43 | attribute :app_disable_samplers, kind_of: [TrueClass, FalseClass], default: false 44 | 45 | attribute :instrumentation_applications, kind_of: Array, default: [] 46 | attribute :instrumentation_log_enable, kind_of: [TrueClass, FalseClass], default: false 47 | 48 | attribute :attributes_collection_enabled, kind_of: [TrueClass, FalseClass], default: true 49 | attribute :attributes_exclude, kind_of: Array, default: [] 50 | attribute :attributes_include, kind_of: Array, default: [] 51 | 52 | attribute :app_pools, kind_of: Array, default: [] # [{name: '', instrument: true|false}] 53 | attribute :app_pools_instrument_default_behavior, kind_of: [TrueClass, FalseClass], default: false 54 | 55 | attribute :cross_application_tracer_enabled, kind_of: [TrueClass, FalseClass], default: true 56 | 57 | attribute :error_collector_enabled, kind_of: [TrueClass, FalseClass], default: true 58 | attribute :ignored_exceptions, kind_of: Array, default: [ 59 | 'System.IO.FileNotFoundException', 60 | 'System.Threading.ThreadAbortException', 61 | ] 62 | attribute :ignored_status_codes, kind_of: Array, default: [401, 404] 63 | 64 | attribute :high_security_enabled, kind_of: [TrueClass, FalseClass], default: false 65 | 66 | attribute :tx_events_enabled, kind_of: [TrueClass, FalseClass], default: true 67 | attribute :tx_events_max_samples_per_minute, kind_of: Integer, default: 10_000 68 | attribute :tx_events_max_samples_stored, kind_of: Integer, default: 10_000 69 | attribute :tx_events_attributes_collection_enabled, kind_of: [TrueClass, FalseClass], default: true 70 | attribute :tx_events_attributes_exclude, kind_of: Array, default: [] 71 | attribute :tx_events_attributes_include, kind_of: Array, default: [] 72 | 73 | attribute :custom_events_enabled, kind_of: [TrueClass, FalseClass], default: true 74 | 75 | attribute :labels, kind_of: String, default: '' 76 | 77 | attribute :browser_monitoring_auto_instrument, kind_of: [TrueClass, FalseClass], default: true 78 | attribute :browser_monitoring_req_paths_excluded, kind_of: Array, default: [] 79 | attribute :browser_monitoring_attributes_collection_enabled, kind_of: [TrueClass, FalseClass], default: true 80 | attribute :browser_monitoring_attributes_exclude, kind_of: Array, default: [] 81 | attribute :browser_monitoring_attributes_include, kind_of: Array, default: [] 82 | 83 | attribute :slow_queries_enabled, kind_of: [TrueClass, FalseClass], default: true 84 | 85 | attribute :tx_tracer_enabled, kind_of: [TrueClass, FalseClass], default: true 86 | attribute :tx_tracer_transaction_threshold, kind_of: String, default: 'apdex_f' 87 | attribute :tx_tracer_stack_trace_threshold, kind_of: Integer, default: 500 88 | attribute :tx_tracer_record_sql, kind_of: String, default: 'obfuscated' 89 | attribute :tx_tracer_explain_enabled, kind_of: [TrueClass, FalseClass], default: true 90 | attribute :tx_tracer_explain_threshold, kind_of: Integer, default: 500 91 | attribute :tx_tracer_max_segments, kind_of: Integer, default: 3_000 92 | 93 | attribute :distributed_tracing_enabled, kind_of: [TrueClass, FalseClass], default: false 94 | 95 | attribute :tx_tracer_max_stack_trace, kind_of: Integer, default: 30 96 | attribute :tx_tracer_max_explain_plans, kind_of: Integer, default: 20 97 | attribute :tx_tracer_attributes_collection_enabled, kind_of: [TrueClass, FalseClass], default: true 98 | attribute :tx_tracer_attributes_exclude, kind_of: Array, default: [] 99 | attribute :tx_tracer_attributes_include, kind_of: Array, default: [] 100 | 101 | attribute :ignored_thread_profiling_methods, kind_of: Array, default: [ 102 | 'System.Threading.WaitHandle:InternalWaitOne', 103 | 'System.Threading.WaitHandle:WaitAny', 104 | ] 105 | -------------------------------------------------------------------------------- /resources/agent_infrastructure.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Resource:: agent_infrastructure 4 | # 5 | # Copyright:: (c) 2017, David Joos 6 | # 7 | 8 | actions :install 9 | default_action :install 10 | 11 | attribute :license, kind_of: String, default: lazy { NewRelic.application_monitoring_license(node) } 12 | attribute :version, kind_of: String, default: nil 13 | 14 | attribute :display_name, kind_of: String, default: nil 15 | attribute :logfile, kind_of: String, default: nil 16 | attribute :verbose, kind_of: Integer, default: 0 17 | attribute :proxy, kind_of: String, default: nil 18 | attribute :custom_attributes, kind_of: Hash, default: {} 19 | attribute :on_host_integrations_enable, kind_of: [TrueClass, FalseClass], default: false 20 | attribute :template_cookbook, kind_of: String, default: 'newrelic' 21 | attribute :template_source, kind_of: String, default: 'agent/infrastructure/newrelic.yml.erb' 22 | attribute :service_actions, kind_of: Array, default: %w(enable start) 23 | attribute :windows_version, kind_of: String, default: '1.0.703' 24 | attribute :windows_checksum, kind_of: String, default: 'dd528d84a6d82f9efc41369bbfcb92b6aa504bf20fc2ad23b1693d05efa22a9e' 25 | attribute :strip_command_line, kind_of: [TrueClass, FalseClass], default: nil 26 | -------------------------------------------------------------------------------- /resources/agent_java.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Resource:: agent_java 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | actions :install, :remove 8 | default_action :install 9 | 10 | attribute :license, kind_of: String, default: lazy { NewRelic.application_monitoring_license(node) } 11 | attribute :version, kind_of: String, default: 'latest' 12 | attribute :install_dir, kind_of: String, default: '/opt/newrelic/java' 13 | attribute :repository, kind_of: String, default: 'https://download.newrelic.com/newrelic/java-agent/newrelic-agent' 14 | attribute :agent_action, kind_of: String, default: 'install' 15 | attribute :execute_agent_action, kind_of: [TrueClass, FalseClass], default: true 16 | attribute :app_location, kind_of: String, default: nil 17 | attribute :app_user, kind_of: String, default: 'newrelic' 18 | attribute :app_group, kind_of: String, default: 'newrelic' 19 | attribute :agent_type, kind_of: String, default: 'java' 20 | attribute :template_cookbook, kind_of: String, default: 'newrelic' 21 | attribute :template_source, kind_of: String, default: 'agent/newrelic.yml.erb' 22 | 23 | attribute :enabled, kind_of: [TrueClass, FalseClass], default: true 24 | attribute :app_name, kind_of: String, default: nil 25 | attribute :high_security, kind_of: [TrueClass, FalseClass], default: false 26 | attribute :logfile, kind_of: String, default: nil 27 | attribute :logfile_path, kind_of: String, default: nil 28 | attribute :loglevel, kind_of: String, default: nil 29 | attribute :daemon_logfile, kind_of: String, default: '/var/log/newrelic/newrelic-daemon.log' 30 | attribute :daemon_loglevel, kind_of: String, default: nil 31 | attribute :audit_mode, kind_of: [TrueClass, FalseClass], default: false 32 | attribute :log_file_count, kind_of: Integer, default: nil 33 | attribute :log_limit_in_kbytes, kind_of: Integer, default: nil 34 | attribute :log_daily, kind_of: [TrueClass, FalseClass], default: false 35 | attribute :daemon_ssl, kind_of: [TrueClass, FalseClass], default: true 36 | attribute :daemon_proxy, kind_of: String, default: nil 37 | attribute :daemon_proxy_host, kind_of: String, default: nil 38 | attribute :daemon_proxy_port, kind_of: String, default: nil 39 | attribute :daemon_proxy_user, kind_of: String, default: nil 40 | attribute :daemon_proxy_password, kind_of: String, default: nil 41 | attribute :distributed_tracing_enable, kind_of: [TrueClass, FalseClass], default: false 42 | attribute :capture_params, kind_of: String, default: nil 43 | attribute :ignored_params, kind_of: String, default: nil 44 | attribute :enable_custom_tracing, kind_of: [TrueClass, FalseClass], default: false 45 | attribute :transaction_tracer_enable, kind_of: [TrueClass, FalseClass], default: true 46 | attribute :transaction_tracer_threshold, kind_of: String, default: nil 47 | attribute :transaction_tracer_record_sql, kind_of: String, default: nil 48 | attribute :transaction_tracer_stack_trace_threshold, kind_of: String, default: nil 49 | attribute :transaction_tracer_slow_sql, kind_of: String, default: nil 50 | attribute :transaction_tracer_explain_threshold, kind_of: String, default: nil 51 | attribute :error_collector_enable, kind_of: [TrueClass, FalseClass], default: true 52 | attribute :error_collector_ignore_errors, kind_of: String, default: nil 53 | attribute :error_collector_ignore_classes, kind_of: Array, default: nil 54 | attribute :error_collector_ignore_status_codes, kind_of: String, default: nil 55 | attribute :class_transformer_config, kind_of: Hash, default: {} 56 | attribute :circuitbreaker_enabled, kind_of: [TrueClass, FalseClass], default: true 57 | attribute :circuitbreaker_memory_threshold, kind_of: Integer, default: 20 58 | attribute :circuitbreaker_gc_cpu_threshold, kind_of: Integer, default: 10 59 | attribute :browser_monitoring_auto_instrument, kind_of: String, default: nil 60 | attribute :cross_application_tracer_enable, kind_of: [TrueClass, FalseClass], default: true 61 | attribute :thread_profiler_enable, kind_of: [TrueClass, FalseClass], default: true 62 | attribute :labels, kind_of: String, default: nil 63 | attribute :trim_stats, kind_of: [TrueClass, FalseClass], default: false 64 | -------------------------------------------------------------------------------- /resources/agent_nodejs.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Resource:: agent_nodejs 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | actions :install, :remove 9 | default_action :install 10 | 11 | attribute :license, kind_of: String, required: true 12 | attribute :version, kind_of: String, default: 'latest' 13 | attribute :app_name, kind_of: String, default: 'My Node App' 14 | attribute :app_path, kind_of: String, name_attribute: true 15 | attribute :cookbook, kind_of: String, default: 'newrelic' 16 | attribute :source, kind_of: String, default: 'agent/nodejs/newrelic.js.erb' 17 | attribute :enabled, kind_of: [TrueClass, FalseClass], default: true 18 | attribute :app_log_level, kind_of: String, default: 'info' 19 | attribute :app_log_filepath, kind_of: String, default: nil 20 | attribute :capture_params, kind_of: String, default: nil 21 | attribute :ignored_params, kind_of: String, default: nil 22 | -------------------------------------------------------------------------------- /resources/agent_php.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Resource:: agent_php 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | actions :install, :remove 9 | default_action :install 10 | 11 | attribute :license, kind_of: String, default: lazy { NewRelic.application_monitoring_license(node) } 12 | attribute :version, kind_of: String, default: nil 13 | attribute :config_file, kind_of: String, default: nil 14 | attribute :startup_mode, kind_of: String, default: 'agent' 15 | attribute :app_name, kind_of: String, default: nil 16 | attribute :high_security, kind_of: [TrueClass, FalseClass], default: false 17 | attribute :install_silently, kind_of: [TrueClass, FalseClass], default: false 18 | attribute :config_file_to_be_deleted, kind_of: String, default: nil 19 | attribute :service_name, kind_of: String, default: nil 20 | attribute :service_action, kind_of: String, default: 'restart' 21 | 22 | # @todo take out deprecated execute_php5enmod logic: use enable_module instead 23 | attribute :execute_php5enmod, kind_of: [TrueClass, FalseClass], default: false 24 | 25 | attribute :repository, kind_of: String, default: 'https://download.newrelic.com/php_agent/archive' 26 | 27 | attribute :enable_module, kind_of: [TrueClass, FalseClass], default: false 28 | attribute :cookbook_ini, kind_of: String, default: 'newrelic' 29 | attribute :source_ini, kind_of: String, default: 'agent/php/newrelic.ini.erb' 30 | attribute :cookbook, kind_of: String, default: 'newrelic' 31 | attribute :source, kind_of: String, default: 'agent/php/newrelic.cfg.erb' 32 | 33 | attribute :enabled, kind_of: [TrueClass, FalseClass], default: true 34 | attribute :logfile, kind_of: String, default: nil 35 | attribute :loglevel, kind_of: String, default: nil 36 | attribute :daemon_logfile, kind_of: String, default: '/var/log/newrelic/newrelic-daemon.log' 37 | attribute :daemon_loglevel, kind_of: String, default: nil 38 | attribute :daemon_port, kind_of: String, default: nil 39 | attribute :daemon_max_threads, kind_of: String, default: nil 40 | attribute :daemon_ssl, kind_of: [TrueClass, FalseClass], default: true 41 | attribute :daemon_ssl_ca_path, kind_of: String, default: nil 42 | attribute :daemon_ssl_ca_bundle, kind_of: String, default: nil 43 | attribute :daemon_proxy, kind_of: String, default: nil 44 | attribute :daemon_pidfile, kind_of: String, default: nil 45 | attribute :daemon_location, kind_of: String, default: nil 46 | attribute :daemon_collector_host, kind_of: String, default: nil 47 | attribute :daemon_dont_launch, kind_of: String, default: nil 48 | attribute :distributed_tracing_enabled, kind_of: [TrueClass, FalseClass], default: false 49 | attribute :distributed_tracing_exclude_newrelic_header, kind_of: [TrueClass, FalseClass], default: false 50 | attribute :capture_params, kind_of: [TrueClass, FalseClass], default: false 51 | attribute :ignored_params, kind_of: String, default: nil 52 | attribute :error_collector_enable, kind_of: [TrueClass, FalseClass], default: true 53 | attribute :error_collector_record_database_errors, kind_of: [TrueClass, FalseClass], default: true 54 | attribute :error_collector_prioritize_api_errors, kind_of: [TrueClass, FalseClass], default: false 55 | attribute :error_collector_ignore_errors, kind_of: String, default: nil 56 | attribute :error_collector_ignore_classes, kind_of: Array, default: nil 57 | attribute :browser_monitoring_auto_instrument, kind_of: [TrueClass, FalseClass], default: true 58 | attribute :transaction_tracer_enable, kind_of: [TrueClass, FalseClass], default: true 59 | attribute :transaction_tracer_threshold, kind_of: String, default: nil 60 | attribute :transaction_tracer_detail, kind_of: String, default: nil 61 | attribute :transaction_tracer_slow_sql, kind_of: [TrueClass, FalseClass], default: true 62 | attribute :transaction_tracer_stack_trace_threshold, kind_of: String, default: nil 63 | attribute :transaction_tracer_explain_threshold, kind_of: String, default: nil 64 | attribute :transaction_tracer_record_sql, kind_of: String, default: nil 65 | attribute :transaction_tracer_custom, kind_of: String, default: nil 66 | attribute :framework, kind_of: String, default: nil 67 | attribute :webtransaction_name_remove_trailing_path, kind_of: [TrueClass, FalseClass], default: false 68 | attribute :webtransaction_name_functions, kind_of: String, default: nil 69 | attribute :webtransaction_name_files, kind_of: String, default: nil 70 | attribute :cross_application_tracer_enable, kind_of: [TrueClass, FalseClass], default: true 71 | attribute :additional_config, kind_of: Hash, default: {} 72 | -------------------------------------------------------------------------------- /resources/agent_python.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Resource:: agent_python 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | actions :install, :remove 9 | default_action :install 10 | 11 | attribute :license, kind_of: String, required: true 12 | attribute :config_file, kind_of: String, default: '/etc/newrelic/newrelic.ini' 13 | attribute :cookbook, kind_of: String, default: 'newrelic' 14 | attribute :source, kind_of: String, default: 'agent/python/newrelic.ini.erb' 15 | attribute :app_name, kind_of: String, default: 'Python Application' 16 | attribute :enabled, kind_of: [TrueClass, FalseClass], default: true 17 | attribute :logfile, kind_of: String, default: '/tmp/newrelic-python-agent.log' 18 | attribute :loglevel, kind_of: String, default: 'info' 19 | attribute :daemon_ssl, kind_of: [TrueClass, FalseClass], default: true 20 | attribute :high_security, kind_of: [TrueClass, FalseClass], default: false 21 | attribute :capture_params, kind_of: [TrueClass, FalseClass], default: false 22 | attribute :ignored_params, kind_of: String, default: ' ' 23 | attribute :transaction_tracer_enable, kind_of: [TrueClass, FalseClass], default: true 24 | attribute :transaction_tracer_threshold, kind_of: String, default: 'apdex_f' 25 | attribute :transaction_tracer_record_sql, kind_of: String, default: 'obfuscated' 26 | attribute :transaction_tracer_stack_trace_threshold, kind_of: String, default: '0.5' 27 | attribute :transaction_tracer_slow_sql, kind_of: [TrueClass, FalseClass], default: true 28 | attribute :transaction_tracer_explain_threshold, kind_of: String, default: '0.5' 29 | attribute :thread_profiler_enable, kind_of: [TrueClass, FalseClass], default: true 30 | attribute :error_collector_enable, kind_of: [TrueClass, FalseClass], default: true 31 | attribute :error_collector_ignore_errors, kind_of: String, default: ' ' 32 | attribute :error_collector_ignore_classes, kind_of: Array, default: nil 33 | attribute :browser_monitoring_auto_instrument, kind_of: [TrueClass, FalseClass], default: true 34 | attribute :cross_application_tracer_enable, kind_of: [TrueClass, FalseClass], default: true 35 | attribute :feature_flag, kind_of: String, default: nil 36 | -------------------------------------------------------------------------------- /resources/agent_ruby.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Resource:: agent_ruby 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | actions :install, :remove 8 | default_action :install 9 | 10 | attribute :license, kind_of: String, default: lazy { NewRelic.application_monitoring_license(node) } 11 | attribute :version, kind_of: String, default: 'latest' 12 | attribute :agent_type, kind_of: String, default: 'ruby' 13 | attribute :install_dir, kind_of: String, default: '/opt/newrelic/ruby' 14 | attribute :app_user, kind_of: String, default: 'newrelic' 15 | attribute :app_group, kind_of: String, default: 'newrelic' 16 | attribute :audit_mode, kind_of: [TrueClass, FalseClass], default: false 17 | attribute :template_cookbook, kind_of: String, default: 'newrelic' 18 | attribute :template_source, kind_of: String, default: 'agent/newrelic.yml.erb' 19 | 20 | attribute :enabled, kind_of: [TrueClass, FalseClass], default: true 21 | attribute :app_name, kind_of: String, default: nil 22 | attribute :high_security, kind_of: [TrueClass, FalseClass], default: false 23 | attribute :owner, kind_of: String, default: 'newrelic' 24 | attribute :group, kind_of: String, default: 'newrelic' 25 | attribute :logfile, kind_of: String, default: 'newrelic-daemon.log' 26 | attribute :logfile_path, kind_of: String, default: '/var/log/newrelic/' 27 | attribute :loglevel, kind_of: String, default: nil 28 | attribute :audit_mode, kind_of: [TrueClass, FalseClass], default: false 29 | attribute :log_file_count, kind_of: Integer, default: 1 30 | attribute :log_limit_in_kbytes, kind_of: Integer, default: 0 31 | attribute :log_daily, kind_of: [TrueClass, FalseClass], default: true 32 | attribute :daemon_ssl, kind_of: [TrueClass, FalseClass], default: true 33 | attribute :daemon_proxy, kind_of: String, default: nil 34 | attribute :daemon_proxy_host, kind_of: String, default: nil 35 | attribute :daemon_proxy_port, kind_of: String, default: nil 36 | attribute :daemon_proxy_user, kind_of: String, default: nil 37 | attribute :daemon_proxy_password, kind_of: String, default: nil 38 | attribute :distributed_tracing_enable, kind_of: [TrueClass, FalseClass], default: false 39 | attribute :capture_params, kind_of: String, default: nil 40 | attribute :ignored_params, kind_of: String, default: nil 41 | attribute :enable_custom_tracing, kind_of: [TrueClass, FalseClass], default: false 42 | attribute :transaction_tracer_enable, kind_of: [TrueClass, FalseClass], default: true 43 | attribute :transaction_tracer_threshold, kind_of: String, default: nil 44 | attribute :transaction_tracer_record_sql, kind_of: String, default: nil 45 | attribute :transaction_tracer_stack_trace_threshold, kind_of: String, default: nil 46 | attribute :transaction_tracer_slow_sql, kind_of: String, default: nil 47 | attribute :transaction_tracer_explain_threshold, kind_of: String, default: nil 48 | attribute :error_collector_enable, kind_of: [TrueClass, FalseClass], default: true 49 | attribute :error_collector_ignore_errors, kind_of: String, default: nil 50 | attribute :error_collector_ignore_classes, kind_of: Array, default: nil 51 | attribute :error_collector_ignore_status_codes, kind_of: String, default: nil 52 | attribute :circuitbreaker_enabled, kind_of: [TrueClass, FalseClass], default: true 53 | attribute :circuitbreaker_memory_threshold, kind_of: Integer, default: 20 54 | attribute :circuitbreaker_gc_cpu_threshold, kind_of: Integer, default: 10 55 | attribute :browser_monitoring_auto_instrument, kind_of: String, default: nil 56 | attribute :cross_application_tracer_enable, kind_of: [TrueClass, FalseClass], default: true 57 | attribute :thread_profiler_enable, kind_of: [TrueClass, FalseClass], default: true 58 | attribute :labels, kind_of: String, default: nil 59 | attribute :trim_stats, kind_of: [TrueClass, FalseClass], default: false 60 | -------------------------------------------------------------------------------- /resources/deployment.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Resource:: deployment 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | actions :notify 9 | default_action :notify 10 | 11 | attribute :url, kind_of: String, default: 'https://api.newrelic.com/deployments.xml' 12 | attribute :key_type, kind_of: String, equal_to: %w(license_key api_key), default: 'api_key' 13 | attribute :key, name_attribute: true, kind_of: String 14 | 15 | # @todo take out deprecated api_key logic 16 | attribute :api_key, kind_of: String, default: nil 17 | 18 | attribute :app_name, kind_of: String, name_attribute: true # required when app_id is not set 19 | attribute :app_id, kind_of: Integer, default: nil # required when app_name is not set 20 | attribute :description, kind_of: String, default: nil # optional 21 | attribute :revision, kind_of: String, default: nil # optional 22 | attribute :changelog, kind_of: String, default: nil # optional 23 | attribute :user, kind_of: String, default: nil # optional 24 | 25 | def initialize(*args) 26 | super 27 | @run_context.include_recipe 'curl' 28 | end 29 | -------------------------------------------------------------------------------- /resources/server_monitor.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Resource:: server_monitor 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | actions :install, :remove 9 | default_action :install 10 | 11 | attribute :license, kind_of: String, default: lazy { NewRelic.server_monitoring_license(node) } 12 | 13 | attribute :logfile, kind_of: String, default: nil 14 | attribute :loglevel, kind_of: String, default: nil 15 | attribute :proxy, kind_of: String, default: nil 16 | attribute :ssl, kind_of: [TrueClass, FalseClass], default: true 17 | attribute :ssl_ca_bundle, kind_of: String, default: nil 18 | attribute :ssl_ca_path, kind_of: String, default: nil 19 | attribute :hostname, kind_of: String, default: nil 20 | attribute :labels, kind_of: String, default: nil 21 | attribute :pidfile, kind_of: String, default: nil 22 | attribute :collector_host, kind_of: String, default: nil 23 | attribute :timeout, kind_of: String, default: nil 24 | attribute :other_options, kind_of: Hash, default: {} 25 | attribute :alert_policy_id, kind_of: String, default: nil 26 | 27 | attribute :config_file_user, kind_of: String, default: 'root' 28 | attribute :service_notify_action, kind_of: String, default: 'restart' 29 | attribute :service_actions, kind_of: Array, default: %w(enable start) 30 | attribute :windows_version, kind_of: String, default: '2.0.0.198' 31 | attribute :windows64_checksum, kind_of: String, default: '5a8f3f5e8f15997463430401756d377c321c8899c2790ca85e5587a5b643651e' 32 | attribute :windows32_checksum, kind_of: String, default: 'ac2b65eecaad461fdd2e4386e3e4c9f96ea940b35bdf7a8c532c21dbd1c99ff0' 33 | attribute :cookbook, kind_of: String, default: 'newrelic' 34 | attribute :source, kind_of: String, default: 'agent/server_monitor/nrsysmond.cfg.erb' 35 | 36 | if node['platform'] == 'smartos' 37 | attribute :service_name, kind_of: String, default: 'nrsysmond' 38 | attribute :config_file_group, kind_of: String, default: 'root' 39 | attribute :config_path, kind_of: String, default: '/opt/local/etc' 40 | else 41 | attribute :service_name, kind_of: String, default: 'newrelic-sysmond' 42 | attribute :config_file_group, kind_of: String, default: 'newrelic' 43 | attribute :config_path, kind_of: String, default: '/etc/newrelic' 44 | end 45 | -------------------------------------------------------------------------------- /resources/yml.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic 3 | # Resource:: yml 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | actions :generate 9 | default_action :generate 10 | 11 | attribute :yml_path, kind_of: String, name_attribute: true 12 | attribute :template_cookbook, kind_of: String, default: 'newrelic' 13 | attribute :template_source, kind_of: String, default: 'agent/newrelic.yml.erb' 14 | attribute :app_name, kind_of: String, default: nil 15 | attribute :high_security, kind_of: [TrueClass, FalseClass, String], default: nil 16 | attribute :agent_type, kind_of: String, required: true, regex: /^(java|ruby)$/ 17 | attribute :enabled, kind_of: [TrueClass, FalseClass, String], default: nil 18 | attribute :owner, kind_of: String, default: nil 19 | attribute :group, kind_of: String, default: nil 20 | attribute :license, kind_of: String, default: lazy { NewRelic.application_monitoring_license(node) } 21 | attribute :logfile, kind_of: String, default: lazy { node['newrelic']['application_monitoring']['logfile'] } 22 | attribute :logfile_path, kind_of: String, default: lazy { node['newrelic']['application_monitoring']['logfile'] } 23 | attribute :loglevel, kind_of: String, default: lazy { node['newrelic']['application_monitoring']['loglevel'] } 24 | attribute :audit_mode, kind_of: [TrueClass, FalseClass, String], default: nil 25 | attribute :log_file_count, default: nil 26 | attribute :log_limit_in_kbytes, default: nil 27 | attribute :log_daily, default: nil 28 | attribute :daemon_ssl, default: lazy { node['newrelic']['application_monitoring']['daemon']['ssl'] } 29 | attribute :daemon_proxy, default: lazy { node['newrelic']['application_monitoring']['daemon']['proxy'] } 30 | attribute :daemon_proxy_host, kind_of: String, default: nil 31 | attribute :daemon_proxy_port, kind_of: String, default: nil 32 | attribute :daemon_proxy_user, kind_of: String, default: nil 33 | attribute :daemon_proxy_password, kind_of: String, default: nil 34 | attribute :distributed_tracing_enable, kind_of: [TrueClass, FalseClass], default: false 35 | attribute :capture_params, default: lazy { node['newrelic']['application_monitoring']['capture_params'] } 36 | attribute :ignored_params, default: lazy { node['newrelic']['application_monitoring']['ignored_params'] } 37 | attribute :enable_custom_tracing, kind_of: [TrueClass, FalseClass], default: false 38 | attribute :transaction_tracer_enable, default: lazy { node['newrelic']['application_monitoring']['transaction_tracer']['enable'] } 39 | attribute :transaction_tracer_threshold, default: lazy { node['newrelic']['application_monitoring']['transaction_tracer']['threshold'] } 40 | attribute :transaction_tracer_record_sql, default: lazy { node['newrelic']['application_monitoring']['transaction_tracer']['record_sql'] } 41 | attribute :transaction_tracer_stack_trace_threshold, default: lazy { node['newrelic']['application_monitoring']['transaction_tracer']['stack_trace_threshold'] } 42 | attribute :transaction_tracer_slow_sql, default: lazy { node['newrelic']['application_monitoring']['transaction_tracer']['slow_sql'] } 43 | attribute :transaction_tracer_explain_threshold, default: lazy { node['newrelic']['application_monitoring']['transaction_tracer']['explain_threshold'] } 44 | attribute :error_collector_enable, default: lazy { node['newrelic']['application_monitoring']['error_collector']['enable'] } 45 | attribute :error_collector_ignore_errors, default: lazy { node['newrelic']['application_monitoring']['error_collector']['ignore_errors'] } 46 | attribute :error_collector_ignore_classes, default: lazy { node['newrelic']['application_monitoring']['error_collector']['ignore_classes'] } 47 | attribute :error_collector_ignore_status_codes, default: lazy { node['newrelic']['application_monitoring']['error_collector']['ignore_status_codes'] } 48 | attribute :circuitbreaker_enabled, kind_of: [TrueClass, FalseClass], default: true 49 | attribute :circuitbreaker_memory_threshold, kind_of: Integer, default: 20 50 | attribute :circuitbreaker_gc_cpu_threshold, kind_of: Integer, default: 10 51 | attribute :browser_monitoring_auto_instrument, default: lazy { node['newrelic']['application_monitoring']['browser_monitoring']['auto_instrument'] } 52 | attribute :cross_application_tracer_enable, default: lazy { node['newrelic']['application_monitoring']['browser_monitoring']['auto_instrument'] } 53 | attribute :thread_profiler_enable, default: lazy { node['newrelic']['application_monitoring']['thread_profiler']['enable'] } 54 | attribute :labels, default: lazy { node['newrelic']['application_monitoring']['labels'] } 55 | attribute :trim_stats, kind_of: [TrueClass, FalseClass], default: false 56 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'rspec/expectations' 2 | require 'chefspec' 3 | require 'chefspec/berkshelf' 4 | 5 | ::LOG_LEVEL = :info 6 | 7 | def stub_resources 8 | stub_command('/usr/sbin/apache2 -t').and_return(true) 9 | stub_command('/usr/sbin/httpd -t').and_return(true) 10 | shellout = double('shellout') 11 | shellout.stub(:run_command) 12 | shellout.stub(:error?) 13 | Mixlib::ShellOut.stub(:new).with('which npm').and_return(shellout) 14 | Mixlib::ShellOut.stub(:new).with('php -r "echo PHP_MAJOR_VERSION;"').and_return(double('shell_out', run_command: nil, error!: nil, stdout: '5')) 15 | Mixlib::ShellOut.stub(:new).with('php -r "echo PHP_MINOR_VERSION;"').and_return(double('shell_out', run_command: nil, error!: nil, stdout: '6')) 16 | allow(File).to receive(:exist?).and_call_original 17 | allow(File).to receive(:exist?).with('/var/mynode_app').and_return(true) 18 | end 19 | 20 | def stub_node_resources(node) 21 | node.override['newrelic']['license'] = '0000ffff0000ffff0000ffff0000ffff0000ffff' 22 | node.override['newrelic']['php_agent']['web_server']['service_name'] = 'httpd' 23 | node.override['newrelic']['php_agent']['php_config'] = '/etc/php.d/newrelic.ini' 24 | node.override['rubygems'] = 'rubygems' 25 | end 26 | 27 | RSpec.configure do |config| 28 | config.mock_with :rspec do |c| 29 | c.syntax = %i(should expect) 30 | end 31 | config.log_level = :error 32 | config.formatter = :documentation 33 | config.color = true 34 | end 35 | -------------------------------------------------------------------------------- /spec/unit/agent_dotnet_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'newrelic_lwrp_test::agent_dotnet' do 4 | before do 5 | stub_resources 6 | end 7 | 8 | context 'Windows' do 9 | let(:chef_run) do 10 | ChefSpec::SoloRunner.new(log_level: LOG_LEVEL, platform: 'windows', version: '2012', step_into: ['newrelic_agent_dotnet']) do |node| 11 | stub_node_resources(node) 12 | end.converge(described_recipe) 13 | end 14 | 15 | it 'Installs New Relic .Net agent' do 16 | expect(chef_run).to install_newrelic_agent_dotnet('Install') 17 | end 18 | 19 | it 'Install New Relic .NET Agent (windows_package)' do 20 | expect(chef_run).to install_windows_package('Install New Relic .NET Agent') 21 | end 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /spec/unit/agent_infrastructure_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'newrelic_lwrp_test::agent_infrastructure' do 4 | before do 5 | stub_resources 6 | end 7 | 8 | context 'Centos' do 9 | let(:chef_run) do 10 | ChefSpec::SoloRunner.new(log_level: LOG_LEVEL, platform: 'centos', version: '6', step_into: ['newrelic_agent_infrastructure']) do |node| 11 | stub_node_resources(node) 12 | end.converge(described_recipe) 13 | end 14 | 15 | it 'installs New Relic Infrastructure agent' do 16 | expect(chef_run).to install_newrelic_agent_infrastructure('Install') 17 | end 18 | 19 | it 'creates a yum_repository for newrelic' do 20 | expect(chef_run).to create_yum_repository('newrelic-infra') 21 | end 22 | 23 | it 'creates newrelic infrastructure yml config template from agent/infrastructure/newrelic.yml.erb' do 24 | expect(chef_run).to render_file('/etc/newrelic-infra.yml').with_content('0000ffff0000ffff0000ffff0000ffff0000ffff') 25 | end 26 | 27 | it 'installs newrelic-infra' do 28 | expect(chef_run).to install_package('newrelic-infra') 29 | end 30 | 31 | it 'enables newrelic-infra service' do 32 | expect(chef_run).to enable_service('newrelic-infra').with( 33 | provider: Chef::Provider::Service::Upstart 34 | ) 35 | end 36 | end 37 | 38 | context 'Ubuntu 14.04' do 39 | let(:chef_run) do 40 | ChefSpec::SoloRunner.new(log_level: LOG_LEVEL, platform: 'ubuntu', version: '14.04', step_into: ['newrelic_agent_infrastructure']) do |node| 41 | stub_node_resources(node) 42 | end.converge(described_recipe) 43 | end 44 | 45 | it 'enables newrelic-infra service with upstart' do 46 | expect(chef_run).to enable_service('newrelic-infra').with( 47 | provider: Chef::Provider::Service::Upstart 48 | ) 49 | end 50 | end 51 | 52 | context 'Ubuntu 16.04' do 53 | let(:chef_run) do 54 | ChefSpec::SoloRunner.new(log_level: LOG_LEVEL, platform: 'ubuntu', version: '16.04', step_into: ['newrelic_agent_infrastructure']) do |node| 55 | stub_node_resources(node) 56 | end.converge(described_recipe) 57 | end 58 | 59 | it 'enables newrelic-infra service with systemd' do 60 | expect(chef_run).to enable_service('newrelic-infra').with( 61 | provider: Chef::Provider::Service::Systemd 62 | ) 63 | end 64 | end 65 | 66 | context 'Amazon Linux' do 67 | let(:chef_run) do 68 | ChefSpec::SoloRunner.new(log_level: LOG_LEVEL, platform: 'amazon', version: '2018.03', step_into: ['newrelic_agent_infrastructure']) do |node| 69 | stub_node_resources(node) 70 | end.converge(described_recipe) 71 | end 72 | 73 | it 'enables newrelic-infra service with upstart' do 74 | expect(chef_run).to enable_service('newrelic-infra').with( 75 | provider: Chef::Provider::Service::Upstart 76 | ) 77 | end 78 | end 79 | 80 | context 'Amazon Linux 2' do 81 | let(:chef_run) do 82 | ChefSpec::SoloRunner.new(log_level: LOG_LEVEL, platform: 'amazon', version: '2', step_into: ['newrelic_agent_infrastructure']) do |node| 83 | stub_node_resources(node) 84 | end.converge(described_recipe) 85 | end 86 | 87 | it 'enables newrelic-infra service with systemd' do 88 | expect(chef_run).to enable_service('newrelic-infra').with( 89 | provider: Chef::Provider::Service::Systemd 90 | ) 91 | end 92 | end 93 | end 94 | -------------------------------------------------------------------------------- /spec/unit/agent_java_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'newrelic_lwrp_test::agent_java' do 4 | before do 5 | stub_resources 6 | end 7 | 8 | context 'Centos' do 9 | let(:chef_run) do 10 | ChefSpec::SoloRunner.new(log_level: LOG_LEVEL, platform: 'centos', version: '6', step_into: ['newrelic_agent_java']) do |node| 11 | stub_node_resources(node) 12 | end.converge(described_recipe) 13 | end 14 | 15 | it 'Installs New Relic Java agent' do 16 | expect(chef_run).to install_newrelic_agent_java('Install') 17 | end 18 | 19 | it 'creates install_dir' do 20 | expect(chef_run).to create_directory('/opt/newrelic/java') 21 | end 22 | 23 | it 'creates newrelic-java.zip' do 24 | expect(chef_run).to create_remote_file('/opt/newrelic/java/newrelic.zip') 25 | end 26 | 27 | it 'sends a notification to newrelic-extract-jar after creating newrelic-java.zip' do 28 | expect(chef_run.remote_file('/opt/newrelic/java/newrelic.zip')).to notify('execute[newrelic-extract-jar]').immediately 29 | end 30 | 31 | it 'defines newrelic-extract-jar execute block' do 32 | expect(chef_run.execute('newrelic-extract-jar')).to do_nothing 33 | end 34 | 35 | it 'creates newrelic yml config template from newrelic.yml.erb' do 36 | expect(chef_run).to render_file('/opt/newrelic/java/newrelic.yml').with_content('0000ffff0000ffff0000ffff0000ffff0000ffff') 37 | end 38 | 39 | it 'execute newrelic_install_newrelic.zip' do 40 | expect(chef_run).to run_execute('newrelic_install_newrelic.jar') 41 | end 42 | end 43 | 44 | context 'Centos, class_transformer_config' do 45 | let(:chef_run) do 46 | ChefSpec::Runner.new(log_level: LOG_LEVEL, platform: 'centos', version: '6', step_into: ['newrelic_agent_java']) do |node| 47 | stub_node_resources(node) 48 | node.override['newrelic']['java_agent']['class_transformer_config'] = { 49 | 'classloader_blacklist' => %w(class1 class2), 50 | 'instrumentation_classes' => { 51 | 'wildfly-8' => { 'enabled' => false }, 52 | 'wildfly-8-CAT' => { 'enabled' => false }, 53 | 'wildfly-8-PORT' => { 'enabled' => false }, 54 | }, 55 | } 56 | node.override['newrelic']['java_agent']['agent_action'] = :install 57 | end.converge(described_recipe) 58 | end 59 | 60 | it 'creates newrelic yml with the config for the class_transformer' do 61 | expect(chef_run).to render_file('/opt/newrelic/java/newrelic.yml').with_content('0000ffff0000ffff0000ffff0000ffff0000ffff') 62 | expect(chef_run).to render_file('/opt/newrelic/java/newrelic.yml').with_content(' 63 | class_transformer: 64 | classloader_blacklist: class1, class2 65 | com.newrelic.instrumentation.wildfly-8: 66 | enabled: false 67 | com.newrelic.instrumentation.wildfly-8-CAT: 68 | enabled: false 69 | com.newrelic.instrumentation.wildfly-8-PORT: 70 | enabled: false') 71 | end 72 | end 73 | end 74 | -------------------------------------------------------------------------------- /spec/unit/agent_nodejs_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'newrelic_lwrp_test::agent_nodejs' do 4 | before do 5 | stub_resources 6 | end 7 | 8 | context 'Centos' do 9 | let(:chef_run) do 10 | ChefSpec::SoloRunner.new(log_level: LOG_LEVEL, platform: 'centos', version: '6', step_into: ['newrelic_agent_nodejs']) do |node| 11 | stub_resources 12 | stub_node_resources(node) 13 | end.converge(described_recipe) 14 | end 15 | 16 | it 'creates directory for nodejs app' do 17 | expect(chef_run).to create_directory('/var/mynode_app') 18 | end 19 | 20 | it 'installs New Relic Nodejs agent' do 21 | expect(chef_run).to install_newrelic_agent_nodejs('/var/mynode_app') 22 | end 23 | 24 | it 'creates a yum_repository for newrelic' do 25 | expect(chef_run).to create_yum_repository('newrelic') 26 | end 27 | 28 | it 'creates newrelic.js config template ' do 29 | expect(chef_run).to render_file('/var/mynode_app/newrelic.js').with_content('0000ffff0000ffff0000ffff0000ffff0000ffff') 30 | end 31 | 32 | it 'installs latest newrelic npm package' do 33 | # version one dot thirty eight dot two has invalid readable stream version two dot two dot three 34 | expect(chef_run).to run_execute('npm install newrelic@1.37.2') 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /spec/unit/agent_php_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'newrelic_lwrp_test::agent_php' do 4 | before do 5 | stub_resources 6 | end 7 | 8 | context 'Centos' do 9 | let(:chef_run) do 10 | ChefSpec::SoloRunner.new(log_level: LOG_LEVEL, platform: 'centos', version: '6', step_into: ['newrelic_agent_php']) do |node| 11 | stub_node_resources(node) 12 | end.converge(described_recipe) 13 | end 14 | 15 | it 'installs New Relic PHP agent' do 16 | expect(chef_run).to install_newrelic_agent_php('Install') 17 | end 18 | 19 | it 'creates a yum_repository for newrelic' do 20 | expect(chef_run).to create_yum_repository('newrelic') 21 | end 22 | 23 | it 'removes newrelic-php5-broken ' do 24 | expect(chef_run).to remove_package('newrelic-php5-broken').with(version: '3.0.5.95') 25 | end 26 | 27 | it 'installs newrelic-php5' do 28 | expect(chef_run).to install_package('newrelic-php5') 29 | end 30 | 31 | it 'stub service' do 32 | expect(chef_run).to_not enable_service('stub_service') 33 | end 34 | 35 | it 'sends a notification to newrelic-install after installing newrelic-php5' do 36 | expect(chef_run.package('newrelic-php5')).to notify('execute[newrelic-install]').immediately 37 | end 38 | 39 | it 'defines newrelic-install execute block' do 40 | expect(chef_run.execute('newrelic-install')).to do_nothing 41 | end 42 | 43 | it 'restarts the webserver at the end of the chef run when running newrelic-install' do 44 | expect(chef_run.execute('newrelic-install')).to notify('service[httpd]').delayed 45 | end 46 | 47 | it 'creates newrelic ini config template from newrelic.ini.erb' do 48 | expect(chef_run).to render_file('/etc/php.d/newrelic.ini').with_content('0000ffff0000ffff0000ffff0000ffff0000ffff') 49 | end 50 | 51 | it 'restarts the webserver at the end of the chef run when changing the config file' do 52 | expect(chef_run.template('/etc/php.d/newrelic.ini')).to notify('service[httpd]').delayed 53 | end 54 | 55 | context 'with an external startup mode' do 56 | let(:chef_run) do 57 | ChefSpec::Runner.new(log_level: LOG_LEVEL, platform: 'centos', version: '6', step_into: ['newrelic_agent_php']) do |node| 58 | stub_node_resources(node) 59 | end.converge(described_recipe) 60 | end 61 | 62 | it 'creates newrelic config template from newrelic.conf.erb' do 63 | expect(chef_run).to render_file('/etc/newrelic/newrelic.cfg') 64 | end 65 | 66 | it 'restarts the webserver at the end of the chef run when changing /etc/newrelic/newrelic.cfg config file' do 67 | expect(chef_run.template('/etc/newrelic/newrelic.cfg')).to notify('service[httpd]').delayed 68 | end 69 | 70 | it 'restarts the newrelic-daemon when changing /etc/newrelic/newrelic.cfg config file' do 71 | expect(chef_run.template('/etc/newrelic/newrelic.cfg')).to notify('service[httpd]').delayed 72 | end 73 | 74 | it 'starts and enables newrelic-daemon' do 75 | expect(chef_run).to enable_service('newrelic-daemon') 76 | expect(chef_run).to start_service('newrelic-daemon') 77 | end 78 | end 79 | 80 | it 'defines newrelic-enable-module execute block' do 81 | expect(chef_run.execute('newrelic-enable-module')).to do_nothing 82 | end 83 | end 84 | end 85 | -------------------------------------------------------------------------------- /spec/unit/agent_python_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'newrelic_lwrp_test::agent_python' do 4 | before do 5 | stub_resources 6 | end 7 | 8 | context 'Centos' do 9 | let(:chef_run) do 10 | ChefSpec::SoloRunner.new(log_level: LOG_LEVEL, platform: 'centos', version: '6', step_into: ['newrelic_agent_python']) do |node| 11 | stub_node_resources(node) 12 | end.converge(described_recipe) 13 | end 14 | 15 | it 'Installs New Relic Python agent' do 16 | expect(chef_run).to install_newrelic_agent_python('Install') 17 | end 18 | 19 | it 'creates a yum_repository for newrelic' do 20 | expect(chef_run).to create_yum_repository('newrelic') 21 | end 22 | 23 | it 'creates directory for newrelic' do 24 | expect(chef_run).to create_directory('/etc/newrelic') 25 | end 26 | 27 | it 'installs python-pip newrelic package' do 28 | expect(chef_run).to install_python_package('newrelic') 29 | end 30 | 31 | it 'creates newrelic ini config template from newrelic.ini.erb' do 32 | expect(chef_run).to render_file('/etc/newrelic/newrelic.ini').with_content('0000ffff0000ffff0000ffff0000ffff0000ffff') 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /spec/unit/agent_ruby_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'newrelic_lwrp_test::agent_ruby' do 4 | before do 5 | stub_resources 6 | end 7 | 8 | context 'Centos' do 9 | let(:chef_run) do 10 | ChefSpec::SoloRunner.new(log_level: LOG_LEVEL, platform: 'centos', version: '6', step_into: ['newrelic_agent_ruby']) do |node| 11 | stub_node_resources(node) 12 | end.converge(described_recipe) 13 | end 14 | 15 | it 'Installs New Relic Ruby agent' do 16 | expect(chef_run).to install_newrelic_agent_ruby('Install') 17 | end 18 | 19 | it 'creates install_dir' do 20 | expect(chef_run).to create_directory('/opt/newrelic/ruby') 21 | end 22 | 23 | it 'installs a gem_package newrelic_rpm' do 24 | expect(chef_run).to install_gem_package('newrelic_rpm') 25 | end 26 | 27 | it 'creates newrelic yml config template from newrelic.yml.erb' do 28 | expect(chef_run).to render_file('/opt/newrelic/ruby/newrelic.yml').with_content('0000ffff0000ffff0000ffff0000ffff0000ffff') 29 | end 30 | 31 | it 'installs rubygems from yum' do 32 | expect(chef_run).to install_package('rubygems') 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /spec/unit/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'newrelic::default' do 4 | let(:chef_run) { ChefSpec::SoloRunner.new.converge(described_recipe) } 5 | 6 | it 'includes the server_monitor_agent recipe' do 7 | expect(chef_run).to include_recipe('newrelic::server_monitor_agent') 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/unit/license_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | require_relative '../../libraries/newrelic' 3 | 4 | describe 'libraries/newrelic.rb' do 5 | # helper to build different kinds of node objects 6 | def build_node(lic = nil, server = nil, app = nil) 7 | node = {} 8 | node['newrelic'] = {} 9 | 10 | node['newrelic']['license'] = lic if lic 11 | 12 | if server 13 | node['newrelic']['server_monitoring'] = {} 14 | node['newrelic']['server_monitoring']['license'] = server 15 | end 16 | 17 | if app 18 | node['newrelic']['application_monitoring'] = {} 19 | node['newrelic']['application_monitoring']['license'] = app 20 | end 21 | 22 | node 23 | end 24 | 25 | it "returns nil when node['newrelic'] is not defined" do 26 | license = NewRelic.license({}) 27 | expect(license).to be(nil) 28 | end 29 | 30 | it "returns nil when node['newrelic']['license'] is not defined" do 31 | license = NewRelic.license(build_node) 32 | expect(license).to be(nil) 33 | end 34 | 35 | it "returns node['newrelic']['license'] for all licenses when main value is set" do 36 | node = build_node('a') 37 | expect(NewRelic.license(node)).to eq('a') 38 | expect(NewRelic.server_monitoring_license(node)).to eq('a') 39 | expect(NewRelic.application_monitoring_license(node)).to eq('a') 40 | end 41 | 42 | it "returns node['newrelic']['license'] for all licenses except node['newrelic']['server_monitoring']['license']" do 43 | node = build_node('a', 'b', nil) 44 | expect(NewRelic.license(node)).to eq('a') 45 | expect(NewRelic.server_monitoring_license(node)).to eq('b') 46 | expect(NewRelic.application_monitoring_license(node)).to eq('a') 47 | end 48 | 49 | it "returns node['newrelic']['license'] for all licenses except node['newrelic']['application_monitoring']['license']" do 50 | node = build_node('a', nil, 'c') 51 | expect(NewRelic.license(node)).to eq('a') 52 | expect(NewRelic.server_monitoring_license(node)).to eq('a') 53 | expect(NewRelic.application_monitoring_license(node)).to eq('c') 54 | end 55 | 56 | it "returns unique node['newrelic']['license'], node['newrelic']['server_monitoring']['license'], and node['newrelic']['application_monitoring']['license']" do 57 | node = build_node('a', 'b', 'c') 58 | expect(NewRelic.license(node)).to eq('a') 59 | expect(NewRelic.server_monitoring_license(node)).to eq('b') 60 | expect(NewRelic.application_monitoring_license(node)).to eq('c') 61 | end 62 | end 63 | -------------------------------------------------------------------------------- /spec/unit/repository_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'newrelic::repository' do 4 | # before(:each) do 5 | # stub_command('apt-key list | grep 548C16BF').and_return(true) 6 | # end 7 | 8 | context 'Ubuntu 14.04' do 9 | let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'ubuntu', version: '14.04').converge(described_recipe) } 10 | 11 | it 'installs the New Relic apt repository' do 12 | expect(chef_run).to add_apt_repository('newrelic').with( 13 | uri: 'http://download.newrelic.com/debian/', 14 | distribution: 'newrelic', 15 | components: ['non-free'], 16 | key: ['http://download.newrelic.com/548C16BF.gpg'] 17 | ) 18 | end 19 | end 20 | 21 | context 'Debian 7' do 22 | let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'debian', version: '7.11').converge(described_recipe) } 23 | 24 | it 'installs the New Relic apt repository' do 25 | expect(chef_run).to add_apt_repository('newrelic').with( 26 | uri: 'http://download.newrelic.com/debian/', 27 | distribution: 'newrelic', 28 | components: ['non-free'], 29 | key: ['http://download.newrelic.com/548C16BF.gpg'] 30 | ) 31 | end 32 | end 33 | 34 | context 'CentOS 6' do 35 | let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'centos', version: '6').converge(described_recipe) } 36 | 37 | it 'installs the New Relic yum repository' do 38 | expect(chef_run).to create_yum_repository('newrelic').with( 39 | description: 'New Relic packages for Enterprise Linux 5 - $basearch', 40 | baseurl: 'http://download.newrelic.com/pub/newrelic/el5/$basearch/', 41 | gpgkey: 'http://download.newrelic.com/548C16BF.gpg' 42 | ) 43 | end 44 | end 45 | 46 | context 'RedHat 6' do 47 | let(:chef_run) { ChefSpec::SoloRunner.new(platform: 'redhat', version: '6').converge(described_recipe) } 48 | 49 | it 'installs the New Relic yum repository' do 50 | expect(chef_run).to create_yum_repository('newrelic').with( 51 | description: 'New Relic packages for Enterprise Linux 5 - $basearch', 52 | baseurl: 'http://download.newrelic.com/pub/newrelic/el5/$basearch/', 53 | gpgkey: 'http://download.newrelic.com/548C16BF.gpg' 54 | ) 55 | end 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /spec/unit/server_monitor_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'newrelic_lwrp_test::server_monitor' do 4 | before do 5 | stub_resources 6 | end 7 | 8 | context 'Centos' do 9 | let(:chef_run) do 10 | ChefSpec::SoloRunner.new(log_level: LOG_LEVEL, platform: 'centos', version: '6', step_into: ['newrelic_server_monitor']) do |node| 11 | stub_node_resources(node) 12 | end.converge(described_recipe) 13 | end 14 | 15 | it 'Installs New Relic PHP agent' do 16 | expect(chef_run).to install_newrelic_server_monitor('Install') 17 | end 18 | 19 | it 'creates a yum_repository for newrelic' do 20 | expect(chef_run).to create_yum_repository('newrelic') 21 | end 22 | 23 | it 'installs nrsysmond' do 24 | expect(chef_run).to install_package('newrelic-sysmond') 25 | end 26 | 27 | it 'creates newrelic config template from nrsysmond.cfg.erb' do 28 | expect(chef_run).to render_file('/etc/newrelic/nrsysmond.cfg').with_content('0000ffff0000ffff0000ffff0000ffff0000ffff') 29 | end 30 | 31 | it 'enables service' do 32 | expect(chef_run).to enable_service('newrelic-sysmond') 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /templates/default/agent/dotnet/newrelic.config.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 16 | 17 | <% if @resource.use_proxy -%> 18 | 21 | domain="<%= @resource.proxy_domain %>" 22 | <% end -%> 23 | <% unless @resource.proxy_user.empty? -%> 24 | user="<%= @resource.proxy_user %>" 25 | <% end -%> 26 | <% unless @resource.proxy_password.empty? -%> 27 | password="<%= @resource.proxy_password %>" 28 | <% end -%> 29 | /> 30 | <% end -%> 31 | 32 | 33 | 38 | 39 | 40 | <% @resource.app_name.split(';').first(3).each do |app_name|%> 41 | <%= app_name %> 42 | <% end %> 43 | 44 | 45 | 46 | 47 | 48 | <% unless @resource.instrumentation_applications.empty? -%> 49 | 50 | <% @resource.instrumentation_applications.each do |app| -%> 51 | 52 | <% end -%> 53 | 54 | <% end -%> 55 | 56 | 57 | 58 | <% @resource.attributes_exclude.each do |excluded_attribute| -%> 59 | <%= excluded_attribute %> 60 | <% end -%> 61 | <% @resource.attributes_include.each do |included_attribute| -%> 62 | <%= included_attribute %> 63 | <% end -%> 64 | 65 | 66 | <% unless @resource.app_pools.empty? -%> 67 | 68 | 69 | <% @resource.app_pools.each do |pool| -%> 70 | 71 | <% end -%> 72 | 73 | <% end -%> 74 | 75 | 76 | 77 | 78 | 79 | <% @resource.ignored_exceptions.each do |ignored_exception| -%> 80 | <%= ignored_exception %> 81 | <% end -%> 82 | 83 | 84 | <% @resource.ignored_status_codes.each do |ignored_code| -%> 85 | <%= ignored_code %> 86 | <% end -%> 87 | 88 | 89 | 90 | 91 | 92 | 95 | 96 | <% @resource.tx_events_attributes_exclude.each do |excluded_attribute| -%> 97 | <%= excluded_attribute %> 98 | <% end -%> 99 | <% @resource.tx_events_attributes_include.each do |included_attribute| -%> 100 | <%= included_attribute %> 101 | <% end -%> 102 | 103 | 104 | 105 | 106 | <% unless @resource.labels.empty? -%> 107 | <%= @resource.labels %> 108 | <% end -%> 109 | 110 | 111 | 112 | <% @resource.browser_monitoring_req_paths_excluded.each do |path_regex| -%> 113 | 114 | <% end -%> 115 | 116 | 117 | <% @resource.browser_monitoring_attributes_exclude.each do |excluded_attribute| -%> 118 | <%= excluded_attribute %> 119 | <% end -%> 120 | <% @resource.browser_monitoring_attributes_include.each do |included_attribute| -%> 121 | <%= included_attribute %> 122 | <% end -%> 123 | 124 | 125 | 126 | 127 | 128 | 137 | 138 | <% @resource.tx_tracer_attributes_exclude.each do |excluded_attribute| -%> 139 | <%= excluded_attribute %> 140 | <% end -%> 141 | <% @resource.tx_tracer_attributes_include.each do |included_attribute| -%> 142 | <%= included_attribute %> 143 | <% end -%> 144 | 145 | 146 | 147 | 148 | <% @resource.ignored_thread_profiling_methods.each do |ignored_method| -%> 149 | <%= ignored_method %> 150 | <% end -%> 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /templates/default/agent/infrastructure/newrelic.yml.erb: -------------------------------------------------------------------------------- 1 | ################### 2 | # Generated by Chef 3 | ################### 4 | # 5 | # This file configures the New Relic Infrastructure Agent. 6 | 7 | license_key: <%= @resource.license %> 8 | <% unless @resource.display_name.nil? -%> 9 | display_name: <%= @resource.display_name %> 10 | <% end -%> 11 | <% unless @resource.logfile.nil? -%> 12 | log_file: <%= @resource.logfile %> 13 | <% end -%> 14 | <% unless @resource.verbose.nil? -%> 15 | verbose: <%= @resource.verbose %> 16 | <% end -%> 17 | <% unless @resource.proxy.nil? -%> 18 | proxy: <%= @resource.proxy %> 19 | <% end -%> 20 | <% unless @resource.strip_command_line.nil? -%> 21 | strip_command_line: <%= @resource.strip_command_line %> 22 | <% end -%> 23 | <% unless @resource.custom_attributes.empty? -%> 24 | custom_attributes: 25 | <% @resource.custom_attributes.each do |attribute, value|%> 26 | <%= attribute %>: <%= value %> 27 | <% end %> 28 | <% end -%> 29 | 30 | -------------------------------------------------------------------------------- /templates/default/agent/nodejs/newrelic.js.erb: -------------------------------------------------------------------------------- 1 | /** 2 | * ################### 3 | * # Generated by Chef 4 | * ################### 5 | * 6 | * New Relic agent configuration. 7 | * 8 | * See lib/config.defaults.js in the agent distribution for a more complete 9 | * description of configuration variables and their potential values. 10 | */ 11 | exports.config = { 12 | /** 13 | * Array of application names. 14 | */ 15 | app_name: ['<%= @resource.app_name %>'], 16 | /** 17 | * Your New Relic license key. 18 | */ 19 | license_key: '<%= @resource.license %>', 20 | logging: { 21 | /** 22 | * Level at which to log. 'trace' is most useful to New Relic when diagnosing 23 | * issues with the agent, 'info' and higher will impose the least overhead on 24 | * production applications. 25 | */ 26 | level: '<%= @resource.app_log_level %>'<% unless @resource.app_log_filepath.nil? -%>, 27 | filepath: '<%= @resource.app_log_filepath %>' 28 | <% else -%> 29 | 30 | <% end -%> 31 | }<% unless @resource.capture_params.nil? -%>, 32 | /** 33 | * Whether to capture request parameters in the request URL for slow transaction 34 | * traces and error traces. 35 | */ 36 | capture_params: <%= @resource.capture_params %> 37 | <% else -%> 38 | 39 | <% end -%><% unless @resource.ignored_params.nil? -%>, 40 | /** 41 | * Comma-delimited list of parameter names to ignore that otherwise would be 42 | * captured from request URLs in slow transaction traces and error traces. For 43 | * example, some parameters may contain sensitive values you do not want being 44 | * sent out of your application. 45 | */ 46 | ignored_params: <%= @resource.ignored_params.split(',') %> 47 | <% else -%> 48 | 49 | <% end -%> 50 | }; 51 | -------------------------------------------------------------------------------- /templates/default/agent/php/newrelic.cfg.erb: -------------------------------------------------------------------------------- 1 | ################### 2 | # Generated by Chef 3 | ################### 4 | 5 | # 6 | # This is a configuration template for the New Relic daemon - a communications 7 | # proxy between New Relic agents (such as the PHP agent) and the New Relic 8 | # data collectors. This configuration file is required *ONLY* if you need or 9 | # want to start the New Relic daemon at system boot time using init. In order 10 | # to do so you must execute the following commands (as root): 11 | # 12 | # For CentOS and RedHat systems: 13 | # /sbin/chkconfig newrelic-daemon on 14 | # 15 | # For Ubuntu and Debian systems: 16 | # /usr/sbin/update-rc.d newrelic-daemon defaults 90 10 17 | # /usr/sbin/update-rc.d newrelic-daemon enable 18 | # 19 | # For other systems please consult your documentation on how to enable and 20 | # disable services. 21 | # 22 | # For all systems: 23 | # /etc/init.d/newrelic-daemon start 24 | # 25 | # The startup scripts will only start the daemon if there is a valid daemon 26 | # configuration file in place. This file is, by default: 27 | # 28 | # /etc/newrelic/newrelic.cfg 29 | # 30 | # If that file does not exist, you can copy this template file to that 31 | # location and edit it to suit your system needs. 32 | # 33 | # By default the daemon is not started at system boot time, and does not use 34 | # the /etc/newrelic/newrelic.cfg file. Rather, the daemon is started by the 35 | # agent automatically on startup and is configured by the agent (for example 36 | # when using the PHP agent the daemon parameters are set in the global INI 37 | # file and all begin with 'newrelic.daemon'). 38 | # 39 | # There are certain circumstances under which you may want the daemon to be 40 | # started at boot time rather than by the agent. If you use a chroot jail for 41 | # running the agent in, if you have multiple web servers or FastCGI process 42 | # managers, or if you use PHP on the command line a lot for batch processing 43 | # then you may want to start the daemon once at system boot rather than having 44 | # the agent start it. 45 | # 46 | # Below are the various options you can change that affect the daemon. Each 47 | # one is explained in detail along with it's default value. 48 | # 49 | 50 | # 51 | # Setting: pidfile 52 | # Type : string 53 | # Purpose: Sets the name of the file that the daemon writes its process ID 54 | # (PID) to. This is used by the startup and shutdown script to know 55 | # which process to monitor or kill. 56 | # Default: OS-dependent. Uses a filename of newrelic-daemon.pid in the first 57 | # directory from the list /var/run or /var/pid that is found. 58 | <% if @resource.daemon_pidfile.nil? %> 59 | #pidfile=/var/run/newrelic-daemon.pid 60 | <% else %> 61 | pidfile=<%= @resource.daemon_pidfile %> 62 | <% end %> 63 | 64 | # 65 | # Setting: logfile 66 | # Type : string 67 | # Purpose: Sets the name of the file to record log messages in. If this file 68 | # does not exist it is created. If it cannot be created the daemon 69 | # will not start up. The amount of information sent to this file is 70 | # controlled by the loglevel settings, defined below. 71 | # Default: /var/log/newrelic/newrelic-daemon.log 72 | <% if @resource.daemon_logfile.nil? %> 73 | #logfile=/var/log/newrelic/newrelic-daemon.log 74 | <% else %> 75 | logfile=<%= @resource.daemon_logfile %> 76 | <% end %> 77 | 78 | # 79 | # Setting: loglevel 80 | # Type : string 81 | # Purpose: Sets the level of detail of log messages sent to the log file. This 82 | # variable can control the log level for different subsystem at 83 | # different levels, although such custom usage should only be done at 84 | # the request of New Relic technical support. The simplest setting is 85 | # to use one of the following keywords, in increasing order of detail: 86 | # error - only error messages 87 | # warning - only warning and error messages 88 | # info - only minimal startup and shutdown info 89 | # verbose - slightly more verbose than info, not commonly used 90 | # debug - very verbose, includes messages only relevant to support 91 | # verbosedebug - extremely verbose, creates massive log files 92 | # Default: info 93 | <% if @resource.daemon_loglevel.nil? %> 94 | #loglevel=info 95 | <% else %> 96 | loglevel=<%= @resource.daemon_loglevel %> 97 | <% end %> 98 | 99 | # 100 | # Setting: port 101 | # Type : Integer (1-65534) 102 | # Purpose: Sets the TCP port on which the daemon will listen for connections 103 | # from agents (agents in this case includes Apache / php-fpm worker 104 | # processes, the command line, or any other agent source). In order 105 | # to use a port in the range 1-1023, the daemon must be started by 106 | # the super-user. This is a fundamental OS limitation and not one 107 | # imposed by the daemon itself. 108 | # Default: 33142 109 | <% if @resource.daemon_port.nil? %> 110 | #port=33142 111 | <% else %> 112 | port=<%= @resource.daemon_port %> 113 | <% end %> 114 | 115 | # 116 | # Setting: ssl 117 | # Type : boolean 118 | # Purpose: If you prefer the daemon to use the secure HTTP (https) protocol 119 | # when communicating with the New Relic collector servers, set this 120 | # to true. Please note that in order for this to work the daemon must 121 | # be able to find a Certificate Authority (CA) list. On startup the 122 | # daemon will attempt to find such a list in the usual places, but 123 | # you may need to use the ssl_ca_bundle or ssl_ca_path variables 124 | # below. 125 | # Default: false 126 | <% if @resource.daemon_ssl.nil? %> 127 | #ssl=false 128 | <% else %> 129 | ssl=<%= @resource.daemon_ssl %> 130 | <% end %> 131 | 132 | # 133 | # Setting: proxy 134 | # Type : string 135 | # Purpose: Some networks are configured to require the use of an egress proxy 136 | # server in order to communicate with the outside world. Since the 137 | # daemon needs to communicate with the New Relic data collection 138 | # servers you may need to instruct it to use a proxy server. Your 139 | # system or network administrator should be able to provide you with 140 | # the details. 141 | # This string is in the form [user[:password]]@hostname[:port] with 142 | # the user, password and port fields being optional. Some examples: 143 | # myusername:secret@10.1.1.1:12345 144 | # someuser@proxy.mydomain.com:4321 145 | # proxy.mydomain.com 146 | # Default: none 147 | <% if @resource.daemon_proxy.nil? %> 148 | #proxy= 149 | <% else %> 150 | proxy=<%= @resource.daemon_proxy %> 151 | <% end %> 152 | 153 | # 154 | # Setting: ssl_ca_bundle 155 | # Type : string 156 | # Purpose: If you have the "ssl" option above enabled, and the daemon cannot 157 | # find a suitable Certificate Authority (CA) list, this is one of the 158 | # options you can use to point it to the CA list to use. If your SSL 159 | # installation uses a "bundle" - i.e. a single file which contains a 160 | # list of CA's - then this option should point to that bundle file. 161 | # Default: Looks for one of two files: /etc/pki/tls/certs/ca-bundle.crt or 162 | # /etc/ssl/certs/ca-certificates.crt. 163 | # 164 | <% if @resource.daemon_ssl_ca_bundle.nil? %> 165 | #ssl_ca_bundle= 166 | <% else %> 167 | ssl_ca_bundle=<%= @resource.daemon_ssl_ca_bundle %> 168 | <% end %> 169 | 170 | # 171 | # Setting: ssl_ca_path 172 | # Type : string 173 | # Purpose: See ssl_ca_bundle above. This option should be used if your SSL 174 | # installation uses a sub-directory with a list of CA certificates. 175 | # Set this variable to point to that directory. 176 | # Default: /etc/ssl/certs 177 | <% if @resource.daemon_ssl_ca_path.nil? %> 178 | #ssl_ca_path= 179 | <% else %> 180 | ssl_ca_path=<%= @resource.daemon_ssl_ca_path %> 181 | <% end %> 182 | 183 | # 184 | # Setting: max_threads 185 | # Type : integer (4-128) 186 | # Purpose: Internally the daemon uses a "pool" of worker threads to deal with 187 | # activity from each connected agent. In certain very busy setups 188 | # you may need to increase this number in order to service all of 189 | # those connections quickly enough. Each extra thread you create does 190 | # have resource usage (memory, CPU etc.) implications so do not just 191 | # increase this arbitrarily. 192 | # Default: 8 193 | <% if @resource.daemon_max_threads.nil? %> 194 | #max_threads=8 195 | <% else %> 196 | max_threads=<%= @resource.daemon_max_threads %> 197 | <% end %> 198 | 199 | # 200 | # Setting: collector_host 201 | # Type : string 202 | # Purpose: Sets the host name of the New Relic data collector host to use. 203 | # Please note that this is NOT any form of local host. It refers to 204 | # the New Relic provided host. There is very little reason to ever 205 | # change this from the default except in certain very special 206 | # circumstances, and then only on instruction from a New Relic sales 207 | # person or support staff member. 208 | # Default: collector.newrelic.com 209 | <% if @resource.daemon_collector_host.nil? %> 210 | #collector_host=collector.newrelic.com 211 | <% else %> 212 | collector_host=<%= @resource.daemon_collector_host %> 213 | <% end %> 214 | 215 | <% @resource.additional_config.each do |config, value|%> 216 | <%= config %>=<%= value %> 217 | <% end %> 218 | -------------------------------------------------------------------------------- /templates/default/agent/python/newrelic.ini.erb: -------------------------------------------------------------------------------- 1 | ################### 2 | # Generated by Chef 3 | ################### 4 | 5 | # --------------------------------------------------------------------------- 6 | 7 | # 8 | # This file configures the New Relic Python Agent. 9 | # 10 | # The path to the configuration file should be supplied to the function 11 | # newrelic.agent.initialize() when the agent is being initialized. 12 | # 13 | # The configuration file follows a structure similar to what you would 14 | # find for Microsoft Windows INI files. For further information on the 15 | # configuration file format see the Python ConfigParser documentation at: 16 | # 17 | # http://docs.python.org/library/configparser.html 18 | # 19 | # For further discussion on the behaviour of the Python agent that can 20 | # be configured via this configuration file see: 21 | # 22 | # http://newrelic.com/docs/python/python-agent-configuration 23 | # 24 | 25 | # --------------------------------------------------------------------------- 26 | 27 | # Here are the settings that are common to all environments. 28 | 29 | [newrelic] 30 | 31 | # You must specify the license key associated with your New 32 | # Relic account. This key binds the Python Agent's data to your 33 | # account in the New Relic service. 34 | license_key = <%= @resource.license %> 35 | 36 | # The appplication name. Set this to be the name of your 37 | # application as you would like it to show up in New Relic UI. 38 | # The UI will then auto-map instances of your application into a 39 | # entry on your home dashboard page. 40 | <% if @resource.app_name.nil? %> 41 | app_name = Python Application 42 | <% else %> 43 | app_name = <%= @resource.app_name %> 44 | <% end %> 45 | 46 | # In order for high security to be enabled, this property must be set to true and the high security property in the New Relic user 47 | # interface must be enabled. Enabling high security means SSL is turned on, request and message queue parameters are not collected, and 48 | # SQL cannot be sent to New Relic in its raw form. 49 | <% unless @resource.high_security.nil? %> 50 | high_security: <%= @resource.high_security %> 51 | <% end %> 52 | 53 | # When "true", the agent collects performance data about your 54 | # application and reports this data to the New Relic UI at 55 | # newrelic.com. This global switch is normally overridden for 56 | # each environment below. 57 | <% if @resource.enabled.nil? %> 58 | monitor_mode = true 59 | <% else %> 60 | monitor_mode = <%= @resource.enabled %> 61 | <% end %> 62 | 63 | # Sets the name of a file to log agent messages to. Useful for 64 | # debugging any issues with the agent. This is not set by 65 | # default as it is not known in advance what user your web 66 | # application processes will run as and where they have 67 | # permission to write to. Whatever you set this to you must 68 | # ensure that the permissions for the containing directory and 69 | # the file itself are correct, and that the user that your web 70 | # application runs as can write to the file. If not able to 71 | # write out a log file, it is also possible to say "stderr" and 72 | # output to standard error output. This would normally result in 73 | # output appearing in your web server log. 74 | <% if @resource.logfile.nil? %> 75 | log_file = /tmp/newrelic-python-agent.log 76 | <% else %> 77 | log_file = <%= @resource.logfile %> 78 | <% end %> 79 | 80 | # Sets the level of detail of messages sent to the log file, if 81 | # a log file location has been provided. Possible values, in 82 | # increasing order of detail, are: "critical", "error", "warning", 83 | # "info" and "debug". When reporting any agent issues to New 84 | # Relic technical support, the most useful setting for the 85 | # support engineers is "debug". However, this can generate a lot 86 | # of information very quickly, so it is best not to keep the 87 | # agent at this level for longer than it takes to reproduce the 88 | # problem you are experiencing. 89 | <% if @resource.loglevel.nil? %> 90 | log_level = info 91 | <% else %> 92 | log_level = <%= @resource.loglevel %> 93 | <% end %> 94 | 95 | # The Python Agent communicates with the New Relic service using 96 | # HTTP by default. If you want to communicate via HTTPS to 97 | # increase security, then turn on SSL by setting this value to 98 | # true. Note, this will result in increased CPU overhead to 99 | # perform the encryption involved in SSL communication, but this 100 | # work is done asynchronously to the threads that process your 101 | # application code, so it should not impact response times. 102 | <% if @resource.daemon_ssl.nil? %> 103 | ssl = false 104 | <% else %> 105 | ssl = <%= @resource.daemon_ssl %> 106 | <% end %> 107 | 108 | # The Python Agent will attempt to connect directly to the New 109 | # Relic service. If there is an intermediate firewall between 110 | # your host and the New Relic service that requires you to use a 111 | # HTTP proxy, then you should set both the "proxy_host" and 112 | # "proxy_port" settings to the required values for the HTTP 113 | # proxy. The "proxy_user" and "proxy_pass" settings should 114 | # additionally be set if proxy authentication is implemented by 115 | # the HTTP proxy. 116 | # proxy_host = hostname 117 | # proxy_port = 8080 118 | # proxy_user = 119 | # proxy_pass = 120 | 121 | # Tells the transaction tracer and error collector (when 122 | # enabled) whether or not to capture the query string for the 123 | # URL and send it as the request parameters for display in the 124 | # UI. When "true", it is still possible to exclude specific 125 | # values from being captured using the "ignored_params" setting. 126 | <% if @resource.capture_params.nil? %> 127 | capture_params = false 128 | <% else %> 129 | capture_params = <%= @resource.capture_params %> 130 | <% end %> 131 | 132 | # Space separated list of variables that should be removed from 133 | # the query string captured for display as the request 134 | # parameters in the UI. 135 | <% if @resource.ignored_params.nil? %> 136 | ignored_params = 137 | <% else %> 138 | ignored_params = <%= @resource.ignored_params %> 139 | <% end %> 140 | 141 | # The transaction tracer captures deep information about slow 142 | # transactions and sends this to the UI on a periodic basis. The 143 | # transaction tracer is enabled by default. Set this to "false" 144 | # to turn it off. 145 | <% if @resource.transaction_tracer_enable.nil? %> 146 | transaction_tracer.enabled = true 147 | <% else %> 148 | transaction_tracer.enabled = <%= @resource.transaction_tracer_enable %> 149 | <% end %> 150 | 151 | # Threshold in seconds for when to collect a transaction trace. 152 | # When the response time of a controller action exceeds this 153 | # threshold, a transaction trace will be recorded and sent to 154 | # the UI. Valid values are any positive float value, or (default) 155 | # "apdex_f", which will use the threshold for a dissatisfying 156 | # Apdex controller action - four times the Apdex T value. 157 | <% if @resource.transaction_tracer_threshold.nil? %> 158 | transaction_tracer.transaction_threshold = apdex_f 159 | <% else %> 160 | transaction_tracer.transaction_threshold = <%= @resource.transaction_tracer_threshold %> 161 | <% end %> 162 | 163 | # When the transaction tracer is on, SQL statements can 164 | # optionally be recorded. The recorder has three modes, "off" 165 | # which sends no SQL, "raw" which sends the SQL statement in its 166 | # original form, and "obfuscated", which strips out numeric and 167 | # string literals. 168 | <% if @resource.transaction_tracer_record_sql.nil? %> 169 | transaction_tracer.record_sql = obfuscated 170 | <% else %> 171 | transaction_tracer.record_sql = <%= @resource.transaction_tracer_record_sql %> 172 | <% end %> 173 | 174 | # Threshold in seconds for when to collect stack trace for a SQL 175 | # call. In other words, when SQL statements exceed this 176 | # threshold, then capture and send to the UI the current stack 177 | # trace. This is helpful for pinpointing where long SQL calls 178 | # originate from in an application. 179 | <% if @resource.transaction_tracer_stack_trace_threshold.nil? %> 180 | transaction_tracer.stack_trace_threshold = 0.5 181 | <% else %> 182 | transaction_tracer.stack_trace_threshold = <%= @resource.transaction_tracer_stack_trace_threshold %> 183 | <% end %> 184 | 185 | # Determines whether the agent will capture query plans for slow 186 | # SQL queries. Only supported in MySQL and PostgreSQL. Set this 187 | # to "false" to turn it off. 188 | <% if @resource.transaction_tracer_slow_sql.nil? %> 189 | transaction_tracer.explain_enabled = true 190 | <% else %> 191 | transaction_tracer.explain_enabled = <%= @resource.transaction_tracer_slow_sql %> 192 | <% end %> 193 | 194 | # Threshold for query execution time below which query plans 195 | # will not not be captured. Relevant only when "explain_enabled" 196 | # is true. 197 | <% if @resource.transaction_tracer_explain_threshold.nil? %> 198 | transaction_tracer.explain_threshold = 0.5 199 | <% else %> 200 | transaction_tracer.explain_threshold = <%= @resource.transaction_tracer_explain_threshold %> 201 | <% end %> 202 | 203 | # Space separated list of function or method names in form 204 | # 'module:function' or 'module:class.function' for which 205 | # additional function timing instrumentation will be added. 206 | transaction_tracer.function_trace = 207 | 208 | # The error collector captures information about uncaught 209 | # exceptions or logged exceptions and sends them to UI for 210 | # viewing. The error collector is enabled by default. Set this 211 | # to "false" to turn it off. 212 | <% if @resource.error_collector_enable.nil? %> 213 | error_collector.enabled = true 214 | <% else %> 215 | error_collector.enabled = <%= @resource.error_collector_enable %> 216 | <% end %> 217 | 218 | # To stop specific errors from reporting to the UI, set this to 219 | # a space separated list of the Python exception type names to 220 | # ignore. The exception name should be of the form 'module:class'. 221 | <% if @resource.error_collector_ignore_errors.nil? %> 222 | error_collector.ignore_errors = 223 | <% else %> 224 | error_collector.ignore_errors = <%= @resource.error_collector_ignore_errors %> 225 | <% end %> 226 | 227 | # Browser monitoring is the Real User Monitoring feature of the UI. 228 | # For those Python web frameworks that are supported, this 229 | # setting enables the auto-insertion of the browser monitoring 230 | # JavaScript fragments. 231 | <% if @resource.browser_monitoring_auto_instrument.nil? %> 232 | browser_monitoring.auto_instrument = true 233 | <% else %> 234 | browser_monitoring.auto_instrument = <%= @resource.browser_monitoring_auto_instrument %> 235 | <% end %> 236 | 237 | # A thread profiling session can be scheduled via the UI when 238 | # this option is enabled. The thread profiler will periodically 239 | # capture a snapshot of the call stack for each active thread in 240 | # the application to construct a statistically representative 241 | # call tree. 242 | <% if @resource.thread_profiler_enable.nil? %> 243 | thread_profiler.enabled = true 244 | <% else %> 245 | thread_profiler.enabled = <%= @resource.thread_profiler_enable %> 246 | <% end %> 247 | 248 | # Enable or disable the cross application tracer. 249 | # The cross application tracer inserts HTTP headers into outbound requests 250 | # and the response in order to link together web transaction metrics and 251 | # transaction traces between applications. 252 | <% if @resource.cross_application_tracer_enable.nil? %> 253 | # cross_application_tracer.enabled = true 254 | <% else %> 255 | cross_application_tracer.enabled = <%= @resource.cross_application_tracer_enable %> 256 | <% end %> 257 | 258 | <% unless @resource.feature_flag.nil? %> 259 | # Feature flag 260 | # eg. use for improved Tornado instrumentation 261 | # (https://docs.newrelic.com/docs/release-notes/agent-release-notes/python-release-notes/python-agent-232028) 262 | feature_flag = <%= @resource.feature_flag %> 263 | <% end %> 264 | -------------------------------------------------------------------------------- /templates/default/agent/server_monitor/nrsysmond.cfg.erb: -------------------------------------------------------------------------------- 1 | ################### 2 | # Generated by Chef 3 | ################### 4 | 5 | # 6 | # New Relic Server Monitor configuration file. 7 | # 8 | # Lines that begin with a # are comment lines and are ignored by the server 9 | # monitor. For those options that have command line equivalents, if the 10 | # option is specified on the command line it will over-ride any value set 11 | # in this file. 12 | # 13 | 14 | # 15 | # Option : license_key 16 | # Value : 40-character hexadecimal string provided by New Relic. This is 17 | # required in order for the server monitor to start. 18 | # Default: none 19 | # 20 | license_key=<%= @resource.license %> 21 | 22 | # 23 | # Option : loglevel 24 | # Value : Level of detail you want in the log file (as defined by the logfile 25 | # setting below. Valid values are (in increasing levels of verbosity): 26 | # error - show errors only 27 | # warning - show errors and warnings 28 | # info - show minimal additional information messages 29 | # verbose - show more detailed information messages 30 | # debug - show debug messages 31 | # verbosedebug - show very detailed debug messages 32 | # Default: error 33 | # Note : Can also be set with the -d command line option. 34 | # 35 | <% if @resource.loglevel.nil? %> 36 | loglevel=info 37 | <% else %> 38 | loglevel=<%= @resource.loglevel %> 39 | <% end %> 40 | 41 | # 42 | # Option : logfile 43 | # Value : Name of the file where the server monitor will store it's log 44 | # messages. The amount of detail stored in this file is controlled 45 | # by the loglevel option (above). 46 | # Default: none. However it is highly recommended you set a value for this. 47 | # Note : Can also be set with the -l command line option. 48 | # 49 | <% if @resource.logfile.nil? %> 50 | logfile=/var/log/newrelic/nrsysmond.log 51 | <% else %> 52 | logfile=<%= @resource.logfile %> 53 | <% end %> 54 | 55 | # 56 | # Option : proxy 57 | # Value : The name and optional login credentials of the proxy server to use 58 | # for all communication with the New Relic collector. In its simplest 59 | # form this setting is just a hostname[:port] setting. The default 60 | # port if none is specified is 1080. If your proxy requires a user 61 | # name, use the syntax user@host[:port]. If it also requires a 62 | # password use the format user:password@host[:port]. For example: 63 | # fred:secret@proxy.mydomain.com:8181 64 | # Default: none (use a direct connection) 65 | # 66 | <% if @resource.proxy.nil? %> 67 | #proxy= 68 | <% else %> 69 | proxy=<%= @resource.proxy %> 70 | <% end %> 71 | 72 | # 73 | # Option : ssl 74 | # Value : Whether or not to use the Secure Sockets Layer (SSL) for all 75 | # communication with the New Relic collector. Possible values are 76 | # true/on or false/off. In certain rare cases you may need to modify 77 | # the SSL certificates settings below. 78 | # Default: false 79 | # 80 | <% if @resource.ssl.nil? %> 81 | #ssl=false 82 | <% else %> 83 | ssl=<%= @resource.ssl %> 84 | <% end %> 85 | 86 | # 87 | # Option : ssl_ca_bundle 88 | # Value : The name of a PEM-encoded Certificate Authority (CA) bundle to use 89 | # for SSL connections. This very rarely needs to be set. The monitor 90 | # will attempt to find the bundle in the most common locations. If 91 | # you need to use SSL and the monitor is unable to locate a CA bundle 92 | # then either set this value or the ssl_ca_path option below. 93 | # Default: /etc/ssl/certs/ca-certificates.crt or 94 | # /etc/pki/tls/certs/ca-bundle.crt 95 | # Note : Can also be set with the -b command line option. 96 | # 97 | <% if @resource.ssl_ca_bundle.nil? %> 98 | #ssl_ca_bundle=/path/to/your/bundle.crt 99 | <% else %> 100 | ssl_ca_bundle=<%= @resource.ssl_ca_bundle %> 101 | <% end %> 102 | 103 | # 104 | # Option : ssl_ca_path 105 | # Value : If your SSL installation does not use CA bundles, but rather has a 106 | # directory with PEM-encoded Certificate Authority files, set this 107 | # option to the name of the directory that contains all the CA files. 108 | # Default: /etc/ssl/certs 109 | # Note : Can also be set with the -S command line option. 110 | # 111 | <% if @resource.ssl_ca_path.nil? %> 112 | #ssl_ca_path=/etc/ssl/certs 113 | <% else %> 114 | ssl_ca_path=<%= @resource.ssl_ca_path %> 115 | <% end %> 116 | 117 | # 118 | # Option : hostname 119 | # Value : A meaningful host name to be displayed in the user interface. On 120 | # many cloud based nodes the host name is incomprehensible and makes 121 | # finding a specific host problematic. Using this option will allow 122 | # you to assign a more meaningful name to a host. You must ensure 123 | # that all your host names are unique. 124 | # Default: Whatever the system calls the host. 125 | # Note : Can also be set with the -n command line option. 126 | # 127 | <% if @resource.hostname.nil? %> 128 | #hostname= 129 | <% else %> 130 | hostname=<%= @resource.hostname %> 131 | <% end %> 132 | 133 | # 134 | # Option : labels 135 | # 136 | # Value : A dictionary of label names and values for categories that will be 137 | # applied to the data sent from this agent. May also be expressed as 138 | # a semicolon delimited string of colon-separated pairs; 139 | # for example, labels=Server:One;Data Center:Primary;. 140 | # Default: nil 141 | <% if @resource.labels.nil? %> 142 | #labels= 143 | <% else %> 144 | labels=<%= @resource.labels %> 145 | <% end %> 146 | 147 | # 148 | # Option : pidfile 149 | # Value : Name of a file where the server monitoring daemon will store it's 150 | # process ID (PID). This is used by the startup and shutdown script 151 | # to determine if the monitor is already running, and to start it up 152 | # or shut it down. 153 | # Default: /tmp/nrsysmond.pid 154 | # Note : Can also be set with the -p command line option. 155 | # 156 | <% if @resource.pidfile.nil? %> 157 | #pidfile=/var/run/newrelic/nrsysmond.pid 158 | <% else %> 159 | pidfile=<%= @resource.pidfile %> 160 | <% end %> 161 | 162 | # 163 | # Option : collector_host 164 | # Value : The name of the New Relic collector to connect to. This should only 165 | # ever be changed on advise from a New Relic support staff member. 166 | # The format is host[:port]. Using a port number of 0 means the default 167 | # port, which is 80 (if not using the ssl option - see below) or 443 168 | # if SSL is enabled. If the port is omitted the default value is used. 169 | # Default: collector.newrelic.com 170 | # 171 | <% if @resource.collector_host.nil? %> 172 | #collector_host=collector.newrelic.com 173 | <% else %> 174 | collector_host=<%= @resource.collector_host %> 175 | <% end %> 176 | 177 | # 178 | # Option : timeout 179 | # Value : How long the monitor should wait to contact the collector host. If 180 | # the connection cannot be established in this period of time, the 181 | # monitor will progressively back off in 15-second increments, up to 182 | # a maximum of 300 seconds. Once the initial connection has been 183 | # established, this value is reset back to the value specified here 184 | # (or the default). This then sets the maximum time to wait for 185 | # a connection to the collector to report data. There is no back-off 186 | # once the original connection has been made. The value is in seconds. 187 | # Default: 30 188 | # 189 | <% if @resource.timeout.nil? %> 190 | #timeout=30 191 | <% else %> 192 | timeout=<%= @resource.timeout %> 193 | <% end %> 194 | 195 | # 196 | # Other Options : refer to the newrelic documentation for the details 197 | # https://docs.newrelic.com/docs/servers/new-relic-servers-linux/installation-configuration/linux-configuration-new-relic-servers 198 | # 199 | <% unless @resource.other_options.empty? %> 200 | <% @resource.other_options.each do | op_key, op_value | %> 201 | <%= op_key %>=<%= op_value %> 202 | <% end %> 203 | <% end %> 204 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/newrelic_lwrp_test/README.md: -------------------------------------------------------------------------------- 1 | This is a test cookbook 2 | 3 | ## Usage 4 | 5 | ``` 6 | newrelic_agent_php 'Install' do 7 | license node['newrelic']['license'] 8 | app_name 'test_app' 9 | service_name 'httpd' 10 | config_file '/etc/php.d/newrelic.ini' 11 | startup_mode 'external' 12 | end 13 | ``` 14 | 15 | * ```license:``` New Relic license key 16 | * ```app_name:``` The name of the application, found in the newrelic.yml file 17 | * ```service_name:``` Webserver service (apache2, httpd, nginx) If this is defined the install will take care of reloading the webserver. If not then the recipe will need to handle the reload. 18 | * ```config_file:``` The New Relic php agent config file, depends on your php external configuration directory; e.g. /etc/php5/conf.d/newrelic.ini, /etc/php5/mods-available/newrelic.ini, ... Defaults to nil 19 | * ```startup_mode:``` The newrelic-daemon startup mode ("agent"/"external"), defaults to "agent". [newrelic-daemon startup modes](https://newrelic.com/docs/php/newrelic-daemon-startup-modes) 20 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/newrelic_lwrp_test/metadata.rb: -------------------------------------------------------------------------------- 1 | name 'newrelic_lwrp_test' 2 | maintainer 'David Joos' 3 | maintainer_email 'development@davidjoos.com' 4 | license 'MIT' 5 | description 'Installs/Configures newrelic_poc' 6 | version '0.1.0' 7 | 8 | depends 'apache2' 9 | depends 'java' 10 | depends 'newrelic' 11 | depends 'nodejs' 12 | depends 'php' 13 | depends 'tomcat' 14 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/newrelic_lwrp_test/recipes/agent_dotnet.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic_lwrp_test 3 | # Recipe:: agent_dotnet 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | newrelic_agent_dotnet 'Install' do 9 | license node['newrelic']['license'] 10 | app_name 'My Application;Sub Application' 11 | end 12 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/newrelic_lwrp_test/recipes/agent_infrastructure.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic_lwrp_test 3 | # Recipe:: agent_infrastructure 4 | # 5 | # Copyright:: (c) 2017, David Joos 6 | # 7 | 8 | newrelic_agent_infrastructure 'Install' do 9 | on_host_integrations_enable true 10 | end 11 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/newrelic_lwrp_test/recipes/agent_java.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic_lwrp_test 3 | # Recipe:: agent_java 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | include_recipe 'java' 9 | 10 | tomcat_install 'java_test_app' do 11 | tomcat_user 'tomcat_user' 12 | tomcat_group 'tomcat_group' 13 | end 14 | 15 | newrelic_agent_java 'Install' do 16 | license node['newrelic']['license'] 17 | install_dir node['newrelic']['java_agent']['install_dir'] 18 | version node['newrelic']['java_agent']['version'] 19 | app_name 'java_test_app' 20 | app_user 'root' 21 | app_group 'root' 22 | class_transformer_config node['newrelic']['java_agent']['class_transformer_config'] 23 | end 24 | 25 | # newrelic_agent_java 'Remove' do 26 | # action :remove 27 | # end 28 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/newrelic_lwrp_test/recipes/agent_nodejs.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic_lwrp_test 3 | # Recipe:: agent_nodejs 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | include_recipe 'nodejs' 9 | 10 | directory '/var/mynode_app' do 11 | mode '0755' 12 | recursive true 13 | action :create 14 | end 15 | 16 | newrelic_agent_nodejs '/var/mynode_app' do 17 | license node['newrelic']['license'] 18 | # version one dot thirty eight dot two has invalid readable stream version two dot two dot three 19 | version '1.37.2' 20 | app_name 'my_nodejs_app' 21 | enabled false 22 | app_log_level 'debug' 23 | app_log_filepath '/var/mynode_app/mylog.log' 24 | end 25 | 26 | # newrelic_agent_nodejs '/var/mynode_app' do 27 | # license node['newrelic']['license'] 28 | # action :remove 29 | # end 30 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/newrelic_lwrp_test/recipes/agent_nodejs_recipe.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic_lwrp_test 3 | # Recipe:: agent_nodejs_recipe 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | # version one dot thirty eight dot two has invalid readable stream version two dot two dot three 9 | nodeapp = { 'app_path' => '/var/mynode_app', 'app_name' => 'My Node Application', 'app_log_level' => 'info', 'app_log_filepath' => '/var/mynode_app/newrelic.log', 'version' => '1.37.2' } 10 | node.default['newrelic']['nodejs_agent']['apps'] = [nodeapp] 11 | 12 | directory '/var/mynode_app' do 13 | mode '0755' 14 | recursive true 15 | action :create 16 | end 17 | 18 | include_recipe 'nodejs' 19 | include_recipe 'newrelic::nodejs_agent' 20 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/newrelic_lwrp_test/recipes/agent_php.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic_lwrp_test 3 | # Recipe:: agent_php 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | include_recipe 'apache2' 9 | 10 | node.normal['php']['pear'] = 'pear' 11 | include_recipe 'php' 12 | 13 | newrelic_agent_php 'Install' do 14 | license node['newrelic']['license'] 15 | service_name node['newrelic']['php_agent']['web_server']['service_name'] 16 | config_file node['newrelic']['php_agent']['php_config'] 17 | enable_module node['newrelic']['php_agent']['enable_module'] 18 | execute_php5enmod node['newrelic']['php_agent']['execute_php5enmod'] 19 | startup_mode 'external' 20 | end 21 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/newrelic_lwrp_test/recipes/agent_python.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic_lwrp_test 3 | # Recipe:: agent_python 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | newrelic_agent_python 'Install' do 9 | license node['newrelic']['license'] 10 | config_file '/etc/newrelic/newrelic.ini' 11 | cookbook 'newrelic' 12 | source 'agent/python/newrelic.ini.erb' 13 | app_name 'my_python_app' 14 | enabled true 15 | logfile '/etc/newrelic/log.log' 16 | loglevel 'debug' 17 | high_security false 18 | daemon_ssl false 19 | capture_params true 20 | transaction_tracer_enable true 21 | transaction_tracer_threshold 'apdex_f' 22 | transaction_tracer_record_sql 'off' 23 | transaction_tracer_stack_trace_threshold '0.6' 24 | transaction_tracer_slow_sql false 25 | transaction_tracer_explain_threshold '0.7' 26 | thread_profiler_enable false 27 | error_collector_enable false 28 | browser_monitoring_auto_instrument true 29 | cross_application_tracer_enable false 30 | end 31 | 32 | # newrelic_agent_python 'remove' do 33 | # action :remove 34 | # end 35 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/newrelic_lwrp_test/recipes/agent_python_recipe.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic_lwrp_test 3 | # Recipe:: agent_python_recipe 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | node.default['newrelic']['application_monitoring']['app_name'] = 'My Python Application' 9 | node.default['newrelic']['application_monitoring']['error_collector']['enable'] = 'false' 10 | node.default['newrelic']['application_monitoring']['transaction_tracer']['enable'] = true 11 | node.default['newrelic']['application_monitoring']['enabled'] = 'true' 12 | 13 | include_recipe 'newrelic::python_agent' 14 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/newrelic_lwrp_test/recipes/agent_ruby.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic_lwrp_test 3 | # Recipe:: agent_java 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | package 'ruby' 9 | 10 | package node['rubygems'] do 11 | action :install 12 | end 13 | 14 | newrelic_agent_ruby 'Install' do 15 | license node['newrelic']['license'] 16 | app_name 'ruby_test_app' 17 | app_user 'root' 18 | app_group 'root' 19 | version node['newrelic']['ruby_agent']['version'] 20 | end 21 | 22 | # newrelic_agent_ruby 'Remove' do 23 | # action :remove 24 | # end 25 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/newrelic_lwrp_test/recipes/lwrp_yml.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic_lwrp_test 3 | # Recipe:: lwrp_yml 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | include_recipe 'java' 9 | 10 | tomcat_install 'java_test_app' do 11 | tomcat_user 'tomcat_user' 12 | tomcat_group 'tomcat_group' 13 | end 14 | 15 | newrelic_yml "#{node['newrelic']['java_agent']['install_dir']}/newrelic.yml" do 16 | app_name 'java_test_app' 17 | agent_type 'java' 18 | end 19 | -------------------------------------------------------------------------------- /test/fixtures/cookbooks/newrelic_lwrp_test/recipes/server_monitor.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook:: newrelic_lwrp_test 3 | # Recipe:: server_monitor 4 | # 5 | # Copyright:: (c) 2016, David Joos 6 | # 7 | 8 | newrelic_server_monitor 'Install' do 9 | license node['newrelic']['license'] 10 | end 11 | 12 | # newrelic_server_remove 'Remove' do 13 | # action :remove 14 | # end 15 | -------------------------------------------------------------------------------- /test/integration/default/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'newrelic::default' do 4 | describe yumrepo('newrelic'), if: os[:family] == 'redhat' do 5 | it { is_expected.to exist } 6 | it { is_expected.to be_enabled } 7 | end 8 | 9 | describe file('/etc/apt/sources.list.d/newrelic.list'), if: %w(debian ubuntu).include?(os[:family]) do 10 | it { is_expected.to be_file } 11 | end 12 | 13 | describe package 'newrelic-sysmond' do 14 | it { is_expected.to be_installed } 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /test/integration/helpers/serverspec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | set :backend, :exec 4 | -------------------------------------------------------------------------------- /test/integration/infrastructure-agent/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe yumrepo('newrelic-infra'), if: os[:family] == 'redhat' do 4 | it { is_expected.to exist } 5 | it { is_expected.to be_enabled } 6 | end 7 | describe file('/etc/apt/sources.list.d/newrelic-infra.list'), if: %w(debian ubuntu).include?(os[:family]) do 8 | it { is_expected.to be_file } 9 | end 10 | describe file('/etc/newrelic-infra.yml') do 11 | it { is_expected.to be_file } 12 | it { is_expected.to be_owned_by 'root' } 13 | it { is_expected.to be_mode 600 } 14 | end 15 | %w(newrelic-infra newrelic-infra-integrations).each do |pkg| 16 | describe package pkg do 17 | it { is_expected.to be_installed } 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /test/integration/java-agent/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe file('/opt/tomcat_java_test_app/newrelic.jar') do 4 | it { is_expected.to exist } 5 | end 6 | -------------------------------------------------------------------------------- /test/integration/nodejs-agent-recipe/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe yumrepo('newrelic'), if: os[:family] == 'redhat' do 4 | it { is_expected.to exist } 5 | it { is_expected.to be_enabled } 6 | end 7 | describe file('/etc/apt/sources.list.d/newrelic.list'), if: %w(debian ubuntu).include?(os[:family]) do 8 | it { is_expected.to be_file } 9 | end 10 | 11 | describe command('cd /var/mynode_app/ && npm ls') do 12 | its(:exit_status) { should eq 0 } 13 | its(:stdout) { should match(/newrelic@/) } 14 | end 15 | 16 | describe file('/var/mynode_app/newrelic.js') do 17 | its(:content) { should match(/license_key: '0000ffff0000ffff0000ffff0000ffff0000ffff',/) } 18 | its(:content) { should match(/app_name: \['My Node Application'\],/) } 19 | its(:content) { should match(/level: 'info',/) } 20 | its(:content) { should match(%r{filepath: '/var/mynode_app/newrelic.log'}) } 21 | end 22 | -------------------------------------------------------------------------------- /test/integration/nodejs-agent/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe yumrepo('newrelic'), if: os[:family] == 'redhat' do 4 | it { is_expected.to exist } 5 | it { is_expected.to be_enabled } 6 | end 7 | describe file('/etc/apt/sources.list.d/newrelic.list'), if: %w(debian ubuntu).include?(os[:family]) do 8 | it { is_expected.to be_file } 9 | end 10 | 11 | describe command('cd /var/mynode_app/ && npm ls') do 12 | its(:exit_status) { should eq 0 } 13 | its(:stdout) { should match(/newrelic@/) } 14 | end 15 | 16 | describe file('/var/mynode_app//newrelic.js') do 17 | its(:content) { should match(/license_key: '0000ffff0000ffff0000ffff0000ffff0000ffff',/) } 18 | its(:content) { should match(/app_name: \['my_nodejs_app'\],/) } 19 | its(:content) { should match(/level: 'debug',/) } 20 | its(:content) { should match(%r{filepath: '/var/mynode_app/mylog.log'}) } 21 | end 22 | -------------------------------------------------------------------------------- /test/integration/php-agent-php5enmod/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe file('/etc/php5/conf.d/newrelic.ini'), if: %w(12.04).include?(os[:release]) do 4 | it { is_expected.to be_file } 5 | end 6 | 7 | describe file('/etc/php5/mods-available/newrelic.ini'), if: %w(14.04).include?(os[:release]) do 8 | it { is_expected.to be_file } 9 | end 10 | 11 | describe file('/etc/php/7.0/mods-available/newrelic.ini'), if: os[:release] == '16.04' do 12 | it { is_expected.to be_file } 13 | end 14 | 15 | describe file('/etc/php.d/newrelic.ini'), if: os[:family] == 'redhat' do 16 | it { is_expected.to be_file } 17 | end 18 | 19 | describe command('php --modules') do 20 | its(:stdout) { is_expected.to match(/newrelic/) } 21 | end 22 | -------------------------------------------------------------------------------- /test/integration/php-agent/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe yumrepo('newrelic'), if: os[:family] == 'redhat' do 4 | it { is_expected.to exist } 5 | it { is_expected.to be_enabled } 6 | end 7 | describe file('/etc/apt/sources.list.d/newrelic.list'), if: %w(debian ubuntu).include?(os[:family]) do 8 | it { is_expected.to be_file } 9 | end 10 | describe package 'newrelic-daemon' do 11 | it { is_expected.to be_installed } 12 | end 13 | -------------------------------------------------------------------------------- /test/integration/python-agent-recipe/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe yumrepo('newrelic'), if: os[:family] == 'redhat' do 4 | it { is_expected.to exist } 5 | it { is_expected.to be_enabled } 6 | end 7 | 8 | describe file('/etc/apt/sources.list.d/newrelic.list'), if: %w(debian ubuntu).include?(os[:family]) do 9 | it { is_expected.to be_file } 10 | end 11 | 12 | describe command('pip show newrelic') do 13 | its(:exit_status) { should eq 0 } 14 | end 15 | 16 | describe file('/etc/newrelic/newrelic.ini') do 17 | its(:content) { should match(/license_key = 0000ffff0000ffff0000ffff0000ffff0000ffff/) } 18 | its(:content) { should match(/app_name = My Python Application/) } 19 | its(:content) { should match(/high_security: false/) } 20 | its(:content) { should match(/monitor_mode = true/) } 21 | its(:content) { should match(/log_level = info/) } 22 | its(:content) { should match(%r{log_file = /tmp/newrelic-python-agent.log}) } 23 | its(:content) { should match(/ssl = true/) } 24 | its(:content) { should match(/capture_params = false/) } 25 | its(:content) { should match(/transaction_tracer.enabled = true/) } 26 | its(:content) { should match(/transaction_tracer.transaction_threshold = apdex_f/) } 27 | its(:content) { should match(/transaction_tracer.record_sql = obfuscated/) } 28 | its(:content) { should match(/transaction_tracer.stack_trace_threshold = 0.5/) } 29 | its(:content) { should match(/transaction_tracer.explain_enabled = true/) } 30 | its(:content) { should match(/transaction_tracer.explain_threshold = 0.5/) } 31 | its(:content) { should match(/thread_profiler.enabled = true/) } 32 | its(:content) { should match(/error_collector.enabled = false/) } 33 | its(:content) { should match(/browser_monitoring.auto_instrument = true/) } 34 | its(:content) { should match(/cross_application_tracer.enabled = false/) } 35 | end 36 | -------------------------------------------------------------------------------- /test/integration/python-agent/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe yumrepo('newrelic'), if: os[:family] == 'redhat' do 4 | it { is_expected.to exist } 5 | it { is_expected.to be_enabled } 6 | end 7 | describe file('/etc/apt/sources.list.d/newrelic.list'), if: %w(debian ubuntu).include?(os[:family]) do 8 | it { is_expected.to be_file } 9 | end 10 | 11 | describe command('pip show newrelic') do 12 | its(:exit_status) { should eq 0 } 13 | end 14 | 15 | describe file('/etc/newrelic/newrelic.ini') do 16 | its(:content) { should match(/license_key = 0000ffff0000ffff0000ffff0000ffff0000ffff/) } 17 | its(:content) { should match(/app_name = my_python_app/) } 18 | its(:content) { should match(/monitor_mode = true/) } 19 | its(:content) { should match(/log_level = debug/) } 20 | its(:content) { should match(%r{log_file = /etc/newrelic/log.log}) } 21 | its(:content) { should match(/ssl = false/) } 22 | its(:content) { should match(/capture_params = true/) } 23 | its(:content) { should match(/transaction_tracer.enabled = true/) } 24 | its(:content) { should match(/transaction_tracer.transaction_threshold = apdex_f/) } 25 | its(:content) { should match(/transaction_tracer.record_sql = off/) } 26 | its(:content) { should match(/transaction_tracer.stack_trace_threshold = 0.6/) } 27 | its(:content) { should match(/transaction_tracer.explain_enabled = false/) } 28 | its(:content) { should match(/transaction_tracer.explain_threshold = 0.7/) } 29 | its(:content) { should match(/thread_profiler.enabled = false/) } 30 | its(:content) { should match(/error_collector.enabled = false/) } 31 | its(:content) { should match(/browser_monitoring.auto_instrument = true/) } 32 | its(:content) { should match(/cross_application_tracer.enabled = false/) } 33 | end 34 | -------------------------------------------------------------------------------- /test/integration/ruby-agent/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | set :path, '/opt/rbenv/shims:/opt/rbenv/bin:/opt/rbenv/plugins/ruby_build/bin:/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:$PATH' 3 | 4 | describe file('/opt/newrelic/ruby') do 5 | it { should be_directory } 6 | end 7 | 8 | describe package('newrelic_rpm') do 9 | it { should be_installed.by('gem') } 10 | end 11 | 12 | describe file('/opt/newrelic/ruby/newrelic.yml') do 13 | it { should be_file } 14 | its(:content) { should match('0000ffff0000ffff0000ffff0000ffff0000ffff') } 15 | end 16 | -------------------------------------------------------------------------------- /test/integration/server-monitor/serverspec/default_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe yumrepo('newrelic'), if: os[:family] == 'redhat' do 4 | it { is_expected.to exist } 5 | it { is_expected.to be_enabled } 6 | end 7 | describe file('/etc/apt/sources.list.d/newrelic.list'), if: %w(debian ubuntu).include?(os[:family]) do 8 | it { is_expected.to be_file } 9 | end 10 | describe package 'newrelic-sysmond' do 11 | it { is_expected.to be_installed } 12 | end 13 | --------------------------------------------------------------------------------