Skip to content

Instantly share code, notes, and snippets.

@Ladas
Ladas / collector.rb
Last active July 30, 2018 15:09
Collector/Persistor split
# require 'manageiq_performance'
def generate_batches_od_data(ems_name:, total_elements:, batch_size: 1000)
ems = ExtManagementSystem.find_by(:name => ems_name)
persister = ManageIQ::Providers::Amazon::Inventory::Persister::TargetCollection.new(
ems, ems
)
count = 1
persister, count = process_entity(ems, :vm, persister, count, total_elements, batch_size)
@Ladas
Ladas / extra_vars
Created June 5, 2018 13:53
extra_vars
count: '2'
image_uuid: ami-a4dc46db
instance_indexed_tags: |-
Name: ladas_ansible_test_2
TestTag: test2
TestTag2: test2
instance_name: ladas_ansible_test_2
instance_tags: |-
Name: ladas_ansible_test_2
TestTag: test2
@Ladas
Ladas / run_all_specs.sh
Created May 14, 2018 13:03
Will run all provice_specs
#!/bin/bash
# Script for creating/updating ManageIQ plugins
# Ruby script in directory /path-to-manageiq/plugins
# @param --clone for cloning and set upstream
cd /home/mslemr/Projects/ManageIQ/upstream
git fetch --all
git checkout master
@Ladas
Ladas / good_query.sql
Last active May 10, 2018 07:38
slow scoped_search query
SELECT "vms".* FROM "vms"
INNER JOIN "taggings" ON "taggings"."taggable_id" = "vms"."id" AND "taggings"."taggable_type" = $1
INNER JOIN "tags" ON "tags"."id" = "taggings"."tag_id"
WHERE "vms"."type" IN ('ManageIQ::Providers::CloudManager::Vm',
'ManageIQ::Providers::Google::CloudManager::Vm',
'ManageIQ::Providers::Amazon::CloudManager::Vm',
'ManageIQ::Providers::Azure::CloudManager::Vm',
'ManageIQ::Providers::Openstack::CloudManager::Vm',
'ManageIQ::Providers::Vmware::CloudManager::Vm')
AND "vms"."template" = $2
@Ladas
Ladas / azure_refresh.rb
Created March 20, 2018 16:25
azure_refresh
equire 'manageiq_performance'
manager_name = ARGV[0] || "azure bigger"
ems = ExtManagementSystem.find_by(:name => manager_name)
unless ems
password = 'pswd'.freeze
userid = "user"
ems = ManageIQ::Providers::Azure::CloudManager.create(
@Ladas
Ladas / generate_metrics_parallel.rb
Last active January 17, 2018 15:56
generate_metrics_parallel.rb
# ActiveRecord::Base.logger = Logger.new(STDOUT)
NUMBER_OF_CONTAINERS = 20_000 # 100_000
NUMBER_OF_PROJECTS = 100
LABELS_PER_CONTAINER_IMAGE = 20
METRIC_PERIOD = 20.seconds
METRICS_START = 4.hours.ago.utc
METRICS_END = Time.now.utc
# Have also archived containers?
@Ladas
Ladas / mock_metrics.rb
Last active January 17, 2018 14:02
generate mock metrics and labels for containers
# ActiveRecord::Base.logger = Logger.new(STDOUT)
NUMBER_OF_CONTAINERS = 20_000 # 100_000
NUMBER_OF_PROJECTS = 100
LABELS_PER_CONTAINER_IMAGE = 20
METRIC_PERIOD = 20.seconds
METRICS_START = 1.days.ago.utc
METRICS_END = Time.now.utc
# Have also archived containers?
@Ladas
Ladas / generate_data_in_parallel.rb
Last active January 10, 2018 15:05
Generates data in parallel, in 8 processe the speed is 86k records per second
ActiveRecord::Base.logger = Logger.new(STDOUT)
UNIQUE_INDEXES_FOR_MODELS = {
# Just having :ems_id & :ems_ref
ContainerBuild => [:ems_id, :ems_ref],
ContainerBuildPod => [:ems_id, :ems_ref],
ContainerGroup => [:ems_id, :ems_ref],
ContainerLimit => [:ems_id, :ems_ref],
ContainerNode => [:ems_id, :ems_ref],
ContainerProject => [:ems_id, :ems_ref],
@Ladas
Ladas / generate_data.rb
Last active January 10, 2018 09:55
Generate huge amount of mock data, can insert around 27.4k records per s into Postgre DB
ActiveRecord::Base.logger = Logger.new(STDOUT)
UNIQUE_INDEXES_FOR_MODELS = {
# Just having :ems_id & :ems_ref
ContainerBuild => [:ems_id, :ems_ref],
ContainerBuildPod => [:ems_id, :ems_ref],
ContainerGroup => [:ems_id, :ems_ref],
ContainerLimit => [:ems_id, :ems_ref],
ContainerNode => [:ems_id, :ems_ref],
ContainerProject => [:ems_id, :ems_ref],
@Ladas
Ladas / perf_capture
Created November 29, 2017 08:53
huntin mem leaks
rss: 908332 live objects 3829402 gc: 23 pg: 9569 fpg: 0 ep 9569 tp 0---- 2017-11-28 16:19:36 UTC 0
rss: 1006148 live objects 3900281 gc: 29 pg: 9569 fpg: 0 ep 9569 tp 0---- 2017-11-28 16:22:15 UTC 1
rss: 1028232 live objects 3886911 gc: 34 pg: 9569 fpg: 0 ep 9569 tp 0---- 2017-11-28 16:25:07 UTC 2
rss: 1039276 live objects 3885838 gc: 39 pg: 9569 fpg: 0 ep 9569 tp 0---- 2017-11-28 16:27:45 UTC 3
rss: 1052328 live objects 3894789 gc: 44 pg: 9569 fpg: 0 ep 9569 tp 0---- 2017-11-28 16:30:15 UTC 4
rss: 1063136 live objects 3878740 gc: 49 pg: 9569 fpg: 0 ep 9569 tp 0---- 2017-11-28 16:32:54 UTC 5
rss: 1073020 live objects 3890319 gc: 54 pg: 9569 fpg: 0 ep 9569 tp 0---- 2017-11-28 16:35:48 UTC 6
rss: 1080832 live objects 3895098 gc: 59 pg: 9569 fpg: 0 ep 9569 tp 0---- 2017-11-28 16:38:27 UTC 7
rss: 1086920 live objects 3900161 gc: 64 pg: 9569 fpg: 0 ep 9569 tp 0---- 2017-11-28 16:41:02 UTC 8
rss: 1091912 live objects 3885167 gc: 69 pg: 9569 fpg: 0 ep 9569 tp 0---- 2017-11-28 16:43:41 UTC 9