Commit eb598258 authored by fsalum's avatar fsalum
Browse files

Split the Server Monitoring and PHP Agent on their own classes, compliant with...

Split the Server Monitoring and PHP Agent on their own classes, compliant with the New Relic PHP Agent 3 configuration
parent f37e0aca
pkg/
Gemfile.lock
2012-11-30 - Felipe Salum <fsalum@gmail.com> - 3.0.0
* Split the Server Monitoring and PHP agent in their own classes
* Compliance with the New Relic PHP Agent 3.0 changes
2012-10-10 - Felipe Salum <fsalum@gmail.com> - 0.0.1
* Initial Forge release
GEM
remote: http://rubygems.org/
specs:
facter (1.6.13)
hiera (1.0.0)
puppet (3.0.1)
facter (~> 1.6.11)
hiera (~> 1.0.0)
puppet-lint (0.3.2)
rake (0.9.2.2)
PLATFORMS
ruby
DEPENDENCIES
puppet (>= 2.7)
puppet-lint
rake
name 'fsalum-newrelic'
version '0.0.1'
version '3.0.0'
source 'git://github.com/fsalum/puppet-newrelic.git'
author 'Felipe Salum'
license 'Apache License, Version 2.0'
summary 'Puppet module for NewRelic'
description 'Module to install and configure Newrelic server monitoring and Newrelic PHP Agent'
description 'Module to install and configure New Relic server monitoring and New Relic PHP Agent'
project_page 'https://github.com/fsalum/puppet-newrelic'
## Add dependencies, if any:
......
Newrelic Module for Puppet
===========================
==========================
[![Build Status](https://secure.travis-ci.org/fsalum/puppet-newrelic.png)](http://travis-ci.org/fsalum/puppet-newrelic)
This module manages and installs the New Relic Server Monitoring and PHP agents.
IMPORTANT
---------
If you were using the previous version of this module `0.0.1` you need to change
how you declare the class because I'm now using defined resource types and I have
split the Server Monitoring and PHP Agent classes to be easy to maintain.
All the parameters are still the same and new parameters were included.
Quick Start
-----------
To install the Newrelic Server Monitoring and the PHP agent packages, include the following in your manifest file:
node default {
class { newrelic:
newrelic_license_key => 'YOUR LICENSE KEY HERE',
newrelic_php => true,
newrelic_php_conf_appname => 'Your PHP Application Name Here',
}
newrelic::server {
'srvXYZ':
newrelic_license_key => 'your license key here',
}
newrelic::php {
'appXYZ':
newrelic_license_key => 'your license key here',
newrelic_php_conf_appname => 'Your PHP Application',
}
}
Parameters
----------
You can also set some extra parameters to enable or disable a few options:
* `newrelic_service_ensure`
Specify the service running state. Defaults to 'running'. Possible value is 'stopped'.
* `newrelic_package_ensure`
Specify the package update state. Defaults to 'present'. Possible value is 'latest'.
* `newrelic_license_key`
Specify your Newrelic License Key.
* `newrelic_php`
If set to true will install and configure Newrelic PHP agent. Defaults to false.
* `newrelic_php_package_ensure`
Specific the Newrelic PHP package update state. Defaults to 'present'. Possible value is 'latest'.
* `newrelic_php_service_ensure`
Specify the Newrelic PHP service running state. Defaults to 'running'. Possible value is 'stopped'.
* `newrelic_php_conf_appname`
Sets the name of the application as it will be seen in the New Relic UI
* `newrelic_php_conf_enabled`
By default the New Relic PHP agent is enabled for all directories. To disable set it to '0'.
* `newrelic_php_conf_transaction`
Turns on the "top 100 slowest calls" tracer. To enable set it to '1'.
* `newrelic_php_conf_logfile`
This identifies the file name for logging messages.
* `newrelic_php_conf_loglevel`
Sets the level of detail of messages sent to the log file. Possible values: error, warning, info, verbose, debug, verbosedebug.
* `newrelic_php_conf_browser`
This enables auto-insertion of the JavaScript fragments for browser monitoring. To disable set it to '0'.
* `newrelic_php_conf_dberrors`
It causes MySQL errors from all instrumented MySQL calls to be reported to New Relic. To enable set it to '1'.
* `newrelic_php_conf_transactionrecordsql`
When recording transaction traces internally, the full SQL for slow SQL calls is recorded. Possible values: off, raw, obfuscate
.
* `newrelic_php_conf_captureparams`
This will enable the display of parameters passed to a PHP script via the URL. To enable set it to '1'.
There are a lot of parameters you can customize, check the `.pp` files and the New Relic documentation to understand them.
Author
------
Felipe Salum <fsalum@gmail.com>
\ No newline at end of file
Felipe Salum <fsalum@gmail.com>
......@@ -4,66 +4,10 @@
#
# === Parameters
#
# [*newrelic_service_ensure*]
# Specify the service running state. Defaults to 'running'. Possible value is 'stopped'.
#
# [*newrelic_package_ensure*]
# Specify the package update state. Defaults to 'present'. Possible value is 'latest'.
#
# [*newrelic_license_key*]
# Specify your Newrelic License Key.
#
# [*newrelic_php*]
# If set to true will install and configure Newrelic PHP agent. Defaults to false.
#
# [*newrelic_php_package_ensure*]
# Specific the Newrelic PHP package update state. Defaults to 'present'. Possible value is 'latest'.
#
# [*newrelic_php_service_ensure*]
# Specify the Newrelic PHP service running state. Defaults to 'running'. Possible value is 'stopped'.
#
# [*newrelic_php_conf_appname*]
# Sets the name of the application as it will be seen in the New Relic UI
#
# [*newrelic_php_conf_enabled*]
# By default the New Relic PHP agent is enabled for all directories. To disable set it to '0'.
#
# [*newrelic_php_conf_transaction*]
# Turns on the "top 100 slowest calls" tracer. To enable set it to '1'.
#
# [*newrelic_php_conf_logfile*]
# This identifies the file name for logging messages.
#
# [*newrelic_php_conf_loglevel*]
# Sets the level of detail of messages sent to the log file. Possible values: error, warning, info, verbose, debug, verbosedebug.
#
# [*newrelic_php_conf_browser*]
# This enables auto-insertion of the JavaScript fragments for browser monitoring. To disable set it to '0'.
#
# [*newrelic_php_conf_dberrors*]
# It causes MySQL errors from all instrumented MySQL calls to be reported to New Relic. To enable set it to '1'.
#
# [*newrelic_php_conf_transactionrecordsql*]
# When recording transaction traces internally, the full SQL for slow SQL calls is recorded. Possible values: off, raw, obfuscated.
#
# [*newrelic_php_conf_captureparams*]
# This will enable the display of parameters passed to a PHP script via the URL. To enable set it to '1'.
#
#
# === Variables
#
# === Examples
#
# class { newrelic:
# newrelic_package_ensure => 'latest',
# newrelic_service_ensure => 'running',
# newrelic_license_key => '1234567890123456789012345678901234567890',
# newrelic_php => true,
# newrelic_php_package_ensure => 'latest',
# newrelic_php_service_ensure => 'running',
# newrelic_php_conf_appname => 'Your PHP Application',
# }
#
# === Authors
#
# Felipe Salum <fsalum@gmail.com>
......@@ -72,73 +16,8 @@
#
# Copyright 2012 Felipe Salum, unless otherwise noted.
#
class newrelic (
$newrelic_package_ensure = 'present',
$newrelic_service_ensure = 'running',
$newrelic_license_key = '',
$newrelic_php = false,
$newrelic_php_package_ensure = 'present',
$newrelic_php_service_ensure = 'running',
$newrelic_php_conf_appname = 'Your PHP Application',
$newrelic_php_conf_enabled = '1',
$newrelic_php_conf_logfile = '/var/log/newrelic/php_agent.log',
$newrelic_php_conf_loglevel = 'info',
$newrelic_php_conf_browser = '1',
$newrelic_php_conf_transaction = '0',
$newrelic_php_conf_dberrors = '0',
$newrelic_php_conf_transactionrecordsql = 'off',
$newrelic_php_conf_captureparams = '0',
) {
class newrelic {
require newrelic::params
$newrelic_package_name = $newrelic::params::newrelic_package_name
$newrelic_service_name = $newrelic::params::newrelic_service_name
$newrelic_php_package = $newrelic::params::newrelic_php_package
$newrelic_php_service = $newrelic::params::newrelic_php_service
$newrelic_php_conf_dir = $newrelic::params::newrelic_php_conf_dir
package { $newrelic_package_name:
ensure => $newrelic_package_ensure,
notify => Service[$newrelic_service_name],
}
service { $newrelic_service_name:
ensure => $newrelic_service_ensure,
enable => true,
hasrestart => true,
hasstatus => true,
require => Exec[$newrelic_license_key],
}
exec { $newrelic_license_key:
path => '/bin:/usr/bin',
command => "/usr/sbin/nrsysmond-config --set license_key=${newrelic_license_key}",
user => 'root',
group => 'root',
unless => "cat /etc/newrelic/nrsysmond.cfg | grep ${newrelic_license_key}",
require => Package[$newrelic_package_name],
notify => Service[$newrelic_service_name],
}
if $newrelic_php {
class { 'newrelic::php':
newrelic_license_key => $newrelic_license_key,
newrelic_php_package => $newrelic_php_package,
newrelic_php_service => $newrelic_php_service,
newrelic_php_conf_dir => $newrelic_php_conf_dir,
newrelic_php_conf_appname => $newrelic_php_conf_appname,
newrelic_php_conf_enabled => $newrelic_php_conf_enabled,
newrelic_php_conf_logfile => $newrelic_php_conf_logfile,
newrelic_php_conf_loglevel => $newrelic_php_conf_loglevel,
newrelic_php_conf_browser => $newrelic_php_conf_browser,
newrelic_php_conf_transaction => $newrelic_php_conf_transaction,
newrelic_php_conf_dberrors => $newrelic_php_conf_dberrors,
newrelic_php_conf_transactionrecordsql => $newrelic_php_conf_transactionrecordsql,
newrelic_php_conf_captureparams => $newrelic_php_conf_captureparams,
newrelic_php_package_ensure => $newrelic_php_package_ensure,
newrelic_php_service_ensure => $newrelic_php_service_ensure,
}
}
}
......@@ -31,7 +31,6 @@ class newrelic::params {
$newrelic_php_package = 'newrelic-php5'
$newrelic_php_service = 'newrelic-daemon'
$newrelic_php_conf_dir = '/etc/php5/conf.d'
include apt
apt::source { 'newrelic':
location => 'http://apt.newrelic.com/debian/',
repos => 'newrelic non-free',
......
# Class: newrelic::php
#
# This class should not be used individually as it uses values and is
# called from the main class.
# This class install the New Relic PHP Agent
#
# Parameters:
#
# [*newrelic_php_package_ensure*]
# Specific the Newrelic PHP package update state. Defaults to 'present'. Possible value is 'latest'.
#
# [*newrelic_php_service_ensure*]
# Specify the Newrelic PHP service running state. Defaults to 'running'. Possible value is 'stopped'.
#
# [*newrelic_php_conf_appname*]
# Sets the name of the application as it will be seen in the New Relic UI
#
# [*newrelic_php_conf_enabled*]
# By default the New Relic PHP agent is enabled for all directories. To disable set it to '0'.
#
# [*newrelic_php_conf_transaction*]
# This traces all calls, not just those calls internally instrumented by New Relic. To disable set it to '0'.
#
# [*newrelic_php_conf_logfile*]
# This identifies the file name for logging messages.
#
# [*newrelic_php_conf_loglevel*]
# Sets the level of detail of messages sent to the log file. Possible values: error, warning, info, verbose, debug, verbosedebug.
#
# [*newrelic_php_conf_browser*]
# This enables auto-insertion of the JavaScript fragments for browser monitoring. To disable set it to '0'.
#
# [*newrelic_php_conf_dberrors*]
# It causes MySQL errors from all instrumented MySQL calls to be reported to New Relic. To enable set it to '1'.
#
# [*newrelic_php_conf_transactionrecordsql*]
# When recording transaction traces internally, the full SQL for slow SQL calls is recorded. Possible values: off, raw, obfuscated.
#
# [*newrelic_php_conf_captureparams*]
# This will enable the display of parameters passed to a PHP script via the URL. To enable set it to '1'.
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
class newrelic::php (
$newrelic_license_key,
$newrelic_php_package,
$newrelic_php_service,
$newrelic_php_conf_dir,
$newrelic_php_conf_appname,
$newrelic_php_conf_enabled,
$newrelic_php_conf_logfile,
$newrelic_php_conf_loglevel,
$newrelic_php_conf_browser,
$newrelic_php_conf_transaction,
$newrelic_php_conf_dberrors,
$newrelic_php_conf_transactionrecordsql,
$newrelic_php_conf_captureparams,
$newrelic_php_package_ensure,
$newrelic_php_service_ensure,
# newrelic::php {
# 'appXYZ':
# newrelic_license_key => 'your license key here',
# newrelic_php_package_ensure => 'latest',
# newrelic_php_service_ensure => 'running',
# newrelic_php_conf_appname => 'Your PHP Application',
# }
#
define newrelic::php (
$newrelic_license_key = '',
$newrelic_php_package_ensure = 'present',
$newrelic_php_service_ensure = 'running',
$newrelic_php_conf_appname = 'Your PHP Application',
$newrelic_php_conf_enabled = '1',
$newrelic_php_conf_transaction = '1',
$newrelic_php_conf_logfile = '/var/log/newrelic/php_agent.log',
$newrelic_php_conf_loglevel = 'info',
$newrelic_php_conf_browser = '1',
$newrelic_php_conf_dberrors = '0',
$newrelic_php_conf_transactionrecordsql = 'off',
$newrelic_php_conf_captureparams = '0',
$newrelic_daemon_pidfile = '/var/run/newrelic-daemon.pid',
$newrelic_daemon_logfile = '/var/log/newrelic/newrelic-daemon.log',
$newrelic_daemon_loglevel = 'info',
$newrelic_daemon_port = '33142',
$newrelic_daemon_ssl = 'false',
$newrelic_daemon_proxy = '',
$newrelic_daemon_ssl_ca_bundle = '',
$newrelic_daemon_ssl_ca_path = '',
$newrelic_daemon_max_threads = '8',
$newrelic_daemon_collector_host = 'collector.newrelic.com',
) {
include newrelic
$newrelic_php_package = $newrelic::params::newrelic_php_package
$newrelic_php_service = $newrelic::params::newrelic_php_service
$newrelic_php_conf_dir = $newrelic::params::newrelic_php_conf_dir
package { $newrelic_php_package:
ensure => $newrelic_php_package_ensure,
notify => Service[$newrelic_php_service],
}
service { $newrelic_php_service:
......@@ -48,9 +100,8 @@ class newrelic::php (
provider => 'shell',
user => 'root',
group => 'root',
unless => "cat /etc/newrelic/newrelic.cfg | grep ${newrelic_license_key}",
unless => "cat ${newrelic_php_conf_dir}/newrelic.ini | grep ${newrelic_license_key}",
require => Package[$newrelic_php_package],
notify => Service[$newrelic_php_service],
}
file { 'newrelic.ini':
......@@ -59,4 +110,11 @@ class newrelic::php (
require => Exec['/usr/bin/newrelic-install'],
}
file { '/etc/newrelic/newrelic.cfg':
path => '/etc/newrelic/newrelic.cfg',
content => template('newrelic/newrelic.cfg.erb'),
require => Exec['/usr/bin/newrelic-install'],
before => Service[$newrelic_php_service],
}
}
# == Class: newrelic::server
#
# This class installs and configures NewRelic server monitoring.
#
# === Parameters
#
# [*newrelic_service_ensure*]
# Specify the service running state. Defaults to 'running'. Possible value is 'stopped'.
#
# [*newrelic_package_ensure*]
# Specify the package update state. Defaults to 'present'. Possible value is 'latest'.
#
# [*newrelic_license_key*]
# Specify your Newrelic License Key.
#
# === Variables
#
# === Examples
#
# newrelic::server {
# 'serverXYZ':
# newrelic_license_key => 'your license key here',
# newrelic_package_ensure => 'latest',
# newrelic_service_ensure => 'running',
# }
#
# === Authors
#
# Felipe Salum <fsalum@gmail.com>
#
# === Copyright
#
# Copyright 2012 Felipe Salum, unless otherwise noted.
#
define newrelic::server (
$newrelic_license_key = '',
$newrelic_package_ensure = 'present',
$newrelic_service_ensure = 'running',
) {
include newrelic
$newrelic_package_name = $newrelic::params::newrelic_package_name
$newrelic_service_name = $newrelic::params::newrelic_service_name
package { $newrelic_package_name:
ensure => $newrelic_package_ensure,
notify => Service[$newrelic_service_name],
}
service { $newrelic_service_name:
ensure => $newrelic_service_ensure,
enable => true,
hasrestart => true,
hasstatus => true,
require => Exec[$newrelic_license_key],
}
exec { $newrelic_license_key:
path => '/bin:/usr/bin',
command => "/usr/sbin/nrsysmond-config --set license_key=${newrelic_license_key}",
user => 'root',
group => 'root',
unless => "cat /etc/newrelic/nrsysmond.cfg | grep ${newrelic_license_key}",
require => Package[$newrelic_package_name],
notify => Service[$newrelic_service_name],
}
}
#
# This is a configuration template for the New Relic daemon - a communications
# proxy between New Relic agents (such as the PHP agent) and the New Relic
# data collectors. This configuration file is required *ONLY* if you need or
# want to start the New Relic daemon at system boot time using init. In order
# to do so you must execute the following commands (as root):
#
# For CentOS and RedHat systems:
# /sbin/chkconfig newrelic-daemon on
#
# For Ubuntu and Debian systems:
# /usr/sbin/update-rc.d newrelic-daemon defaults 90 10
# /usr/sbin/update-rc.d newrelic-daemon enable
#
# For other systems please consult your documentation on how to enable and
# disable services.
#
# For all systems:
# /etc/init.d/newrelic-daemon start
#
# The startup scripts will only start the daemon if there is a valid daemon
# configuration file in place. This file is, by default:
#
# /etc/newrelic/newrelic.cfg
#
# If that file does not exist, you can copy this template file to that
# location and edit it to suit your system needs.
#
# By default the daemon is not started at system boot time, and does not use
# the /etc/newrelic/newrelic.cfg file. Rather, the daemon is started by the
# agent automatically on startup and is configured by the agent (for example
# when using the PHP agent the daemon parameters are set in the global INI
# file and all begin with 'newrelic.daemon').
#
# There are certain circumstances under which you may want the daemon to be
# started at boot time rather than by the agent. If you use a chroot jail for
# running the agent in, if you have multiple web servers or FastCGI process
# managers, or if you use PHP on the command line a lot for batch processing
# then you may want to start the daemon once at system boot rather than having
# the agent start it.
#
# Below are the various options you can change that affect the daemon. Each
# one is explained in detail along with it's default value.
#
#
# Setting: pidfile
# Type : string
# Purpose: Sets the name of the file that the daemon writes its process ID
# (PID) to. This is used by the startup and shutdown script to know
# which process to monitor or kill.
# Default: OS-dependent. Uses a filename of newrelic-daemon.pid in the first
# directory from the list /var/run or /var/pid that is found.
pidfile=<%= newrelic_daemon_pidfile %>
#
# Setting: logfile
# Type : string
# Purpose: Sets the name of the file to record log messages in. If this file
# does not exist it is created. If it cannot be created the daemon
# will not start up. The amount of information sent to this file is
# controlled by the loglevel settings, defined below.
# Default: /var/log/newrelic/newrelic-daemon.log
logfile=<%= newrelic_daemon_logfile %>
#
# Setting: loglevel
# Type : string
# Purpose: Sets the level of detail of log messages sent to the log file. This
# variable can control the log level for different subsystem at
# different levels, although such custom usage should only be done at
# the request of New Relic technical support. The simplest setting is
# to use one of the following keywords, in increasing order of detail:
# error - only error messages
# warning - only warning and error messages
# info - only minimal startup and shutdown info
# verbose - slightly more verbose than info, not commonly used
# debug - very verbose, includes messages only relevant to support
# verbosedebug - extremely verbose, creates massive log files
# Default: info
loglevel=<%= newrelic_daemon_loglevel %>
#
# Setting: port
# Type : Integer (1-65534)
# Purpose: Sets the TCP port on which the daemon will listen for connections
# from agents (agents in this case includes Apache / php-fpm worker
# processes, the command line, or any other agent source). In order
# to use a port in the range 1-1023, the daemon must be started by
# the super-user. This is a fundamental OS limitation and not one
# imposed by the daemon itself.
# Default: 33142
port=<%= newrelic_daemon_port %>
#
# Setting: ssl
# Type : boolean
# Purpose: If you prefer the daemon to use the secure HTTP (https) protocol
# when communicating with the New Relic collector servers, set this
# to true. Please note that in order for this to work the daemon must
# be able to find a Certificate Authority (CA) list. On startup the
# daemon will attempt to find such a list in the usual places, but
# you may need to use the ssl_ca_bundle or ssl_ca_path variables
# below.
# Default: false
ssl=<%= newrelic_daemon_ssl %>
#
# Setting: proxy
# Type : string
# Purpose: Some networks are configured to require the use of an egress proxy
# server in order to communicate with the outside world. Since the
# daemon needs to communicate with the New Relic data collection
# servers you may need to instruct it to use a proxy server. Your
# system or network administrator should be able to provide you with
# the details.
# This string is in the form [user[:password]]@hostname[:port] with
# the user, password and port fields being optional. Some examples:
# myusername:secret@10.1.1.1:12345
# someuser@proxy.mydomain.com:4321
# proxy.mydomain.com
# Default: none
proxy=<%= newrelic_daemon_proxy %>
#
# Setting: ssl_ca_bundle
# Type : string
# Purpose: If you have the "ssl" option above enabled, and the daemon cannot
# find a suitable Certificate Authority (CA) list, this is one of the
# options you can use to point it to the CA list to use. If your SSL
# installation uses a "bundle" - i.e. a single file which contains a