report_sanity_checker looks at a report, widget, or table view and runs a basic sanity check.
Add this line to your application's Gemfile:
gem 'report_sanity_checker'And then execute:
$ bundle
Or install it yourself as:
$ gem install report_sanity_checker
vmdb
report_sanity_checker # reads product/reports
report_sanity_checker ../manageiq-ui-classic/product/views/
report_sanity_checker underutilized.yml
report_sanity_checker -w # widgets
RAILS_ROOT=vmdb report_sanity_checker underutilized.ymlreport_sanity_checker.rb underutilized.yml| column | virtual | sql | sort | hidden | cond |
|---|---|---|---|---|---|
| managed.cust_portfolio | custom | ruby | sort | ||
| managed.cust_owner | custom | ruby | |||
| name | sql | ||||
| created_on | sql | ||||
| active | attr | sql | |||
| cpu_total_cores | attr | sql | |||
| overallocated_vcpus_pct | attr | ruby | cond | ||
| cpu_usagemhz_rate_average_max_over_time_period | attr | sql | |||
| mem_cpu | attr | sql | |||
| overallocated_mem_pct | attr | ruby | cond | ||
| derived_memory_used_max_over_time_period | attr | sql | |||
| allocated_disk_storage | attr | sql | |||
| used_disk_storage | attr | sql | |||
| v_pct_free_disk_space | attr | sql | cond | ||
| v_pct_used_disk_space | attr | sql |
This tells us a few things:
- This report is based upon the
Vmmodel (first line) managed.cust_portfoliois sorting on a tag - this is determined in ruby. sorting in ruby requires all records to be in memory.nameis a regular sql columnactiveis a virtual attribute but is derived in sql - you can sort or filter on this- Record filter uses 3 columns. Since
overallocated_vcpus_pctis determined in ruby, filtering is performed in ruby. All records are brought back from the database. v_pct_free_disk_spaceis calculated on the fly, but can be calculated in sql. Filtering on this field does not require all records be loaded into memory. Since theMiqExpressionhas anORfor these fields, this optimization can not be used.
Take away:
- A report that only filters by
v_pct_free_disk_spacewould be much quicker and wouldn't download every VM into memory. - the whole
Vmtable is downloaded. This report will run slowly.
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/report_sanity_checker.
The gem is available as open source under the terms of the MIT License.