Class: Nephelae::RedisStatus

Inherits:
Plugin
  • Object
show all
Defined in:
lib/nephelae/plugins/redis.rb

Instance Attribute Summary

Attributes inherited from Plugin

#config

Instance Method Summary collapse

Methods inherited from Plugin

#initialize, #namespace

Constructor Details

This class inherits a constructor from Nephelae::Plugin

Instance Method Details

#get_metricsObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/nephelae/plugins/redis.rb', line 5

def get_metrics
  metrics = Metrics.new(namespace)
  output = `#{command}`

  if $?.success?
    stats = parse_status(output)
    metrics.append_metric('Up', 1)
    metrics.append_metric('MasterLinkStatus', (stats[:master] == 'up' ? 1 : 0)) unless stats[:master].nil?
    metrics.append_metric('MasterIOSecondsAgo', stats[:master_last_io_seconds_ago], {unit: 'Seconds'}) unless stats[:master_last_io_seconds_ago].nil?
    metrics.append_metric('ChangesSinceLastSave', stats[:changes_since_last_save], {unit: 'Count'})
    metrics.append_metric('UsedMemory', stats[:used_memory], {unit: 'Bytes'})
    metrics.append_metric('ConnectedSlaves', stats[:connected_slaves], {unit: 'Count'})
    metrics.append_metric('ConnectedClients', stats[:connected_clients], {unit: 'Count'})
  else
    metrics.append_metric('Up', 0)
  end

  return metrics

end