-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongos-plugin.xml
276 lines (242 loc) · 9.6 KB
/
mongos-plugin.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2011 Clarity Services, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Document : mongos-plugin.xml
Author : Reid Morrison
Home Page : https://github.com/ClarityServices/hyperic-mongos
Version : 1.0
Description:
Hyperic HQ Plug-in to monitor MongoDB Router Servers
-->
<!DOCTYPE plugin [
<!ENTITY process-metrics SYSTEM "/pdk/plugins/process-metrics.xml">
]>
<plugin>
<!-- Invoke mongo shell and extract serverStatus -->
<script name="hq-mongos-stat">
<![CDATA[
#!/bin/bash
# Parameters: %hostname% %port% %username% %password%
# username and password are optional, but must be supplied if the
# mongo server has been secured
JAVA_SCRIPT=$(cat <<EOF
// Print BSON as name value pairs
function flattenBson(hash, prefix) {
for(key in hash) {
value = hash[key];
klass = Object.prototype.toString.call(value).slice(8, -1);
if(klass == "bson_object") {
flattenBson(value, prefix+"_"+key)
} else {
print(prefix+"_"+key+"="+value)
};
}
};
// Authenticate first if username was supplied
if (("$3" != "") && ("$3" != "%username%")) {
if (db.auth("$3", "$4") != 1) {
print("Failed to authenticate. Bad Credentials");
exit(-1);
}
}
status = db.serverStatus();
flattenBson(status, "serverStatus");
EOF
)
mongo --host $1 --port $2 --quiet admin --eval "$JAVA_SCRIPT"
]]>
</script>
<property name="SERVER_STATUS" value="exec:timeout=10,file=pdk/work/scripts/mongos/hq-mongos-stat,args=%hostname% %port% %username% %password%,exec=%exec%"/>
<filter name="template" value="${SERVER_STATUS}:${alias}"/>
<metrics name="MongoDB Utilization">
<metric name="Connections"
alias="serverStatus_connections_current"
category="UTILIZATION"
interval="300000"
indicator="true"/>
<metric name="Connections Available"
alias="serverStatus_connections_available"
interval="600000"
category="UTILIZATION"/>
<metric name="Uptime"
alias="serverStatus_uptime"
category="UTILIZATION"
interval="600000"
units="sec"/>
<!-- This metric is platform specific -->
<metric name="Page faults"
alias="serverStatus_extra_info_page_faults"
category="UTILIZATION"
collectionType="trendsup"
interval="300000"/>
</metrics>
<metrics name="MongoDB Network">
<metric name="Network In"
alias="serverStatus_network_bytesIn"
category="UTILIZATION"
indicator="true"
collectionType="trendsup"
interval="300000"
units="B"/>
<metric name="Network Out"
alias="serverStatus_network_bytesOut"
category="UTILIZATION"
indicator="true"
collectionType="trendsup"
interval="300000"
units="B"/>
<metric name="Network Requests"
alias="serverStatus_network_numRequests"
collectionType="trendsup"
interval="300000"
category="UTILIZATION"/>
</metrics>
<metrics name="MongoDB Memory">
<metric name="Virtual Memory Size"
alias="serverStatus_mem_virtual"
category="UTILIZATION"
indicator="true"
interval="300000"
units="MB"/>
<metric name="Resident Memory Size"
alias="serverStatus_mem_resident"
category="UTILIZATION"
indicator="true"
interval="300000"
units="MB"/>
</metrics>
<metrics name="MongoDB IO">
<!-- Operations -->
<metric name="Inserts"
alias="serverStatus_opcounters_insert"
category="THROUGHPUT"
collectionType="trendsup"
interval="300000"
indicator="true"/>
<metric name="Queries"
alias="serverStatus_opcounters_query"
category="THROUGHPUT"
collectionType="trendsup"
interval="300000"
indicator="true"/>
<metric name="Updates"
alias="serverStatus_opcounters_update"
category="THROUGHPUT"
collectionType="trendsup"
interval="300000"
indicator="true"/>
<metric name="Deletes"
alias="serverStatus_opcounters_delete"
category="THROUGHPUT"
collectionType="trendsup"
interval="300000"
indicator="true"/>
<metric name="Getmores"
alias="serverStatus_opcounters_getmore"
category="THROUGHPUT"
collectionType="trendsup"
interval="300000"
indicator="true"/>
<metric name="Commands"
alias="serverStatus_opcounters_command"
category="THROUGHPUT"
collectionType="trendsup"
interval="300000"
indicator="true"/>
</metrics>
<metrics name="MongoDB Asserts">
<metric name="Asserts Regular"
alias="serverStatus_asserts_regular"
category="UTILIZATION"
interval="600000"
collectionType="trendsup"/>
<metric name="Asserts Warning"
alias="serverStatus_asserts_warning"
category="UTILIZATION"
interval="600000"
collectionType="trendsup"/>
<metric name="Asserts Msg"
alias="serverStatus_asserts_msg"
category="UTILIZATION"
interval="600000"
collectionType="trendsup"/>
<metric name="Asserts User"
alias="serverStatus_asserts_user"
category="UTILIZATION"
interval="600000"
collectionType="trendsup"/>
<metric name="Asserts Rollovers"
alias="serverStatus_asserts_rollovers"
category="UTILIZATION"
interval="600000"
collectionType="trendsup"/>
</metrics>
<metrics name="MongoDB Process Metrics">
<metric name="Process Cpu Usage"
template="sigar:Type=ProcCpu,Arg=%process.query%:Percent"
indicator="true"
interval="300000"
units="percentage"/>
</metrics>
<server name="MongoDB Router" version="2.x">
<property name="PROC_QUERY" value="State.Name.eq=mongos,Args.*.eq=/etc/mongos.conf"/>
<property name="DEFAULT_CONFIG_FILE" value="/etc/mongos.conf"/>
<property name="DEFAULT_LOG_FILE" value="/var/log/mongo/mongos.log"/>
<property name="DEFAULT_PID_FILE" value="/var/run/mongo/mongos.pid"/>
<config>
<option name="process.query"
description="PTQL for mongos process"
default="${PROC_QUERY}"/>
<option name="hostname"
description="Usually leave as localhost"
default="localhost"/>
<option name="port"
description="mongos port number"
type="int"
default="27017"/>
<option name="username"
description="User name [Only if MongoDB Authorization has been enabled]"
optional="true"
default=""/>
<option name="password"
description="Password [Only if MongoDB Authorization has been enabled]"
type="secret"
optional="true"
default=""/>
</config>
<!--notifies the plugin to auto-discover one instance of each service-->
<property name="HAS_BUILTIN_SERVICES" value="true"/>
<plugin type="autoinventory"
class="org.hyperic.hq.product.DaemonDetector"/>
<plugin type="measurement"
class="org.hyperic.hq.product.MeasurementPlugin"/>
<plugin type="config_track"
class="org.hyperic.hq.product.ConfigFileTrackPlugin"/>
<plugin type="log_track"
class="org.hyperic.hq.product.LogFileTailPlugin"/>
<metric name="Availability"
template="sigar:Type=ProcState,Arg=%process.query%:State"
category="AVAILABILITY"
indicator="true"/>
<metrics include="MongoDB Utilization"/>
<metrics include="MongoDB Process Metrics"/>
<metrics include="MongoDB Network"/>
<metrics include="MongoDB Memory"/>
<metrics include="MongoDB IO"/>
<metrics include="MongoDB Asserts"/>
</server>
<help name="MongoDB Router">
Configure Hyperic for monitoring MongoDB Routing servers.
The port for mongos is by default 27017, please change the port above if required.
For servers that have more than one MongoDB instance, update the port.
</help>
</plugin>