Class: AwsAuditor::Scripts::Audit
- Inherits:
-
Object
- Object
- AwsAuditor::Scripts::Audit
- Extended by:
- AWSWrapper
- Defined in:
- lib/aws_auditor/scripts/audit.rb
Instance Attribute Summary
Attributes included from AWSWrapper
Class Method Summary collapse
- .audit_cache(options) ⇒ Object
- .audit_ec2(options) ⇒ Object
- .audit_rds(options) ⇒ Object
- .colorize(key, value) ⇒ Object
- .execute(environment, options = nil) ⇒ Object
Class Method Details
.audit_cache(options) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/aws_auditor/scripts/audit.rb', line 58 def self.audit_cache() puts "============== CACHE ==============" if [:instances] CacheInstance.instance_count_hash(CacheInstance.get_instances).each do |key,value| say "<%= color('#{key}: #{value}', :white) %>" end elsif [:reserved] CacheInstance.instance_count_hash(CacheInstance.get_reserved_instances).each do |key,value| say "<%= color('#{key}: #{value}', :white) %>" end else CacheInstance.compare.each do |key,value| colorize(key,value) end end end |
.audit_ec2(options) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/aws_auditor/scripts/audit.rb', line 41 def self.audit_ec2() puts "=============== EC2 ===============" if [:instances] EC2Instance.instance_count_hash(EC2Instance.get_instances).each do |key,value| say "<%= color('#{key}: #{value}', :white) %>" end elsif [:reserved] EC2Instance.instance_count_hash(EC2Instance.get_reserved_instances).each do |key,value| say "<%= color('#{key}: #{value}', :white) %>" end else EC2Instance.compare.each do |key,value| colorize(key,value) end end end |
.audit_rds(options) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/aws_auditor/scripts/audit.rb', line 24 def self.audit_rds() puts "=============== RDS ===============" if [:instances] RDSInstance.instance_count_hash(RDSInstance.get_instances).each do |key,value| say "<%= color('#{key}: #{value}', :white) %>" end elsif [:reserved] RDSInstance.instance_count_hash(RDSInstance.get_reserved_instances).each do |key,value| say "<%= color('#{key}: #{value}', :white) %>" end else RDSInstance.compare.each do |key, value| colorize(key,value) end end end |
.colorize(key, value) ⇒ Object
75 76 77 78 79 80 81 82 83 |
# File 'lib/aws_auditor/scripts/audit.rb', line 75 def self.colorize(key,value) if value < 0 say "<%= color('#{key}: #{value}', :yellow) %>" elsif value == 0 say "<%= color('#{key}: #{value}', :green) %>" elsif value > 0 say "<%= color('#{key}: #{value}', :red) %>" end end |
.execute(environment, options = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/aws_auditor/scripts/audit.rb', line 8 def self.execute(environment, =nil) aws(environment) if [:ec2] audit_ec2() elsif [:rds] audit_rds() elsif [:cache] audit_cache() else audit_ec2() audit_rds() audit_cache() end end |