Skip to content
This repository
Browse code

simplify blueeyes_service module to create less but more meaningful g…

…raphs, update mongodb module documentation
  • Loading branch information...
commit 042c31ba45733a0541afdd9d9d6c2c3a376b2678 1 parent 092b696
authored May 03, 2011
6  blueeyes_service/README.mkdn
Source Rendered
@@ -7,11 +7,7 @@ This module parses health statistics from a BlueEyes service and creates
7 7
 "blueeyes_*" metrics:
8 8
 
9 9
  * DELETE/GET/POST/PUT requests per second
10  
- * DELETE/GET/POST/PUT error count
11  
- * DELETE/GET/POST/PUT minimum time
12  
- * DELETE/GET/POST/PUT maximum time
13  
- * DELETE/GET/POST/PUT average time
14  
- * DELETE/GET/POST/PUT time standard deviation
  10
+ * DELETE/GET/POST/PUT errors per second
15 11
 
16 12
 ## AUTHOR
17 13
 
51  blueeyes_service/conf.d/blueeyes_service.conf
@@ -19,54 +19,11 @@ collection_group {
19 19
     time_threshold = 90
20 20
 
21 21
     metric {
22  
-        name = "blueeyes_service_example_v1_requests_DELETE_count"
23  
-        title = "DELETE Requests"
  22
+        name = "blueeyes_service_example_v1_requests"
  23
+        title = "Requests per Second"
24 24
     }
25 25
     metric {
26  
-        name = "blueeyes_service_example_v1_requests_DELETE_timing_averageTime"
27  
-        title = "DELETE Request Average Time"
28  
-    }
29  
-    metric {
30  
-        name = "blueeyes_service_example_v1_requests_DELETE_errors_errorCount"
31  
-        title = "DELETE Errors"
32  
-    }
33  
-
34  
-    metric {
35  
-        name = "blueeyes_service_example_v1_requests_GET_count"
36  
-        title = "GET Requests"
37  
-    }
38  
-    metric {
39  
-        name = "blueeyes_service_example_v1_requests_GET_timing_averageTime"
40  
-        title = "GET Request Average Time"
41  
-    }
42  
-    metric {
43  
-        name = "blueeyes_service_example_v1_requests_GET_errors_errorCount"
44  
-        title = "GET Errors"
45  
-    }
46  
-
47  
-    metric {
48  
-        name = "blueeyes_service_example_v1_requests_POST_count"
49  
-        title = "POST Requests"
50  
-    }
51  
-    metric {
52  
-        name = "blueeyes_service_example_v1_requests_POST_timing_averageTime"
53  
-        title = "POST Request Average Time"
54  
-    }
55  
-    metric {
56  
-        name = "blueeyes_service_example_v1_requests_POST_errors_errorCount"
57  
-        title = "POST Errors"
58  
-    }
59  
-
60  
-    metric {
61  
-        name = "blueeyes_service_example_v1_requests_PUT_count"
62  
-        title = "PUT Requests"
63  
-    }
64  
-    metric {
65  
-        name = "blueeyes_service_example_v1_requests_PUT_timing_averageTime"
66  
-        title = "PUT Request Average Time"
67  
-    }
68  
-    metric {
69  
-        name = "blueeyes_service_example_v1_requests_PUT_errors_errorCount"
70  
-        title = "PUT Errors"
  26
+        name = "blueeyes_service_example_v1_errors"
  27
+        title = "Errors per Second"
71 28
     }
72 29
 }
137  blueeyes_service/python_modules/blueeyes_service.py
... ...
@@ -1,22 +1,30 @@
1 1
 #!/usr/bin/env python
2  
-################################################################################
  2
+# -*- coding: utf-8 -*-
  3
+#
3 4
 # BlueEyes gmond module for Ganglia
4  
-# Copyright (c) 2011 Michael T. Conigliaro <mike [at] conigliaro [dot] org>
5 5
 #
6  
-# This program is free software; you can redistribute it and/or modify
7  
-# it under the terms of the GNU General Public License as published by
8  
-# the Free Software Foundation; either version 2 of the License, or
9  
-# (at your option) any later version.
  6
+# Copyright (C) 2011 by Michael T. Conigliaro <mike [at] conigliaro [dot] org>.
  7
+# All rights reserved.
  8
+#
  9
+# Permission is hereby granted, free of charge, to any person obtaining a copy
  10
+# of this software and associated documentation files (the "Software"), to deal
  11
+# in the Software without restriction, including without limitation the rights
  12
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13
+# copies of the Software, and to permit persons to whom the Software is
  14
+# furnished to do so, subject to the following conditions:
  15
+#
  16
+# The above copyright notice and this permission notice shall be included in
  17
+# all copies or substantial portions of the Software.
10 18
 #
11  
-# This program is distributed in the hope that it will be useful,
12  
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
13  
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  
-# GNU General Public License for more details.
  19
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25
+# THE SOFTWARE.
15 26
 #
16  
-# You should have received a copy of the GNU General Public License
17  
-# along with this program; if not, write to the Free Software
18  
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  
-################################################################################
  27
+
20 28
 
21 29
 import json
22 30
 import os
@@ -25,17 +33,18 @@
25 33
 
26 34
 
27 35
 PARAMS = {
28  
-    'service_name'    : 'example',
29  
-    'service_version' : 'v1',
30  
-    'stats_command'   : 'curl --silent http://appserver01.example.com:30060/blueeyes/services/example/v1/health'
  36
+    'service_name'    : 'stats',
  37
+    'service_version' : 'v1'
31 38
 }
  39
+PARAMS['stats_command'] = 'curl --silent http://appserver11.example.com:30040/blueeyes/services/%s/%s/health' % \
  40
+                          (PARAMS['service_name'], PARAMS['service_version'])
32 41
 NAME_PREFIX = 'blueeyes_service_%s_%s_' % (PARAMS['service_name'], PARAMS['service_version'])
33 42
 METRICS = {
34 43
     'time' : 0,
35 44
     'data' : {}
36 45
 }
37 46
 LAST_METRICS = dict(METRICS)
38  
-METRICS_CACHE_MAX = 1
  47
+METRICS_CACHE_TTL = 1
39 48
 
40 49
 
41 50
 def flatten(obj, pre = '', sep = '_'):
@@ -59,7 +68,7 @@ def get_metrics():
59 68
 
60 69
     global METRICS, LAST_METRICS
61 70
 
62  
-    if (time.time() - METRICS['time']) > METRICS_CACHE_MAX:
  71
+    if (time.time() - METRICS['time']) > METRICS_CACHE_TTL:
63 72
 
64 73
         # get raw metric data
65 74
         io = os.popen(PARAMS['stats_command'])
@@ -98,13 +107,7 @@ def get_value(name):
98 107
     return result
99 108
 
100 109
 
101  
-def get_time_value(name):
102  
-    """BlueEyes returns time values in ns, so convert to seconds"""
103  
-
104  
-    return get_value(name)/1000000
105  
-
106  
-
107  
-def get_delta(name):
  110
+def get_rate(name):
108 111
     """Return change over time for the requested metric"""
109 112
 
110 113
     # get metrics
@@ -122,6 +125,20 @@ def get_delta(name):
122 125
     return delta
123 126
 
124 127
 
  128
+def get_requests(name):
  129
+    """Return requests per second"""
  130
+
  131
+    return reduce(lambda memo,obj: memo + get_rate('%srequests_%s_count' % (NAME_PREFIX, obj)),
  132
+                 ['DELETE', 'GET', 'POST', 'PUT'], 0)
  133
+
  134
+
  135
+def get_errors(name):
  136
+    """Return errors per second"""
  137
+
  138
+    return reduce(lambda memo,obj: memo + get_rate('%srequests_%s_errors_errorCount' % (NAME_PREFIX, obj)),
  139
+                 ['DELETE', 'GET', 'POST', 'PUT'], 0)
  140
+
  141
+
125 142
 def metric_init(lparams):
126 143
     """Initialize metric descriptors"""
127 144
 
@@ -135,74 +152,30 @@ def metric_init(lparams):
135 152
     # define descriptors
136 153
     time_max = 60
137 154
     groups = 'blueeyes service %s %s' % (PARAMS['service_name'], PARAMS['service_version'])
138  
-    descriptors = []
139  
-    for request in ['DELETE', 'GET', 'POST', 'PUT']:
140  
-        descriptors.extend([{
141  
-            'name': NAME_PREFIX + 'requests_' + request + '_count',
142  
-            'call_back': get_delta,
143  
-            'time_max': time_max,
144  
-            'value_type': 'float',
145  
-            'units': 'Ops/Sec',
146  
-            'slope': 'both',
147  
-            'format': '%f',
148  
-            'description': '%s Requests' % request,
149  
-            'groups': groups
150  
-        },
  155
+    descriptors = [
151 156
         {
152  
-            'name': NAME_PREFIX + 'requests_' + request + '_errors_errorCount',
153  
-            'call_back': get_value,
154  
-            'time_max': time_max,
155  
-            'value_type': 'int',
156  
-            'units': 'Errors',
157  
-            'slope': 'both',
158  
-            'format': '%d',
159  
-            'description': '%s Errors' % request,
160  
-            'groups': groups
161  
-        },
162  
-        {
163  
-            'name': NAME_PREFIX + 'requests_' + request + '_timing_minimumTime',
164  
-            'call_back': get_time_value,
  157
+            'name': NAME_PREFIX + 'requests',
  158
+            'call_back': get_requests,
165 159
             'time_max': time_max,
166 160
             'value_type': 'float',
167  
-            'units': 'Seconds',
  161
+            'units': 'Requests/Sec',
168 162
             'slope': 'both',
169 163
             'format': '%f',
170  
-            'description': '%s Request Minimum Time' % request,
  164
+            'description': 'Requests',
171 165
             'groups': groups
172 166
         },
173 167
         {
174  
-            'name': NAME_PREFIX + 'requests_' + request + '_timing_maximumTime',
175  
-            'call_back': get_time_value,
  168
+            'name': NAME_PREFIX + 'errors',
  169
+            'call_back': get_errors,
176 170
             'time_max': time_max,
177 171
             'value_type': 'float',
178  
-            'units': 'Seconds',
  172
+            'units': 'Errors/Sec',
179 173
             'slope': 'both',
180 174
             'format': '%f',
181  
-            'description': '%s Request Maximum Time' % request,
  175
+            'description': 'Errors',
182 176
             'groups': groups
183  
-        },
184  
-        {
185  
-            'name': NAME_PREFIX + 'requests_' + request + '_timing_averageTime',
186  
-            'call_back': get_time_value,
187  
-            'time_max': time_max,
188  
-            'value_type': 'float',
189  
-            'units': 'Seconds',
190  
-            'slope': 'both',
191  
-            'format': '%f',
192  
-            'description': '%s Request Average Time' % request,
193  
-            'groups': groups
194  
-        },
195  
-        {
196  
-            'name': NAME_PREFIX + 'requests_' + request + '_timing_standardDeviation',
197  
-            'call_back': get_time_value,
198  
-            'time_max': time_max,
199  
-            'value_type': 'float',
200  
-            'units': 'Seconds',
201  
-            'slope': 'both',
202  
-            'format': '%f',
203  
-            'description': '%s Request Standard Deviation' % request,
204  
-            'groups': groups
205  
-        }])
  177
+        }
  178
+    ]
206 179
 
207 180
     return descriptors
208 181
 
@@ -220,4 +193,4 @@ def metric_cleanup():
220 193
         for d in descriptors:
221 194
             print (('%s = %s') % (d['name'], d['format'])) % (d['call_back'](d['name']))
222 195
         print ''
223  
-        time.sleep(1)
  196
+        time.sleep(METRICS_CACHE_TTL)
20  mongodb/README.mkdn
Source Rendered
@@ -6,25 +6,29 @@ Python module for ganglia 3.1.
6 6
 This module parses output from the db.serverStatus() and rs.status() commands
7 7
 and creates "mongodb_*" metrics:
8 8
 
9  
- * Inserts per second
10  
- * Queries per second
11  
- * Updates per second
12  
- * Deletes per second
13  
- * Getmores per second
14  
- * Commands per second
15  
- * Flushes per second
  9
+ * Inserts per Second
  10
+ * Queries per Second
  11
+ * Updates per Second
  12
+ * Deletes per Second
  13
+ * Getmores per Second
  14
+ * Commands per Second
  15
+ * Flushes per Second
16 16
  * Memory-mapped Data
17 17
  * Process Virtual Size
18 18
  * Process Resident Size
19  
- * Page Faults per second
  19
+ * Page Faults per Second
20 20
  * Global Write Lock Ratio
21 21
  * BTree Page Miss Ratio
22 22
  * Total Operations Waiting for Lock
23 23
  * Readers Waiting for Lock
24 24
  * Writers Waiting for Lock
  25
+ * Total Active Clients
  26
+ * Active Readers
  27
+ * Active Writers
25 28
  * Open Connections
26 29
  * Open Connections (as a percentage of total available)
27 30
  * Replica Set Slave Delay
  31
+ * Asserts per Second
28 32
 
29 33
 ## AUTHOR
30 34
 

0 notes on commit 042c31b

Please sign in to comment.
Something went wrong with that request. Please try again.