class Gauges
- Gauges
- Application
- ActionController::Base
- Reference
- Object
Defined in:
controllers/gauges.crConstant 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
-
.__init_routes__(router)
Routes call the functions generated above
-
.__route_list__
Create draw_routes function
-
.base_route
Helper for obtaining base route
- .context(method : String, route : String, route_params : Hash(String, String) | Nil = nil, headers : Hash(String, String) | Nil = nil, body : String | Bytes | IO | Nil = nil, &)
-
.disk(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Create draw_routes function
-
.get__gauges_disk__group(context, head_request)
Create draw_routes function
-
.get__gauges_host(context, head_request)
Generate functions for each route
-
.get__gauges_load(context, head_request)
Create draw_routes function
-
.get__gauges_memory(context, head_request)
Create draw_routes function
-
.get__gauges_net(context, head_request)
Create draw_routes function
-
.get__gauges_service(context, head_request)
Create draw_routes function
-
.get__gauges_top(context, head_request)
Create draw_routes function
-
.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
-
.load(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Create draw_routes function
-
.memory(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Create draw_routes function
-
.net(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Create draw_routes function
-
.service(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Create draw_routes function
-
.top(hash_parts : Hash(String | Symbol, Nil | Bool | Int32 | Int64 | Float32 | Float64 | String | Symbol) | Nil = nil, **tuple_parts)
Create draw_routes function
Instance Method Summary
-
#base_route(*args, **options)
Helper for obtaining base route
-
#base_route(*args, **options, &)
Helper for obtaining base route
- #db_error(e)
- #disk
- #host
- #last
- #load
- #memory
- #net
- #null_error(e)
- #service
- #show_arc(percent : Float, size : String = "", color : String = "")
- #show_bar(percent : Float, size : String = "", color : String = "")
- #top
Macro Summary
- __inherit_after_filters__
- __inherit_around_filters__
- __inherit_before_filters__
- __inherit_force_filters__
- __inherit_rescue_filters__
- __inherit_routes_filters__
- __inherit_skip_filters__
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
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
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
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
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
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
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
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
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
Helper methods for performing redirect_to calls
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
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
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
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
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