Ori.livneh has submitted this change and it was merged. Change subject: Add mwprof module ......................................................................
Add mwprof module - Move implementation from role class to module - Parametrize collector port and carbon host / port - Provide Upstart configs - Provide service management script Change-Id: Iaefc77236e56b7bf1ff48da0186027845df342d8 --- M manifests/role/mwprof.pp A modules/mwprof/files/mwprofctl A modules/mwprof/files/upstart/init.conf A modules/mwprof/manifests/init.pp A modules/mwprof/templates/upstart/collector.conf.erb A modules/mwprof/templates/upstart/profiler-to-carbon.conf.erb 6 files changed, 151 insertions(+), 3 deletions(-) Approvals: Ori.livneh: Looks good to me, approved jenkins-bot: Verified diff --git a/manifests/role/mwprof.pp b/manifests/role/mwprof.pp index 58f9365..8e060b4 100644 --- a/manifests/role/mwprof.pp +++ b/manifests/role/mwprof.pp @@ -3,7 +3,7 @@ # Sets up mwprof. # class role::mwprof { - system::role { 'role::mwprof': description => 'MediaWiki profiler', } - package { [ 'build-essential', 'libdb-dev' ]: } - deployment::target { 'mwprof': } + class { '::mwprof': + collector_port => 3812, + } } diff --git a/modules/mwprof/files/mwprofctl b/modules/mwprof/files/mwprofctl new file mode 100755 index 0000000..6cd6404 --- /dev/null +++ b/modules/mwprof/files/mwprofctl @@ -0,0 +1,38 @@ +#!/bin/bash +# mwprofctl -- Manage MediaWiki profiler service +# Usage: mwprofctl {status|check|start|stop|restart|tail} +# +command=$1 +shift +case "$command" in + status) + initctl list | grep -P '^mwprof/(?!init)' | sort + ;; + check) + $0 status 2>&1 >/dev/null || { + echo "CRITICAL: Not all configured Carbon instances are running." + exit 2 + } + echo "OK: All defined Carbon jobs are runnning." + exit 0 + ;; + start) + /sbin/initctl emit mwprof.start + ;; + stop) + /sbin/initctl emit mwprof.stop + ;; + restart) + /sbin/initctl emit mwprof.stop + /sbin/initctl emit mwprof.start + ;; + tail) + tail "$@" /var/log/upstart/mwprof_init.log + ;; + top) + top -u mwprof + ;; + *) + echo >&2 "Usage: ${0##*/} {status|check|start|stop|restart|tail}" + ;; +esac diff --git a/modules/mwprof/files/upstart/init.conf b/modules/mwprof/files/upstart/init.conf new file mode 100644 index 0000000..367abaa --- /dev/null +++ b/modules/mwprof/files/upstart/init.conf @@ -0,0 +1,19 @@ +# Upstart job configuration for mwprof +# This file is managed by Puppet +description "MediaWiki profiler" + +start on runlevel [2345] or mwprof.start +stop on runlevel [!2345] or mwprof.stop + +task + +pre-start script + mkdir -p /run/mwprof + chown -R mwprof:mwprof /run/mwprof +end script + +script + start mwprof/collector || status mwprof/collector +end script + +# vim: set ft=upstart: diff --git a/modules/mwprof/manifests/init.pp b/modules/mwprof/manifests/init.pp new file mode 100644 index 0000000..6aae70a --- /dev/null +++ b/modules/mwprof/manifests/init.pp @@ -0,0 +1,56 @@ +# == Class: role::mwprof +# +# Sets up mwprof, a MediaWiki profiling log collector. +# +class mwprof( + $carbon_host = '127.0.0.1', + $carbon_port = 2003, + $collector_port = 3811, +) { + system::role { 'role::mwprof': + description => 'MediaWiki profiler', + } + + deployment::target { 'mwprof': } + + package { [ 'build-essential', 'libdb-dev' ]: } + + group { 'mwprof': + ensure => present, + } + + user { 'mwprof': + ensure => present, + gid => 'mwprof', + shell => '/bin/false', + home => '/nonexistent', + system => true, + } + + file { + '/etc/init/mwprof': + ensure => directory, + recurse => true, + purge => true, + force => true, + source => 'puppet:///modules/mwprof/upstart'; + '/etc/init/mwprof/profiler-to-carbon.conf': + content => template('mwprof/upstart/profiler-to-carbon.conf.erb'); + '/etc/init/mwprof/collector.conf': + content => template('mwprof/upstart/collector.conf.erb'); + } + + file { '/sbin/mwprofctl': + source => 'puppet:///modules/mwprof/mwprofctl'; + } + + service { 'mwprof': + ensure => 'running', + provider => 'base', + restart => '/sbin/mwprofctl restart', + start => '/sbin/mwprofctl start', + status => '/sbin/mwprofctl status', + stop => '/sbin/mwprofctl stop', + require => File['/sbin/mwprofctl'], + } +} diff --git a/modules/mwprof/templates/upstart/collector.conf.erb b/modules/mwprof/templates/upstart/collector.conf.erb new file mode 100644 index 0000000..4b95c05 --- /dev/null +++ b/modules/mwprof/templates/upstart/collector.conf.erb @@ -0,0 +1,18 @@ +# mwprof +# +# MediaWiki profiling data collector +# +description "profiling data collector" + +stop on runlevel [!2345] or mwprof.stop + +expect fork + +setuid mwprof +setgid mwprof + +env COLLECTOR_PORT=<%= @collector_port %> +chdir /run/mwprof +exec /srv/deployment/mwprof/mwprof/collector + +respawn diff --git a/modules/mwprof/templates/upstart/profiler-to-carbon.conf.erb b/modules/mwprof/templates/upstart/profiler-to-carbon.conf.erb new file mode 100644 index 0000000..c3d2ff4 --- /dev/null +++ b/modules/mwprof/templates/upstart/profiler-to-carbon.conf.erb @@ -0,0 +1,17 @@ +# mwprof +# +# MediaWiki profiling data collector +# +description "profiling data collector" + +start on started mwprof/collector +stop on runlevel [!2345] or mwprof.stop + +setuid mwprof +setgid mwprof + +exec /srv/deployment/mwprof/mwprof/profiler-to-carbon \ + --collector-host=127.0.0.1 \ + --collector-port=<%= @collector_port %> \ + --carbon-host=<%= @carbon_host %> \ + --carbon-port=<%= @carbon_port %> -- To view, visit https://gerrit.wikimedia.org/r/98585 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Iaefc77236e56b7bf1ff48da0186027845df342d8 Gerrit-PatchSet: 4 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Ori.livneh <o...@wikimedia.org> Gerrit-Reviewer: Ori.livneh <o...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits