Class: Cloudscale::Plugins::MySqlQueryCache

Inherits:
Plugin
  • Object
show all
Defined in:
lib/cloudscale/plugins/mysql/mysql_querycache.rb

Instance Attribute Summary collapse

Attributes inherited from Plugin

#log, #plugins

Instance Method Summary collapse

Methods inherited from Plugin

inherited, plugins

Constructor Details

#initializeMySqlQueryCache

Returns a new instance of MySqlQueryCache.



18
19
20
21
22
23
# File 'lib/cloudscale/plugins/mysql/mysql_querycache.rb', line 18

def initialize
  super
  if is_enabled
    @connection = Preops::MysqlPreop.instance.connection
  end
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



12
13
14
# File 'lib/cloudscale/plugins/mysql/mysql_querycache.rb', line 12

def connection
  @connection
end

Instance Method Details

#collect(agentInstanceId) ⇒ Object



25
26
27
28
29
30
# File 'lib/cloudscale/plugins/mysql/mysql_querycache.rb', line 25

def collect(agentInstanceId)
  registry = Monitor::Registry.instance
  metrics = Metrics::Agent.new
  log.info("Calling Collect on MysqlQueryCache")

end

#is_enabledObject



14
15
16
# File 'lib/cloudscale/plugins/mysql/mysql_querycache.rb', line 14

def is_enabled
  Preops::MysqlPreop.instance.is_enabled
end

#report_database_stats(registry, metrics) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/cloudscale/plugins/mysql/mysql_querycache.rb', line 32

def report_database_stats(registry, metrics)
  results = mysql.query('SHOW GLOBAL STATUS')

  registry.metrics["mysql.qcache.queries.cache"] = metrics.gauge :queriesInCache do
    { :value => results['queriesInCache'] }
  end

  registry.metrics["mysql.qcache.cache.hits"] = metrics.gauge :cacheHits do
    { :value => results['cacheHits'] }
  end

  registry.metrics["mysql.qcache.inserts"] = metrics.gauge :inserts do
    { :value => results['inserts'] }
  end

  registry.metrics["mysql.qcache.notcached"] = metrics.gauge :notCached do
    { :value => results['notCached'] }
  end

  registry.metrics["mysql.qcache.lowmem.prunes"] = metrics.gauge :lowMemPrunes do
    { :value => results['lowMemPrunes'] }
  end

end