Class: Source::Nagios

Inherits:
Source
  • Object
show all
Includes:
Helpers
Defined in:
lib/source/nagios.rb

Overview

Constant Summary

Constants included from Helpers

Helpers::REDIS_KEY

Instance Method Summary collapse

Methods included from Helpers

#data_sanitize, #delete_metrics_cache, #get_json, #init_lib, #init_source, #init_store, #interpolate, #is_up?, #json_metrics, #json_metrics_list, #keysplit, #mandatory_param, #optional_param, #origin_settings, #redis_conn, #top_tail_pad

Instance Method Details

#metaadd(meta) ⇒ Object

For nagios, add some nice things


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/source/nagios.rb', line 23

def metaadd meta
	if meta["service"] == "cpu" then
		color = { "Idle" => "#dddddd",  # an "idle" color
   			"User" => "#3465a4", "System" => "#73d216", "Nice" => "#f57900", "Iowait" => "#cc0000", #pnp4nagios
			"Irq" => "#916f7c", "Softirq" => "#9955ff" , "Steal" => "#ffcc00" # fill the remaining palette

		}
	elsif meta["service"] == "mem" then
		color = { "Used" => "#729fcf", "Cached" => "#fcaf3e", "Buffers" => "#fce84f", "Free" => "#8ae234"} #pnp4nagios
	elsif meta["service"] == "neutron-L3_agents" then
		color = { "l3_agents_alive" => "#54CA05", "l3_agents_dead" => "#2A6403", "routers_dead" => "#ff0000", "routers_alive" => "#ffeb00"}
	end

	color.each{|k,v| if meta["metric"].include? k then meta["color"] = v; end } if color

	return meta
end

#titleize(keys) ⇒ Object

Humanize the title for the perfdata feed. Handles both v1 and v2 style Vaultaire metadata


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/source/nagios.rb', line 6

def titleize keys 
	nice = []

	if keys.include? "hostname"
		nice << keys["hostname"]
		nice << keys["service_name"] unless keys["service_name"] == "host"
		nice << keys["metric"]
	else
		nice << keys["host"]
		nice << keys["service"] unless keys["service"] == "host"
		nice << keys["metric"]
	end

	return URI.decode(nice.join(" - "))
end