Skip to content

Instantly share code, notes, and snippets.

@kbrock
Created June 21, 2017 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbrock/6b2fef0e99270b2caba1436046bf576c to your computer and use it in GitHub Desktop.
Save kbrock/6b2fef0e99270b2caba1436046bf576c to your computer and use it in GitHub Desktop.
Metrics capture timing
def reload_models
[Vm, Host, Storage].each { |m| m.update_all(:last_perf_capture_on => 50.minutes.ago) } # <== still tweaking
[MiqTask, MiqQueue, Metric, MetricRollup, VimPerformanceState].each { |m| m.truncate}
ActiveRecord::Base.connection.execute("vacuum full")
Module.clear_all_cache_with_timeout
[[MiqProductFeature, :@feature_cache], [MiqProductFeature, :@obj_cache], [BottleneckEvent, :@event_definitions],
[Tenant, :@root_tenant]].each { |i, ivar| i.instance_variable_set(ivar, nil) }
MiqServer.my_server ; MiqServer.my_zone
[ExtManagementSystem, Host, EmsCluster, Tagging, Tag, HostStorage, Storage, Vm, MiqRegion, MiqTask, Relationship, Disk,
Endpoint, Authentication, ServerRole, MiqWorker, MiqQueue, MetricRollup, BottleneckEvent].each { |m| m.first }
end
# run multiple times:
reload! ; reload_models ; bookend("capu-trunc", :gc => true) { Metric::Capture.perf_capture_timer }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment