class Gauges

Defined in:

controllers/gauges.cr

Constant Summary

AFTER = {} of Nil => Nil
AROUND = {} of Nil => Nil
BEFORE = {set_request_id => {nil, nil}, set_date_header => {nil, nil}, require_login => {nil, nil}, require_read => {[index, show], nil}, require_write => {nil, [index, show]}} of Nil => Nil
FORCE = {:force => {nil, nil}} of Nil => Nil
LOCAL_AFTER = {} of Nil => Nil

function => options

LOCAL_AROUND = {} of Nil => Nil

function => options

LOCAL_BEFORE = {require_read => {nil, nil}} of Nil => Nil

function => options

LOCAL_FORCE = {} of Nil => Nil

function => options

LOCAL_RESCUE = {DB::ConnectionRefused => {db_error, nil}, NilAssertionError => {null_error, nil}} of Nil => Nil

function => options

LOCAL_ROUTES = {host => {"get", "/host", nil, do host = Host.first.not_nil! boot = (Boot.find(last[:boot].not_nil!.seq)).not_nil! respond_with do html(template("gauge_host.cr")) end end, false}, memory => {"get", "/memory", nil, do memory = (Memory.find(last[:memory].not_nil!.seq)).not_nil! respond_with do html(template("gauge_memory.cr")) end end, false}, load => {"get", "/load", nil, do load = (Load.find(last[:load].not_nil!.seq)).not_nil! respond_with do html(template("gauge_load.cr")) end end, false}, net => {"get", "/net", nil, do net = (Net.find(last[:net].not_nil!.seq)).not_nil! respond_with do html(template("gauge_net.cr")) end end, false}, disk => {"get", "/disk/:group", nil, do even = Array(Disk).new odd = Array(Disk).new latest_disk = (Disk.find(last[:disk].not_nil!.seq)).not_nil! (Disk.all("JOIN partition p on p.id = disk.partition_id WHERE seconds = ?", [latest_disk.seconds])).reject do |d| d.size_mb == 0.0 end.each_with_index do |d, i| ( (i % 2) == 0) ? ( even << d) : ( odd << d) end disks = ( params["group"] == "even") ? even : odd if disks.size > 0 else return end disk = disks.shuffle.pop accent = case disk.usage when .<=(25.0) "blue" when .<=(50.0) "green" when .<=(75.0) "yellow" else "red" end respond_with do html(template("gauge_disk.cr")) end end, false}, top => {"get", "/top", nil, do latest_pid = (Pid.find(last[:pid].not_nil!.seq)).not_nil! pids = (Pid.where(seconds: latest_pid.seconds).order(memory: :asc).select.pop(4)).reverse respond_with do html(template("gauge_pid.cr")) end end, false}, service => {"get", "/service", nil, do services_up = Array(Service).new services_dn = Array(Service).new last_svc = "" Service.order(name: :asc, seconds: :desc).select.each do |svc| if svc.enabled && (svc.name != last_svc) svc.running ? ( services_up << svc) : ( services_dn << svc) end last_svc = svc.name end services_up.sort_by! do |svc| svc.name.downcase end services_dn.sort_by! do |svc| svc.name.downcase end enabled_services = services_dn + services_up respond_with do html(template("gauge_service.cr")) end end, false}} of Nil => Nil

function => options

LOCAL_SKIP = {require_write => {nil, nil}} of Nil => Nil

function => options

NAMESPACE = ["/gauges"]

default namespace based on class

RESCUE = {DB::ConnectionRefused => {db_error, nil}, NilAssertionError => {null_error, nil}} of Nil => Nil
ROUTES = {host => {"get", "/host", nil, do host = Host.first.not_nil! boot = (Boot.find(last[:boot].not_nil!.seq)).not_nil! respond_with do html(template("gauge_host.cr")) end end, false}, memory => {"get", "/memory", nil, do memory = (Memory.find(last[:memory].not_nil!.seq)).not_nil! respond_with do html(template("gauge_memory.cr")) end end, false}, load => {"get", "/load", nil, do load = (Load.find(last[:load].not_nil!.seq)).not_nil! respond_with do html(template("gauge_load.cr")) end end, false}, net => {"get", "/net", nil, do net = (Net.find(last[:net].not_nil!.seq)).not_nil! respond_with do html(template("gauge_net.cr")) end end, false}, disk => {"get", "/disk/:group", nil, do even = Array(Disk).new odd = Array(Disk).new latest_disk = (Disk.find(last[:disk].not_nil!.seq)).not_nil! (Disk.all("JOIN partition p on p.id = disk.partition_id WHERE seconds = ?", [latest_disk.seconds])).reject do |d| d.size_mb == 0.0 end.each_with_index do |d, i| ( (i % 2) == 0) ? ( even << d) : ( odd << d) end disks = ( params["group"] == "even") ? even : odd if disks.size > 0 else return end disk = disks.shuffle.pop accent = case disk.usage when .<=(25.0) "blue" when .<=(50.0) "green" when .<=(75.0) "yellow" else "red" end respond_with do html(template("gauge_disk.cr")) end end, false}, top => {"get", "/top", nil, do latest_pid = (Pid.find(last[:pid].not_nil!.seq)).not_nil! pids = (Pid.where(seconds: latest_pid.seconds).order(memory: :asc).select.pop(4)).reverse respond_with do html(template("gauge_pid.cr")) end end, false}, service => {"get", "/service", nil, do services_up = Array(Service).new services_dn = Array(Service).new last_svc = "" Service.order(name: :asc, seconds: :desc).select.each do |svc| if svc.enabled && (svc.name != last_svc) svc.running ? ( services_up << svc) : ( services_dn << svc) end last_svc = svc.name end services_up.sort_by! do |svc| svc.name.downcase end services_dn.sort_by! do |svc| svc.name.downcase end enabled_services = services_dn + services_up respond_with do html(template("gauge_service.cr")) end end, false}} of Nil => Nil
SKIP = {require_write => {nil, nil}} of Nil => Nil

Class Method Summary

Instance Method Summary

Macro Summary

Instance methods inherited from class Application

authorize_groups(group_names : String) authorize_groups, require_read require_read, require_write require_write, set_date_header set_date_header, set_request_id set_request_id

Class methods inherited from class Application

context(method : String, route : String, route_params : Hash(String, String) | Nil = nil, headers : Hash(String, String) | Nil = nil, body : String | Bytes | IO | Nil = nil, &) context

Instance methods inherited from module SessionUtils

current_user(username : String)
current_user
current_user
, end_session end_session, notice(message : String)
notice
notice
, notice? notice?, pack_string(txt : String) pack_string, require_login require_login, unpack_string(txt : String) unpack_string

Class Method Detail

def self.__init_routes__(router) #

Routes call the functions generated above


def self.__route_list__ #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.base_route #

Helper for obtaining base route


def self.context(method : String, route : String, route_params : Hash(String, String) | Nil = nil, headers : Hash(String, String) | Nil = nil, body : String | Bytes | IO | Nil = nil, &) #

[View source]
def self.disk(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__gauges_disk__group(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__gauges_host(context, head_request) #

Generate functions for each route


def self.get__gauges_load(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__gauges_memory(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__gauges_net(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__gauges_service(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.get__gauges_top(context, head_request) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.host(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Helper methods for performing redirect_to calls


def self.load(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.memory(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.net(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.service(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


def self.top(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts) #

Create draw_routes function

Create instance of controller class init with context, params and logger protocol checks (https etc) controller instance created begin exception helpers inline the around filters inline the before filters inline the action inline the after filters rescue exception handlers


Instance Method Detail

def base_route(*args, **options) #

Helper for obtaining base route


def base_route(*args, **options, &) #

Helper for obtaining base route


def db_error(e) #

[View source]
def disk #

[View source]
def host #

[View source]
def last #

[View source]
def load #

[View source]
def memory #

[View source]
def net #

[View source]
def null_error(e) #

[View source]
def service #

[View source]
def show_arc(percent : Float, size : String = "", color : String = "") #

[View source]
def show_bar(percent : Float, size : String = "", color : String = "") #

[View source]
def top #

[View source]

Macro Detail

macro __inherit_after_filters__ #

macro __inherit_around_filters__ #

macro __inherit_before_filters__ #

macro __inherit_force_filters__ #

macro __inherit_rescue_filters__ #

macro __inherit_routes_filters__ #

macro __inherit_skip_filters__ #