Class: Cloudscale::Plugins::MongoServerStatus

Inherits:
Plugin
  • Object
show all
Defined in:
lib/cloudscale/plugins/mongo/mongo_server_status.rb

Instance Attribute Summary collapse

Attributes inherited from Plugin

#plugins, #rest_client

Instance Method Summary collapse

Methods inherited from Plugin

inherited, plugins, remove, remove_agenInstance, reset, resetRestEndpoint

Constructor Details

#initializeMongoServerStatus

Returns a new instance of MongoServerStatus.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 27

def initialize
  super
  if is_enabled
    menus = Plugins::PluginMenus.load_hash()
    @menu_generalInformation = load_menu(menus["mongodb-server-stats"], "generalInformation")
    @menu_idxCounter = load_menu(menus["mongodb-server-stats"], "indexCounters")
    @menu_globalLock = load_menu(menus["mongodb-server-stats"], "globalLock")
    @menu_opCounter = load_menu(menus["mongodb-server-stats"], "opCounters")
    @menu_memory = load_menu(menus["mongodb-server-stats"], "memory")
    @menu_network = load_menu(menus["mongodb-server-stats"], "network")
    
    @db = Plugins::PluginPreop.instance.db
    components = Plugins::PluginComponents.load_hash()
    @indexCountersBtreeHits = load_metric(components["mongodb-server-stats"], "indexCountersBtreeHits")        
    @indexCountersBtreeAccesses = load_metric(components["mongodb-server-stats"], "indexCountersBtreeAccesses")
    @indexCountersBtreeMisses = load_metric(components["mongodb-server-stats"], "indexCountersBtreeMisses")
    
    @globalLockLockTime = load_metric(components["mongodb-server-stats"], "globalLockLockTime")
    @globalLockTotalTime = load_metric(components["mongodb-server-stats"], "globalLockTotalTime")
    
    @opcountersInsert = load_metric(components["mongodb-server-stats"], "opcountersInsert")
    @opcountersQuery = load_metric(components["mongodb-server-stats"], "opcountersQuery")
    @opcountersUpdate = load_metric(components["mongodb-server-stats"], "opcountersUpdate")
    @opcountersDelete = load_metric(components["mongodb-server-stats"], "opcountersDelete")
    @opcountersGetMore = load_metric(components["mongodb-server-stats"], "opcountersGetMore")
    
    @generalInformation = load_metric(components["mongodb-server-stats"], "generalInformation")
    
    @memBits = load_metric(components["mongodb-server-stats"], "memBits")
    @memResident = load_metric(components["mongodb-server-stats"], "memResident")
    @memVirtual = load_metric(components["mongodb-server-stats"], "memVirtual")
    @memMapped = load_metric(components["mongodb-server-stats"], "memMapped")
    @memMappedWithJournal = load_metric(components["mongodb-server-stats"], "memMappedWithJournal")
    
    @networkBytesIn = load_metric(components["mongodb-server-stats"], "networkBytesIn")
    @networkBytesOut = load_metric(components["mongodb-server-stats"], "networkBytesOut")
    @networkNumOfRequests = load_metric(components["mongodb-server-stats"], "networkNumOfRequests")
  end
end

Instance Attribute Details

#dbObject

Returns the value of attribute db.



13
14
15
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 13

def db
  @db
end

#generalInformationObject (readonly)

Returns the value of attribute generalInformation.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def generalInformation
  @generalInformation
end

#globalLockLockTimeObject (readonly)

Returns the value of attribute globalLockLockTime.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def globalLockLockTime
  @globalLockLockTime
end

#globalLockTotalTimeObject (readonly)

Returns the value of attribute globalLockTotalTime.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def globalLockTotalTime
  @globalLockTotalTime
end

#indexCountersBtreeAccessesObject (readonly)

Returns the value of attribute indexCountersBtreeAccesses.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def indexCountersBtreeAccesses
  @indexCountersBtreeAccesses
end

#indexCountersBtreeHitsObject (readonly)

Returns the value of attribute indexCountersBtreeHits.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def indexCountersBtreeHits
  @indexCountersBtreeHits
end

#indexCountersBtreeMissesObject (readonly)

Returns the value of attribute indexCountersBtreeMisses.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def indexCountersBtreeMisses
  @indexCountersBtreeMisses
end

#memBitsObject (readonly)

Returns the value of attribute memBits.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def memBits
  @memBits
end

#memMappedObject (readonly)

Returns the value of attribute memMapped.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def memMapped
  @memMapped
end

#memMappedWithJournalObject (readonly)

Returns the value of attribute memMappedWithJournal.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def memMappedWithJournal
  @memMappedWithJournal
end

#memResidentObject (readonly)

Returns the value of attribute memResident.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def memResident
  @memResident
end

#memVirtualObject (readonly)

Returns the value of attribute memVirtual.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def memVirtual
  @memVirtual
end

Returns the value of attribute menu_generalInformation.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def menu_generalInformation
  @menu_generalInformation
end

Returns the value of attribute menu_globalLock.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def menu_globalLock
  @menu_globalLock
end

Returns the value of attribute menu_idxCounter.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def menu_idxCounter
  @menu_idxCounter
end

Returns the value of attribute menu_memory.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def menu_memory
  @menu_memory
end

Returns the value of attribute menu_network.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def menu_network
  @menu_network
end

Returns the value of attribute menu_opCounter.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def menu_opCounter
  @menu_opCounter
end

#networkBytesInObject (readonly)

Returns the value of attribute networkBytesIn.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def networkBytesIn
  @networkBytesIn
end

#networkBytesOutObject (readonly)

Returns the value of attribute networkBytesOut.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def networkBytesOut
  @networkBytesOut
end

#networkNumOfRequestsObject (readonly)

Returns the value of attribute networkNumOfRequests.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def networkNumOfRequests
  @networkNumOfRequests
end

#opcountersDeleteObject (readonly)

Returns the value of attribute opcountersDelete.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def opcountersDelete
  @opcountersDelete
end

#opcountersGetMoreObject (readonly)

Returns the value of attribute opcountersGetMore.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def opcountersGetMore
  @opcountersGetMore
end

#opcountersInsertObject (readonly)

Returns the value of attribute opcountersInsert.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def opcountersInsert
  @opcountersInsert
end

#opcountersQueryObject (readonly)

Returns the value of attribute opcountersQuery.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def opcountersQuery
  @opcountersQuery
end

#opcountersUpdateObject (readonly)

Returns the value of attribute opcountersUpdate.



14
15
16
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 14

def opcountersUpdate
  @opcountersUpdate
end

Instance Method Details

#collect(agentInstanceId) ⇒ Object



67
68
69
70
71
72
73
74
75
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 67

def collect(agentInstanceId)
  log.info("Calling Collect on MongoServerStatus")
  report_index_counters(agentInstanceId)
  report_global_lock_times(agentInstanceId)
  report_op_counters(agentInstanceId)
  report_general_information(agentInstanceId)
  report_memory(agentInstanceId)
  report_network(agentInstanceId)
end

#is_enabledObject



23
24
25
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 23

def is_enabled
  false
end

#logObject



19
20
21
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 19

def log
  @log = Logger.new(STDOUT)
end

#report_general_information(agentInstanceId) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 109

def report_general_information(agentInstanceId)
  stats = @db.command('serverStatus' => 1)
  
  body = Array.new
  body.push(["Host", stats['host']])
  body.push(["Version", stats['version']])
  body.push(["Uptime", stats['uptime']])
  body.push(["Local time", stats['localTime']])
  body.push(["Connections currently", stats['connections']['current']])
  body.push(["Connections available", stats['connections']['available']])
  mongo_general_inf_table = Monitor::Table.new("generalInformationMonGo", "MongoDB General Information", nil, body, "compact")
  mongo_general_inf_table.caption = "General Information regarding your MongoDB Instance"
  
  persist_table(mongo_general_inf_table, agentInstanceId, menu_generalInformation)
end

#report_global_lock_times(agentInstanceId) ⇒ Object



159
160
161
162
163
164
165
166
167
168
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 159

def report_global_lock_times(agentInstanceId)
  stats = @db.command('serverStatus' => 1)
  if stats['globalLock']
    report(globalLockLockTime, menu_globalLock, stats['globalLock']['lockTime'], false, agentInstanceId, "globalLockLockTimeChart",
    "Globallock Lock Time", "The global lock time across collections in the database" , "area", "Time", "", "s",  nil)
  
    report(globalLockTotalTime, menu_globalLock, stats['globalLock']['totalTime'], false, agentInstanceId, "globalLockTotalTimeChart",
    "Number of btree hits", "The global lock time in total across collections in the database" , "area", "Time", "", "s", nil)
  end
end

#report_index_counters(agentInstanceId) ⇒ Object



144
145
146
147
148
149
150
151
152
153
154
155
156
157
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 144

def report_index_counters(agentInstanceId)
  stats = @db.command('serverStatus' => 1)
  
  if (stats["indexCounters"] and stats["indexCounters"]["btree"])
    report(indexCountersBtreeAccesses, menu_idxCounter, stats['indexCounters']['btree']['accesses'], true, agentInstanceId, "btreeAccessesChart",
    "Number of btree accesses", "Number of btree accesses across all collections in the database" , "area", "Time", "Count", "c", "s")
  
    report(indexCountersBtreeMisses, menu_idxCounter, stats['indexCounters']['btree']['misses'], true, agentInstanceId, "btreeMissesChart",
    "Number of btree misses", "Number of btree misses across all collections in the database" , "area", "Time", "Count", "c", "s")
  
    report(indexCountersBtreeHits, menu_idxCounter, stats['indexCounters']['btree']['hits'], true, agentInstanceId, "btreeHitsChart",
    "Number of btree hits", "Number of btree hits across all collections in the database" , "area", "Time", "Count", "c", "s")
  end
end

#report_memory(agentInstanceId) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 77

def report_memory(agentInstanceId)
  stats = @db.command('serverStatus' => 1)
  report(memBits, menu_memory, stats['mem']['bits'], false, agentInstanceId, "memBitsChart",
  "Memory bits", "Memory bits across collections in the database", "area", "Time", "Count", "c",  nil)
  
  report(memResident, menu_memory, stats['mem']['resident'], false, agentInstanceId, "memResidentChart",
  "Memory resident", "Memory resident across collections in the database", "area", "Time", "Count", "c",  nil)
  
  report(memVirtual, menu_memory, stats['mem']['virtual'], false, agentInstanceId, "memVirtualChart",
  "Memory virtual", "Memory virtual across collections in the database", "area", "Time", "Count", "c",  nil)
  
  report(memMapped, menu_memory, stats['mem']['mapped'], false, agentInstanceId, "memMappedChart",
  "Memory mapped", "Memory mapped across collections in the database", "area", "Time", "Count", "c",  nil)
  
  report(memMappedWithJournal, menu_memory, stats['mem']['mappedWithJournal'], false, agentInstanceId, "memMappedWithJournalChart",
  "Memory mapped with Journal", "Memory mapped with Journal across collections in the database", "area", "Time", "Count", "c",  nil)
  
end

#report_network(agentInstanceId) ⇒ Object



96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 96

def report_network(agentInstanceId)
  stats = @db.command('serverStatus' => 1)
  
  report(networkBytesIn, menu_network, stats['network']['bytesIn'], true, agentInstanceId, "networkBytesInChart",
  "Network Bytes in", "Network Bytes in", "area", "Time", "Count", "B",  "s")
  
  report(networkBytesOut, menu_network, stats['network']['bytesOut'], true, agentInstanceId, "networkBytesOutChart",
  "Network Bytes out", "Network Bytes out", "area", "Time", "Count", "B",  "s")
  
  report(networkNumOfRequests, menu_network, stats['network']['numRequests'], true, agentInstanceId, "networkNumOfRequests",
  "Number of Requests", "Number of Requests", "area", "Time", "Count", "c",  "s")
end

#report_op_counters(agentInstanceId) ⇒ Object



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/cloudscale/plugins/mongo/mongo_server_status.rb', line 125

def report_op_counters(agentInstanceId)
  stats = @db.command('serverStatus' => 1)
  report(opcountersInsert, menu_opCounter, stats['opcounters']['insert'], true, agentInstanceId, "opcountersInsertChart",
  "Operation Counter Inserts", "Operation Counter Inserts across collections in the database", "area", "Time", "Count", "c",  "s")
  
  report(opcountersQuery, menu_opCounter, stats['opcounters']['query'], true, agentInstanceId, "opcountersQueryChart",
  "Operation Counter Query", "Operation Counter Query across collections in the database", "area", "Time", "Count", "c",  "s")
  
  report(opcountersUpdate, menu_opCounter, stats['opcounters']['update'], true, agentInstanceId, "opcountersUpdateChart",
  "Operation Counter Update", "Operation Counter Update across collections in the database", "area", "Time", "Count", "c",  "s")
  
  report(opcountersDelete, menu_opCounter, stats['opcounters']['delete'], true, agentInstanceId, "opcountersDeleteChart",
  "Operation Counter Delete", "Operation Counter Delete across collections in the database", "area", "Time", "Count", "c",  "s")
  
  report(opcountersGetMore, menu_opCounter, stats['opcounters']['getmore'], true, agentInstanceId, "opcountersGetMoreChart",
  "Operation Counter Get More", "Operation Counter Get More across collections in the database", "area", "Time", "Count", "c",  "s")
  
end