Class: CdnManagerPcacheProbe::Cli
- Inherits:
-
Thor
- Object
- Thor
- CdnManagerPcacheProbe::Cli
- Includes:
- Thor::Actions
- Defined in:
- lib/cdn_manager_pcache_probe/cli.rb
Class Method Summary collapse
-
.exit_on_failure? ⇒ Boolean
exit with return code 1 in case of an error.
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
exit with return code 1 in case of an error
17 18 19 |
# File 'lib/cdn_manager_pcache_probe/cli.rb', line 17 def self.exit_on_failure? true end |
Instance Method Details
#collect ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/cdn_manager_pcache_probe/cli.rb', line 47 def collect bytes_sent = CdnManagerPcacheProbe::Connector.new( [:url] ).get_probe() usage = (bytes_sent / ([:interval] * 60) * 8 / 1024**2).round(3) if [:quiet] puts usage.round(0) else if [:key] say "Usage for #{options[:key]} ", :yellow else say "Overall usage ", :yellow end say "over #{options[:interval]} min (#{options[:delay]} min delay):", :yellow puts "Total volume sent: #{(bytes_sent / 1024**3).round(3)} GB" print "Average bandwidth: #{usage} Mbit/s" puts usage >= 1000 ? " (#{(usage / 1024.0).round(2)} Gbit/s)" : nil end end |
#version ⇒ Object
22 23 24 |
# File 'lib/cdn_manager_pcache_probe/cli.rb', line 22 def version say "cdn_manager_pcache_probe v#{VERSION}" end |