cloudscale 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cloudscale.rb +37 -25
- data/lib/cloudscale/monitor/agent/{init.rb → agent.rb} +42 -1
- data/lib/cloudscale/monitor/plugin/settings_db.rb +60 -0
- data/lib/cloudscale/monitor/{agent/preops → preops}/general_preop.rb +0 -0
- data/lib/cloudscale/monitor/preops/preop.rb +62 -0
- data/lib/cloudscale/plugins/mongo/mongo_db_status.rb +24 -19
- data/lib/cloudscale/plugins/mongo/mongo_replica_status.rb +48 -75
- data/lib/cloudscale/plugins/mongo/mongo_server_status.rb +112 -135
- data/lib/cloudscale/plugins/mongo/preops/mongodb_preop.rb +113 -0
- data/lib/cloudscale/plugins/os/preops/{plugin_preop.rb → os_preop.rb} +7 -4
- data/lib/cloudscale/plugins/os/sigar_cpu_perc.rb +3 -3
- data/lib/cloudscale/plugins/os/sigar_disk_iops.rb +4 -4
- data/lib/cloudscale/plugins/os/sigar_disk_space.rb +3 -3
- data/lib/cloudscale/plugins/os/sigar_net_byte_information.rb +4 -5
- data/lib/cloudscale/plugins/os/sigar_packet_information.rb +4 -4
- data/lib/cloudscale/plugins/os/sigar_ram_usage.rb +4 -4
- data/lib/cloudscale/plugins/os/sigar_swap_usage.rb +3 -3
- data/lib/cloudscale/plugins/plugin.rb +2 -50
- data/lib/cloudscale/plugins/postgres/postgres_server_status.rb +60 -101
- data/lib/cloudscale/plugins/postgres/preops/postgres_preop.rb +80 -0
- data/lib/cloudscale/plugins/preops/plugin_preop.rb +30 -0
- data/lib/cloudscale/registry.rb +1 -0
- data/lib/cloudscale/store/plugin/host +1 -0
- data/lib/cloudscale/store/plugin/port +1 -0
- data/lib/cloudscale/store/plugin/token +1 -0
- data/lib/cloudscale/version.rb +1 -1
- metadata +41 -10
- data/lib/cloudscale/monitor/agent/init_charts.rb +0 -50
- data/lib/cloudscale/monitor/agent/init_menus.rb +0 -44
- data/lib/cloudscale/monitor/agent/preops/preop.rb +0 -76
- data/lib/cloudscale/plugins/preops/plugin_mongodb_preop.rb +0 -105
- data/lib/cloudscale/plugins/preops/plugin_postgres_preop.rb +0 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36ae38eb4e8a1200b5e879ca565843d78846eb32
|
4
|
+
data.tar.gz: 4912656914e1c5d406c2b84bec72b22cb71d99fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2702905e295c443f6216f31832d629d21753d2d842bb92169163c5089864faf4fc6c66f66a275def7347ced503cae2edec22a64ae550f88d29988849bbd5775
|
7
|
+
data.tar.gz: 2bb12b0c1586ff22105bcffbfda0f8ef5002a41d6e7e6a5d860778b81a936e19bec780db64e46c7864835d9b3e269b2411e975ae3296f81b65dd9b3e368ab52a
|
data/lib/cloudscale.rb
CHANGED
@@ -3,11 +3,16 @@ require "singleton"
|
|
3
3
|
require "yaml"
|
4
4
|
require "json"
|
5
5
|
require "#{File.dirname(__FILE__)}/cloudscale/version"
|
6
|
-
require "#{File.dirname(__FILE__)}/cloudscale/monitor/agent/init"
|
7
6
|
require "#{File.dirname(__FILE__)}/cloudscale/schedule"
|
8
|
-
require "#{File.dirname(__FILE__)}/cloudscale/monitor/agent/
|
9
|
-
require "#{File.dirname(__FILE__)}/cloudscale/plugins/plugin"
|
7
|
+
require "#{File.dirname(__FILE__)}/cloudscale/monitor/agent/agent"
|
10
8
|
require "#{File.dirname(__FILE__)}/cloudscale/monitor/model/constants/agent_store"
|
9
|
+
require "#{File.dirname(__FILE__)}/cloudscale/monitor/preops/general_preop"
|
10
|
+
|
11
|
+
require "#{File.dirname(__FILE__)}/cloudscale/monitor/plugin/settings_db"
|
12
|
+
require "#{File.dirname(__FILE__)}/cloudscale/plugins/preops/plugin_preop"
|
13
|
+
Dir["#{File.dirname(__FILE__)}/cloudscale/plugins/*/preops/*.rb"].each { | f | require f }
|
14
|
+
|
15
|
+
require "#{File.dirname(__FILE__)}/cloudscale/plugins/plugin"
|
11
16
|
Dir["#{File.dirname(__FILE__)}/cloudscale/plugins/*/*.rb"].each { | f | require f }
|
12
17
|
|
13
18
|
##
|
@@ -23,7 +28,7 @@ module Cloudscale
|
|
23
28
|
|
24
29
|
scheduler = nil
|
25
30
|
|
26
|
-
|
31
|
+
preopDb = Preops::PluginSettingsDb.instance
|
27
32
|
|
28
33
|
parser = OptionParser.new do | parser |
|
29
34
|
|
@@ -47,35 +52,44 @@ module Cloudscale
|
|
47
52
|
parser.separator "\n"
|
48
53
|
parser.separator "Monitoring specific Settings [Mandatory]"
|
49
54
|
|
55
|
+
preopDb.options.merge!(Monitor::GeneralPreop.instance.options)
|
50
56
|
Monitor::GeneralPreop.instance.options.each do | key, value |
|
51
57
|
if (value[:required])
|
52
58
|
mandatoryGeneral.push(key)
|
53
59
|
end
|
54
60
|
parser.on(value[:argument][1,2] + " n", value[:argument] + "=n", value[:description]) do | value |
|
55
|
-
|
61
|
+
preopDb.set_option_value(key, value)
|
56
62
|
end
|
57
63
|
end
|
58
64
|
|
59
65
|
parser.separator "\n"
|
60
66
|
parser.separator "Plugin specific Settings [Mandatory]"
|
61
67
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
+
Preops::PluginPreop.pluginPreops.each do | pluginPreop_class |
|
69
|
+
pluginPreop = pluginPreop_class.instance
|
70
|
+
|
71
|
+
preopDb.options.merge!(pluginPreop.options)
|
72
|
+
if (pluginPreop.is_enabled)
|
73
|
+
pluginPreop.options.each do | key, value |
|
74
|
+
if (value[:required])
|
75
|
+
mandatory.push(key)
|
76
|
+
end
|
77
|
+
parser.on(value[:argument][1,2] + " n", value[:argument] + "=n", value[:description]) do | value |
|
78
|
+
preopDb.set_option_value(key, value)
|
79
|
+
end
|
80
|
+
end
|
68
81
|
end
|
82
|
+
|
69
83
|
end
|
70
84
|
end
|
71
85
|
|
72
86
|
begin
|
73
87
|
parser.parse!
|
74
88
|
missingGeneral = mandatoryGeneral.select { | param |
|
75
|
-
|
89
|
+
preopDb.get_option_value(param).nil?
|
76
90
|
}
|
77
91
|
missing = mandatory.select{ | param |
|
78
|
-
|
92
|
+
preopDb.get_option_value(param).nil?
|
79
93
|
}
|
80
94
|
if (!missing.empty? || !missingGeneral.empty?)
|
81
95
|
puts "\n"
|
@@ -86,18 +100,18 @@ module Cloudscale
|
|
86
100
|
puts parser
|
87
101
|
exit
|
88
102
|
else
|
89
|
-
|
90
|
-
|
103
|
+
preopDb.save_options
|
104
|
+
preopDb.save_options
|
91
105
|
end
|
92
106
|
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
|
93
107
|
puts $!.to_s
|
94
108
|
puts parser
|
95
109
|
exit
|
96
110
|
end
|
97
|
-
|
111
|
+
|
98
112
|
begin
|
99
|
-
host =
|
100
|
-
port =
|
113
|
+
host = preopDb.get_option_value("host")
|
114
|
+
port = preopDb.get_option_value("port")
|
101
115
|
|
102
116
|
config = Constants::Agent.load()
|
103
117
|
if (port != nil) then config["port"] = port end
|
@@ -105,15 +119,13 @@ module Cloudscale
|
|
105
119
|
Constants::Agent.save(config)
|
106
120
|
end
|
107
121
|
|
108
|
-
agent_instance = Monitor::
|
122
|
+
agent_instance = Monitor::Agent.new(preopDb.get_option_value("token"))
|
109
123
|
agent_instance_id = registry = Monitor::Registry.instance.agent_instance_id
|
110
124
|
|
111
125
|
case ARGV[0]
|
112
126
|
when "start"
|
113
127
|
plugins = Set.new
|
114
128
|
|
115
|
-
Plugins::PluginPreop.instance.register
|
116
|
-
|
117
129
|
Plugins::Plugin.plugins.each do | plugin_class |
|
118
130
|
plugin = plugin_class.new
|
119
131
|
plugins << plugin
|
@@ -124,12 +136,12 @@ module Cloudscale
|
|
124
136
|
puts "call stop on options #{options.inspect}"
|
125
137
|
when "reset"
|
126
138
|
puts "Starting cleanup process"
|
127
|
-
|
128
|
-
|
139
|
+
Monitor::Agent.reset(agent_instance_id)
|
140
|
+
preopDb.clear_options
|
129
141
|
when "delete"
|
130
142
|
puts "Starting removal process"
|
131
|
-
|
132
|
-
|
143
|
+
Monitor::Agent.remove(agent_instance_id)
|
144
|
+
preopDb.clear_options
|
133
145
|
else
|
134
146
|
puts parser
|
135
147
|
end
|
@@ -13,7 +13,7 @@ require "#{File.dirname(__FILE__)}/../../rest/rest_client"
|
|
13
13
|
##
|
14
14
|
module Cloudscale
|
15
15
|
module Monitor
|
16
|
-
class
|
16
|
+
class Agent
|
17
17
|
attr_accessor :log, :server, :client
|
18
18
|
|
19
19
|
def initialize(token)
|
@@ -58,6 +58,47 @@ module Cloudscale
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
def self.reset(agentInstanceId)
|
62
|
+
resetRestEndpoint('coredatas', agentInstanceId, 'Coredata')
|
63
|
+
resetRestEndpoint('tables', agentInstanceId, 'Table')
|
64
|
+
resetRestEndpoint('charts', agentInstanceId, 'Chart')
|
65
|
+
|
66
|
+
remove_agenInstance(agentInstanceId)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.remove(agentInstanceId)
|
70
|
+
reset(agentInstanceId)
|
71
|
+
|
72
|
+
Constants::AgentInstance.remove()
|
73
|
+
end
|
74
|
+
|
75
|
+
def self.resetRestEndpoint(entityRel, agentInstanceId, entityName)
|
76
|
+
rest_client = RestClientWrapper.instance
|
77
|
+
entities = rest_client.searchAny(entityRel,"findByAgentInstanceId",
|
78
|
+
{ :agentInstanceId => agentInstanceId })
|
79
|
+
|
80
|
+
puts "Found #{entityName} elements for Agent (#{agentInstanceId}): #{entities["content"].length.to_s}"
|
81
|
+
puts " Starting to delete all elements..."
|
82
|
+
|
83
|
+
entities["content"].each do | entity |
|
84
|
+
rest_client.delete(entityRel, RestClientWrapper.load_entity_id(entity))
|
85
|
+
end
|
86
|
+
|
87
|
+
puts " Deleting all elements was successful \n\n"
|
88
|
+
end
|
89
|
+
|
90
|
+
def self.remove_agenInstance(agentInstanceId)
|
91
|
+
rest_client = RestClientWrapper.instance
|
92
|
+
puts "Removing AgentInstance completely:\n"
|
93
|
+
|
94
|
+
agent_instance = rest_client.searchOne('agentInstances',
|
95
|
+
'findByAgentInstanceId', { :id => agentInstanceId })
|
96
|
+
|
97
|
+
rest_client.delete('agentInstances', RestClientWrapper.load_entity_id(agent_instance))
|
98
|
+
|
99
|
+
puts " Deleting AgentInstance was successful \n\n"
|
100
|
+
end
|
101
|
+
|
61
102
|
end
|
62
103
|
end
|
63
104
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "fsdb"
|
2
|
+
require "#{File.dirname(__FILE__)}/../../registry"
|
3
|
+
|
4
|
+
##
|
5
|
+
#
|
6
|
+
# @author Johannes Hiemer.
|
7
|
+
#
|
8
|
+
##
|
9
|
+
module Cloudscale
|
10
|
+
module Preops
|
11
|
+
class PluginSettingsDb
|
12
|
+
include Singleton
|
13
|
+
attr_accessor :log, :options
|
14
|
+
|
15
|
+
def initialize
|
16
|
+
@log = Logger.new(STDOUT)
|
17
|
+
@options = Hash.new
|
18
|
+
@plugin_settings_db = FSDB::Database.new("#{File.dirname(__FILE__)}/../../../store/plugin/")
|
19
|
+
init_options()
|
20
|
+
end
|
21
|
+
|
22
|
+
def set_option_value(key, val)
|
23
|
+
@options[key.to_sym][:value] = val
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_option(key)
|
27
|
+
@options[key.to_sym]
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_option_value(key)
|
31
|
+
if (@options[key.to_sym] != nil)
|
32
|
+
@options[key.to_sym][:value] #|| @plugin_settings_db[key.to_s]
|
33
|
+
else
|
34
|
+
nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def init_options
|
39
|
+
@plugin_settings_db.fetch.each do | key |
|
40
|
+
if (@options[key.to_sym])
|
41
|
+
@options[key.to_sym][:value] = @plugin_settings_db[key]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def save_options
|
47
|
+
@options.each do | key, value |
|
48
|
+
@plugin_settings_db[key.to_s] = value[:value].to_s
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def clear_options
|
53
|
+
@plugin_settings_db.fetch.each do | element |
|
54
|
+
@plugin_settings_db.delete(element)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
File without changes
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "fsdb"
|
2
|
+
require "#{File.dirname(__FILE__)}/../../registry"
|
3
|
+
|
4
|
+
##
|
5
|
+
#
|
6
|
+
# @author Johannes Hiemer.
|
7
|
+
#
|
8
|
+
##
|
9
|
+
module Cloudscale
|
10
|
+
module Preops
|
11
|
+
class Preop
|
12
|
+
attr_accessor :log, :registry
|
13
|
+
|
14
|
+
def init
|
15
|
+
@log = Logger.new(STDOUT)
|
16
|
+
@registry = Monitor::Registry.instance
|
17
|
+
end
|
18
|
+
|
19
|
+
def init_charts(path)
|
20
|
+
log.info("Starting monitoring chart synchronization...")
|
21
|
+
|
22
|
+
file = File.read(path);
|
23
|
+
plugin = YAML.load(JSON.parse(file).to_yaml)
|
24
|
+
plugin.each do | chart, value |
|
25
|
+
chart["agentInstanceId"] = agentInstanceId
|
26
|
+
|
27
|
+
chart["queries"].each { | query |
|
28
|
+
query["command"].sub! '[[agentInstanceId]]', agentInstanceId
|
29
|
+
}
|
30
|
+
|
31
|
+
test_chart = @client.searchOne("charts", "findByAgentInstanceIdAndChartId", { :agentInstanceId => agentInstanceId, :chartId => chart["chartId"]})
|
32
|
+
if (test_chart == nil)
|
33
|
+
client.post("charts", chart)
|
34
|
+
else
|
35
|
+
client.patch("charts", RestClientWrapper.load_entity_id(test_chart), chart)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Monitor::InitCharts.new(@registry.agent_instance_id, path)
|
40
|
+
|
41
|
+
log.info("Successfully synchronized charts...")
|
42
|
+
end
|
43
|
+
|
44
|
+
def init_menus(path)
|
45
|
+
log.info("Starting monitoring menu synchronization...")
|
46
|
+
|
47
|
+
file = File.read(path);
|
48
|
+
plugin = YAML.load(JSON.parse(file).to_yaml)
|
49
|
+
menuItem["agentInstanceId"] = agentInstanceId
|
50
|
+
test_menu = @client.searchOne("menus", "findByAgentInstanceIdAndMenuId", { :agentInstanceId => agentInstanceId, :menuId => menuItem["menuId"]})
|
51
|
+
if (test_menu == nil)
|
52
|
+
client.post("menus", menuItem)
|
53
|
+
else
|
54
|
+
client.patch("menus", RestClientWrapper.load_entity_id(test_menu), menuItem)
|
55
|
+
end
|
56
|
+
|
57
|
+
log.info("Successfully synchronized menus...")
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require "#{File.dirname(__FILE__)}/preops/mongodb_preop"
|
2
2
|
require "#{File.dirname(__FILE__)}/../plugin"
|
3
3
|
|
4
4
|
##
|
@@ -9,23 +9,22 @@ require "#{File.dirname(__FILE__)}/../plugin"
|
|
9
9
|
module Cloudscale
|
10
10
|
module Plugins
|
11
11
|
class MongoDbStatus < Plugins::Plugin
|
12
|
-
attr_reader
|
13
|
-
|
14
|
-
def log
|
15
|
-
@log = Logger.new(STDOUT)
|
16
|
-
end
|
12
|
+
attr_reader :db
|
17
13
|
|
18
14
|
def is_enabled
|
19
|
-
|
15
|
+
Preops::MongodbPreop.instance.is_enabled
|
20
16
|
end
|
21
17
|
|
22
18
|
def initialize
|
23
19
|
super
|
24
20
|
if is_enabled
|
21
|
+
@db = Preops::MongodbPreop.instance.db
|
25
22
|
end
|
26
23
|
end
|
27
24
|
|
28
25
|
def collect(agentInstanceId)
|
26
|
+
registry = Monitor::Registry.instance
|
27
|
+
metrics = Metrics::Agent.new
|
29
28
|
log.info("Calling Collect on MongoDbStatus")
|
30
29
|
stats = @db.stats
|
31
30
|
|
@@ -33,23 +32,29 @@ module Cloudscale
|
|
33
32
|
{ :value => stats['objects'] }
|
34
33
|
end
|
35
34
|
|
36
|
-
|
37
|
-
|
35
|
+
registry.metrics["mongo.status.indexes"] = metrics.gauge :status_indexes do
|
36
|
+
{ :value => stats['indexes'] }
|
37
|
+
end
|
38
38
|
|
39
|
-
|
40
|
-
|
39
|
+
registry.metrics["mongo.status.indexes"] = metrics.gauge :status_indexes do
|
40
|
+
{ :value => stats['indexes'] }
|
41
|
+
end
|
41
42
|
|
42
|
-
|
43
|
-
|
43
|
+
registry.metrics["mongo.status.dataSize"] = metrics.gauge :status_dataSize do
|
44
|
+
{ :value => stats['dataSize'] }
|
45
|
+
end
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
+
registry.metrics["mongo.status.storageSize"] = metrics.gauge :status_storageSize do
|
48
|
+
{ :value => stats['storageSize'] }
|
49
|
+
end
|
47
50
|
|
48
|
-
|
49
|
-
|
51
|
+
registry.metrics["mongo.status.collections"] = metrics.gauge :status_collections do
|
52
|
+
{ :value => stats['collections'] }
|
53
|
+
end
|
50
54
|
|
51
|
-
|
52
|
-
|
55
|
+
registry.metrics["mongo.status.avgObjSize"] = metrics.gauge :status_avgObjSize do
|
56
|
+
{ :value => stats['avgObjSize'] }
|
57
|
+
end
|
53
58
|
end
|
54
59
|
|
55
60
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require "#{File.dirname(__FILE__)}/preops/mongodb_preop"
|
2
2
|
require "#{File.dirname(__FILE__)}/../plugin"
|
3
3
|
|
4
4
|
##
|
@@ -9,95 +9,68 @@ require "#{File.dirname(__FILE__)}/../plugin"
|
|
9
9
|
module Cloudscale
|
10
10
|
module Plugins
|
11
11
|
class MongoReplicaStatus < Plugins::Plugin
|
12
|
-
|
13
|
-
|
14
|
-
def log
|
15
|
-
@log = Logger.new(STDOUT)
|
16
|
-
end
|
17
|
-
|
12
|
+
attr_reader :db
|
13
|
+
|
18
14
|
def is_enabled
|
19
|
-
|
15
|
+
Preops::MongodbPreop.instance.is_enabled
|
20
16
|
end
|
21
|
-
|
17
|
+
|
22
18
|
def initialize
|
23
19
|
super
|
24
20
|
if is_enabled
|
25
|
-
|
26
|
-
@menu_replicaClusterStatus = load_menu(menus["mongodb-server-stats"], "replicaClusterStatus")
|
27
|
-
|
28
|
-
@db = Plugins::PluginPreop.instance.db
|
29
|
-
components = Plugins::PluginComponents.load_hash()
|
30
|
-
@metric = load_metric(components["mongodb-replica-stats"], "replicaClusterStatus")
|
21
|
+
@db = Preops::MongodbPreop.instance.db
|
31
22
|
end
|
32
23
|
end
|
33
|
-
|
34
|
-
def collectHourly(
|
24
|
+
|
25
|
+
def collectHourly()
|
26
|
+
registry = Monitor::Registry.instance
|
27
|
+
metrics = Metrics::Agent.new
|
35
28
|
log.info("Calling Collect on MongoReplicaStatus")
|
36
29
|
replset_status = db.command({'replSetGetStatus' => 1}, :check_response => false)
|
37
|
-
|
30
|
+
|
38
31
|
unless replset_status['ok'] == 1
|
39
32
|
return "Node isn't a member of a Replica Set","Unable to fetch Replica Set status information."
|
40
33
|
end
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
primary = replset_status['members'].detect { | member | member['state'] == 1 }
|
47
|
-
if primary
|
48
|
-
member = replset_status['members'].detect do | member |
|
49
|
-
member['self']
|
34
|
+
|
35
|
+
replset_status['members'].detect do | member |
|
36
|
+
registry.metrics["mongo.replicastate.member." + name + ".errmsg"] = metrics.gauge :errmsg do
|
37
|
+
{ :value => member["errmsg"] }
|
50
38
|
end
|
51
|
-
|
52
|
-
|
53
|
-
|
39
|
+
|
40
|
+
registry.metrics["mongo.replicastate.member." + name + ".health"] = metrics.gauge :health do
|
41
|
+
{ :value => member["health"] }
|
54
42
|
end
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
"Last Heartbeat Message", "Ping Ms"]
|
63
|
-
memberBody = Array.new
|
64
|
-
replset_status['members'].detect do | member |
|
65
|
-
memberBody.push(member["name"], member["errmsg"], member["health"], member["stateStr"], member["uptime"],
|
66
|
-
member["optimeDate"], member["lastHeartbeat"], member["lastHeartbeatRecv"], member["lastHeartbeatMessage"],
|
67
|
-
member["pingMs"])
|
68
|
-
end
|
69
|
-
member_server_table = Monitor::Table.new("replicaClusterStatus", "Replica Status Information", nil, memberBody, "compact")
|
70
|
-
member_server_table.caption = "Replica Status Information for a MongoDB Cluster"
|
71
|
-
persist_table(member_server_table, agentInstanceId, menu_replicaClusterStatus)
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
def get_replica_state(state)
|
76
|
-
member_state = case state
|
77
|
-
when 0
|
78
|
-
'Starting Up'
|
79
|
-
when 1
|
80
|
-
'Primary'
|
81
|
-
when 2
|
82
|
-
'Secondary'
|
83
|
-
when 3
|
84
|
-
'Recovering'
|
85
|
-
when 4
|
86
|
-
'Fatal'
|
87
|
-
when 5
|
88
|
-
'Starting up (forking threads)'
|
89
|
-
when 6
|
90
|
-
'Unknown'
|
91
|
-
when 7
|
92
|
-
'Arbiter'
|
93
|
-
when 8
|
94
|
-
'Down'
|
95
|
-
when 9
|
96
|
-
'Rollback'
|
43
|
+
|
44
|
+
registry.metrics["mongo.replicastate.member." + name + ".stateStr"] = metrics.gauge :stateStr do
|
45
|
+
{ :value => member["stateStr"] }
|
46
|
+
end
|
47
|
+
|
48
|
+
registry.metrics["mongo.replicastate.member." + name + ".uptime"] = metrics.gauge :uptime do
|
49
|
+
{ :value => member["uptime"] }
|
97
50
|
end
|
98
|
-
|
51
|
+
|
52
|
+
registry.metrics["mongo.replicastate.member." + name + ".optimeDate"] = metrics.gauge :optimeDate do
|
53
|
+
{ :value => member["optimeDate"] }
|
54
|
+
end
|
55
|
+
|
56
|
+
registry.metrics["mongo.replicastate.member." + name + ".lastHeartbeat"] = metrics.gauge :lastHeartbeat do
|
57
|
+
{ :value => member["lastHeartbeat"] }
|
58
|
+
end
|
59
|
+
|
60
|
+
registry.metrics["mongo.replicastate.member." + name + ".lastHeartbeatRecv"] = metrics.gauge :lastHeartbeatRecv do
|
61
|
+
{ :value => member["lastHeartbeatRecv"] }
|
62
|
+
end
|
63
|
+
|
64
|
+
registry.metrics["mongo.replicastate.member." + name + ".lastHeartbeatMessage"] = metrics.gauge :lastHeartbeatMessage do
|
65
|
+
{ :value => member["lastHeartbeatMessage"] }
|
66
|
+
end
|
67
|
+
|
68
|
+
registry.metrics["mongo.replicastate.member." + name + ".pingMs"] = metrics.gauge :pingMs do
|
69
|
+
{ :value => member["pingMs"] }
|
70
|
+
end
|
71
|
+
end
|
99
72
|
end
|
100
|
-
|
73
|
+
|
101
74
|
end
|
102
75
|
end
|
103
|
-
end
|
76
|
+
end
|