Class: Sensu::Plugins::Prometheus::Checks::Output
- Inherits:
-
Object
- Object
- Sensu::Plugins::Prometheus::Checks::Output
- Defined in:
- lib/sensu/plugins/prometheus/checks/output.rb
Overview
Handles the final output of checks, creates a custom message based on template and informed variables.
Constant Summary collapse
- TEMPLATES =
{ 'disk' => \ "Disk: <%= value %>%, Mountpoint: <%= cfg['mount'] %> |disk=<%= value %>", 'disk_all' => \ "Disk: <%= cfg['mount'] %>, Inode Usage: <%= value %>% |inodes=<%= value %>", 'load_per_cpu' => \ 'Load: <%= value %>|load=<%= value %>', 'load_per_cluster' => \ 'Cluster Load: <%= value %> |load=<%= value %>', 'load_per_cluster_minus_n' => \ 'Cluster Load: <%= value %> |load=<%= value %>', 'inode' => \ "Disk: <%= cfg['mount'] %>, Inodes: <%= value %>% |inodes=<%= value %>", 'memory' => \ 'Memory <%= value %>% |memory=<%= value %>', 'memory_per_cluster' => \ 'Cluster Memory: <%= value %>% |memory=<%= value %>"', 'predict_disk_all' => \ "Disks to run out of space in the next <%= cfg['days'] %> days: <%= value %>", 'service' => \ "Service: <%= cfg['name'] %> (<%= cfg['state'] %>=<%= value %>)" }.freeze
Instance Method Summary collapse
Instance Method Details
#render(template_name, vars) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/sensu/plugins/prometheus/checks/output.rb', line 36 def render(template_name, vars) template_name = template_name.to_s raise "Can't find template for '#{template_name}'" \ if !TEMPLATES.key?(template_name) || TEMPLATES[template_name].empty? ns = Sensu::Plugins::Prometheus::Checks::Namespace.new(vars) ERB.new(TEMPLATES[template_name]).result(ns.namespace_binding) end |