Filippo Giunchedi has uploaded a new change for review. https://gerrit.wikimedia.org/r/170996
Change subject: jheapdump: gdb-based heap dump for JVM ...................................................................... jheapdump: gdb-based heap dump for JVM Change-Id: I7fc40ff5a0ebd29824f9dbf76bf3d989343ce515 --- A modules/elasticsearch/files/jheapdump M modules/elasticsearch/manifests/init.pp 2 files changed, 80 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/96/170996/1 diff --git a/modules/elasticsearch/files/jheapdump b/modules/elasticsearch/files/jheapdump new file mode 100644 index 0000000..acbfeae --- /dev/null +++ b/modules/elasticsearch/files/jheapdump @@ -0,0 +1,73 @@ +#!/bin/bash + +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software Foundation, Inc., 51 +# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +# Copyright 2014 Filippo Giunchedi <fgiunch...@wikimedia.org> +# Copyright 2014 Wikimedia Foundation + +set -e +set -u + +pid=${1:-} +path=${2:-} + +function usage_exit() { + echo "usage: $0 PID BASE_NAME" + echo " capture a core from PID into BASE_NAME.core.PID" + echo " and extract java heap dump into BASE_NAME.hprof.PID" + exit 1 +} + +if [ -z "$pid" -o -z "$path" ]; then + usage_exit +fi + +jmap=${JMAP:-$(command -vp jmap)} +gcore=${GCORE:-$(command -vp gcore)} +java=${JAVA:-$(command -vp java)} + +if [ -z "$jmap" -o -z "$gcore" -o -z "$java" ]; then + echo "jmap or gcore or java not found" + usage_exit +fi + +if [ -d "$path" ]; then + echo "BASE_NAME can't be a directory" + usage_exit +fi + +core_path="${path}.core.${pid}" +heap_path="${path}.hprof.${pid}" +jmap_options="-dump:format=b,file=${heap_path}" +# remove trailing ".${pid}" +gcore_options="-o ${core_path%*.${pid}}" + +# XXX check disk space +if [ ! -e "$core_path" ]; then + echo "dumping core from ${pid} into ${core_path}" + echo "WARNING: this file can get very big!" + echo " make sure there is enough disk space available" + sudo ${gcore} ${gcore_options} ${pid} +fi + +if [ ! -e "$heap_path" ]; then + echo "writing heap profile to ${heap_path}" + sudo ${jmap} ${jmap_options} "${java}" "${core_path}" +fi + +echo "done." + +echo "NOTE: the core file at ${core_path}, if unused remove with:" +echo " sudo rm ${core_path}" diff --git a/modules/elasticsearch/manifests/init.pp b/modules/elasticsearch/manifests/init.pp index 0e05ea9..a7499cf 100644 --- a/modules/elasticsearch/manifests/init.pp +++ b/modules/elasticsearch/manifests/init.pp @@ -122,6 +122,13 @@ mode => '0444', source => 'puppet:///modules/elasticsearch/logrotate', } + file { '/usr/local/bin/jheapdump': + ensure => file, + owner => root, + group => root, + mode => '0555', + source => 'puppet:///modules/elasticsearch/jheapdump', + } # Note that we don't notify the Elasticsearch service of changes to its # config files because you need to be somewhat careful when restarting it. # So, for now at least, we'll be restarting it manually. -- To view, visit https://gerrit.wikimedia.org/r/170996 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7fc40ff5a0ebd29824f9dbf76bf3d989343ce515 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Filippo Giunchedi <fgiunch...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits