Commit 9dd43eaf authored by Stefan Galinski's avatar Stefan Galinski 🎮
Browse files

[TASK] Initial commit

parents
.idea
\ No newline at end of file
# Description
Installs and configures Webgrind.
# Usage
This will allow you to run the profiler on a request by adding the following params to a request `?XDEBUG_PROFILE`.
\ No newline at end of file
default['webgrind']['ip_address'] = ''
default['webgrind']['hostname'] = 'xhprof'
default['webgrind']['install_path'] = '/opt/webgrind'
\ No newline at end of file
name 'webgrind'
maintainer 'sgalinski Internet Services'
maintainer_email 'stefan@sgalinski.de'
license 'Apache 2.0'
description 'Webgrind'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '1.0.0'
issues_url 'https://gitlab.sgalinski.de/chef-cookbooks/webgrind/issues'
source_url 'https://gitlab.sgalinski.de/chef-cookbooks/webgrind'
recipe 'webgrind::default', 'Installs Webgrind'
recipe 'webgrind::webgrind', 'Webgrind'
depends :apache2
depends :database
depends :git
depends :hostsfile
\ No newline at end of file
#
# Cookbook Name:: webgrind
# Recipe:: default
#
# Copyright sgalinski Internet Services
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
if node['platform_version'] == '16.04'
include_recipe 'webgrind::webgrind'
hostsfile_entry node['webgrind']['ip_address'] do
hostname node['webgrind']['hostname']
action :append
end
else
log 'webgrind not supported' do
message 'Webgrind is not supported in combination with Ubuntu 14.04'
level :warn
end
end
#
# Cookbook Name:: webgrind
# Recipe:: webgrind
#
# Copyright sgalinski Internet Services
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the 'Software'), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
############################
### Install Dependencies ###
############################
package 'graphviz'
#######################
### Download XhProf ###
#######################
directory node['webgrind']['install_path'] do
recursive true
action :create
end
git node['webgrind']['install_path'] do
repository 'git://github.com/jokkedk/webgrind.git'
revision 'master'
action :sync
end
###########################
### Setup Configuration ###
###########################
template node['webgrind']['install_path'] + '/webgrind.config.php.erb' do
source 'webgrind.config.php.erb'
owner 'root'
group 'root'
mode '0644'
variables(
:params => node['webgrind']
)
action :create
end
##########################
### Setup Virtual Host ###
##########################
web_app node['webgrind']['hostname'] do
server_name node['webgrind']['hostname']
apache node['apache']
docroot node['webgrind']['install_path'] + '/'
end
\ No newline at end of file
<VirtualHost *:<%= @params[:apache]['listen_ports'][0] %>>
ServerName <%= @params[:server_name] %>
ServerAlias <% @params[:server_aliases].each do |a| %><%= a %> <% end %>
DocumentRoot <%= @params[:docroot] %>
RewriteEngine On
<Directory <%= @params[:docroot] %>>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Require all granted
</Directory>
<Directory />
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Require all granted
</Location>
LogLevel info
ErrorLog <%= @params[:apache]['log_dir'] %>/<%= @params[:name] %>-error.log
CustomLog <%= @params[:apache]['log_dir'] %>/<%= @params[:name] %>-access.log combined
</VirtualHost>
\ No newline at end of file
<?php
/**
* Configuration for webgrind
*/
class Webgrind_Config extends Webgrind_MasterConfig {
/**
* Automatically check if a newer version of webgrind is available for download
*/
static $checkVersion = true;
static $hideWebgrindProfiles = true;
/**
* Writable dir for information storage.
* If empty, will use system tmp folder or xdebug tmp
*/
static $storageDir = '';
static $profilerDir = '/tmp';
/**
* Suffix for preprocessed files
*/
static $preprocessedSuffix = '.webgrind';
static $defaultTimezone = 'UTC';
static $dateFormat = 'Y-m-d H:i:s';
static $defaultCostformat = 'percent'; // 'percent', 'usec' or 'msec'
static $defaultFunctionPercentage = 90;
static $defaultHideInternalFunctions = false;
/**
* Path to python executable
*/
static $pythonExecutable = '/usr/bin/python';
/**
* Path to graphviz dot executable
*/
static $dotExecutable = '/usr/bin/dot';
/**
* sprintf compatible format for generating links to source files.
* %1$s will be replaced by the full path name of the file
* %2$d will be replaced by the linenumber
*/
static $fileUrlFormat = 'index.php?op=fileviewer&file=%1$s#line%2$d'; // Built in fileviewer
//static $fileUrlFormat = 'txmt://open/?url=file://%1$s&line=%2$d'; // Textmate
//static $fileUrlFormat = 'file://%1$s'; // ?
/**
* format of the trace drop down list
* default is: invokeurl (tracefile_name) [tracefile_size]
* the following options will be replaced:
* %i - invoked url
* %f - trace file name
* %s - size of trace file
* %m - modified time of file name (in dateFormat specified above)
*/
static $traceFileListFormat = '%i (%f) [%s]';
#########################
# BELOW NOT FOR EDITING #
#########################
/**
* Regex that matches the trace files generated by xdebug
*/
static function xdebugOutputFormat() {
$outputName = ini_get('xdebug.profiler_output_name');
if($outputName=='') // Ini value not defined
$outputName = '/^cachegrind\.out\..+$/';
else
$outputName = '/^'.preg_replace('/(%[^%])+/', '.+', $outputName).'$/';
return $outputName;
}
/**
* Directory to search for trace files
*/
static function xdebugOutputDir() {
$dir = ini_get('xdebug.profiler_output_dir');
if($dir=='') // Ini value not defined
return realpath(Webgrind_Config::$profilerDir).'/';
return realpath($dir).'/';
}
/**
* Writable dir for information storage
*/
static function storageDir() {
if (!empty(Webgrind_Config::$storageDir))
return realpath(Webgrind_Config::$storageDir).'/';
if (!function_exists('sys_get_temp_dir') || !is_writable(sys_get_temp_dir())) {
# use xdebug setting
return Webgrind_Config::xdebugOutputDir();
}
return realpath(sys_get_temp_dir()).'/';
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment