class RedisDashboard::Application

Public Instance Methods

active_page?(path='') click to toggle source
# File lib/redis_dashboard/application.rb, line 71
def active_page?(path='')
  request.path_info == '/' + path
end
client() click to toggle source
# File lib/redis_dashboard/application.rb, line 43
def client
  @client ||= RedisDashboard::Client.new(RedisDashboard.urls[redis_id.to_i])
end
client_event_description(event) click to toggle source
# File lib/redis_dashboard/application.rb, line 117
def client_event_description(event)
  # https://redis.io/commands/client-list
  @client_event_description ||= {
    O: "the client is a slave in MONITOR mode",
    S: "the client is a normal slave server",
    M: "the client is a master",
    x: "the client is in a MULTI/EXEC context",
    b: "the client is waiting in a blocking operation",
    i: "the client is waiting for a VM I/O (deprecated)",
    d: "a watched keys has been modified - EXEC will fail",
    c: "connection to be closed after writing entire reply",
    u: "the client is unblocked",
    U: "the client is connected via a Unix domain socket",
    r: "the client is in readonly mode against a cluster node",
    A: "connection to be closed ASAP",
    N: "no specific flag set",
  }
  @client_event_description[event.to_sym]
end
clients() click to toggle source
# File lib/redis_dashboard/application.rb, line 47
def clients
  @clients ||= RedisDashboard.urls.map do |url|
    RedisDashboard::Client.new(url)
  end
end
clients_column_description(col) click to toggle source
# File lib/redis_dashboard/application.rb, line 93
def clients_column_description(col)
  # https://redis.io/commands/client-list
  @clients_column_description ||= {
    id: "an unique 64-bit client ID (introduced in Redis 2.8.12).",
    addr: "address/port of the client",
    fd: "file descriptor corresponding to the socket",
    age: "total duration of the connection in seconds",
    idle: "idle time of the connection in seconds",
    flags: "client flags (see below)",
    db: "current database ID",
    sub: "number of channel subscriptions",
    psub: "number of pattern matching subscriptions",
    multi: "number of commands in a MULTI/EXEC context",
    qbuf: "query buffer length (0 means no query pending)",
    'qbuf-f': "ree: free space of the query buffer (0 means the buffer is full)",
    obl: "output buffer length",
    oll: "output list length (replies are queued in this list when the buffer is full)",
    omem: "output buffer memory usage",
    events: "file descriptor events (see below)",
    cmd: "last command played",
  }
  @clients_column_description[col.to_sym]
end
close_clients() click to toggle source
# File lib/redis_dashboard/application.rb, line 53
def close_clients
  @client.close if @client
  @clients.each { |client| client.close } if @clients
end
compute_cache_hit_ratio(info) click to toggle source
# File lib/redis_dashboard/application.rb, line 83
def compute_cache_hit_ratio(info)
  hits = info["keyspace_hits"].to_i
  misses = info["keyspace_misses"].to_i
  if (total = hits + misses) > 0
    hits * 100.0 / total
  else
    0
  end
end
epoch_to_short_date_time(epoch) click to toggle source
# File lib/redis_dashboard/application.rb, line 63
def epoch_to_short_date_time(epoch)
  Time.at(epoch).strftime("%b %d %H:%M")
end
format_impact_percentage(percentage) click to toggle source
# File lib/redis_dashboard/application.rb, line 75
def format_impact_percentage(percentage)
  percentage < 1 ? "< 1 <small>%</small>" : "#{percentage.round} <small>%</small>"
end
format_usec(usec) click to toggle source
# File lib/redis_dashboard/application.rb, line 79
def format_usec(usec)
  "#{usec}&nbsp;<small>㎲</small>"
end
page_title() click to toggle source
# File lib/redis_dashboard/application.rb, line 59
def page_title
  "#{URI(client.url).host} (#{client.info["role"]})"
end
redis_id() click to toggle source
# File lib/redis_dashboard/application.rb, line 67
def redis_id
  params[:id]
end