Skip to content

Instantly share code, notes, and snippets.

@Ladas
Created July 21, 2017 12:02
Show Gist options
  • Save Ladas/4bc7308b0c75034f0a371fcec82c9ab6 to your computer and use it in GitHub Desktop.
Save Ladas/4bc7308b0c75034f0a371fcec82c9ab6 to your computer and use it in GitHub Desktop.
refresh quick perf test, run as ./memusg bundle exec rails r qe_ocp_refresh_manager_first_refresh.rb <ems_name>, grep evm.log for :save_inventory to get a time
#!/usr/bin/env bash
# memusg -- Measure memory usage of processes
# Usage: memusg COMMAND [ARGS]...
#
# Author: Jaeho Shin <[email protected]>
# Created: 2010-08-16
############################################################################
# Copyright 2010 Jaeho Shin. #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); #
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
############################################################################
set -um
# check input
[[ $# -gt 0 ]] || { sed -n '2,/^#$/ s/^# //p' <"$0"; exit 1; }
# TODO support more options: peak, footprint, sampling rate, etc.
pgid=$(ps -o pgid= $$)
# make sure we're in a separate process group
if [[ "$pgid" == "$(ps -o pgid= $(ps -o ppid= $$))" ]]; then
cmd=
set -- "$0" "$@"
for a; do cmd+="'${a//"'"/"'\\''"}' "; done
exec bash -i -c "$cmd"
fi
# detect operating system and prepare measurement
case $(uname) in
Darwin|*BSD) sizes() { /bin/ps -o rss= -g $1; } ;;
Linux) sizes() { /bin/ps -o rss= -$1; } ;;
*) echo "$(uname): unsupported operating system" >&2; exit 2 ;;
esac
# monitor the memory usage in the background.
(
peak=0
while sizes=$(sizes $pgid)
do
set -- $sizes
sample=$((${@/#/+}))
let peak="sample > peak ? sample : peak"
sleep 0.1
done
echo "memusg: peak=$peak" >&2
) &
monpid=$!
# run the given command
exec "$@"
require 'manageiq_performance'
manager_name = ARGV[0] || "10.16.31.50"
ActiveRecord::Base.logger = Logger.new(STDOUT)
# ManageIQPerformance.profile do
ems = ExtManagementSystem.find_by(:name => manager_name)
EmsRefresh.refresh(ems)
# end
puts "finished"
require 'manageiq_performance'
manager_name = ARGV[0] || "10.16.31.50"
ActiveRecord::Base.logger = Logger.new(STDOUT)
# ManageIQPerformance.profile do
ems = ExtManagementSystem.find_by(:name => manager_name)
old_id = ems.id
new_id = old_id + 1
res_t = ExtManagementSystem.to_s
ExtManagementSystem.where(:id => old_id).update_all(:id => new_id)
Endpoint.where(:resource_type => res_t, :resource_id => old_id).update_all(:resource_id => new_id)
Authentication.where(:resource_type => res_t, :resource_id => old_id).update_all(:resource_id => new_id)
ems = ExtManagementSystem.find_by(:name => manager_name)
EmsRefresh.refresh(ems)
# end
puts "finished"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment