Skip to content

Commit 2df075b

Browse files
authored
Merge pull request #192 from Helene/cherrypy_internal_stats
Allow monitoring CherryPy internal statistics
2 parents 6f4cd52 + a0f5fa5 commit 2df075b

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

source/analytics.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@
3232
# measure requests Time-To-First-Byte (TTFB)
3333
global requests_elapsed_time
3434
requests_elapsed_time = False
35+
36+
global cherrypy_internal_stats
37+
cherrypy_internal_stats = False

source/mycherrypy.conf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ request.show_tracebacks = False
66
log.screen = False # turn off logging to console
77
tools.encode.on = True
88
tools.encode.text_only: False
9-
tools.encode.encoding = 'utf-8'
9+
tools.encode.encoding = 'utf-8'
10+
tools.cpstats.on = True

source/zimonGrafanaIntf.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
import os
2727
import errno
2828
import logging
29+
import analytics
30+
2931
from logging import handlers
3032
from queryHandler.QueryHandler import PerfmonConnError
3133
from queryHandler import SensorConfig
@@ -38,6 +40,7 @@
3840
from prometheus import PrometheusExporter
3941
from watcher import ConfigWatcher
4042
from cherrypy import _cperror
43+
from cherrypy.lib.cpstats import StatsPage
4144

4245
ENDPOINTS = {}
4346

@@ -114,6 +117,7 @@ def bind_opentsdb_server(args):
114117
opentsdb_server.ssl_module = 'builtin'
115118
opentsdb_server.ssl_certificate = certPath
116119
opentsdb_server.ssl_private_key = keyPath
120+
opentsdb_server.statistics = analytics.cherrypy_internal_stats
117121
opentsdb_server.subscribe()
118122

119123

@@ -126,6 +130,7 @@ def bind_prometheus_server(args):
126130
prometheus_server.ssl_module = 'builtin'
127131
prometheus_server.ssl_certificate = certPath
128132
prometheus_server.ssl_private_key = keyPath
133+
prometheus_server.statistics = analytics.cherrypy_internal_stats
129134
prometheus_server.subscribe()
130135

131136

@@ -278,7 +283,6 @@ def main(argv):
278283
{'request.dispatch': cherrypy.dispatch.MethodDispatcher()}
279284
}
280285
)
281-
282286
registered_apps.append("OpenTSDB Api listening on Grafana queries")
283287

284288
if args.get('prometheus', None):
@@ -317,6 +321,7 @@ def main(argv):
317321
}
318322
)
319323
registered_apps.append("Prometheus Exporter Api listening on Prometheus requests")
324+
cherrypy.tree.mount(StatsPage(), '/cherrypy_internal_stats')
320325

321326
logger.info("%s", MSG['sysStart'].format(sys.version, cherrypy.__version__))
322327

0 commit comments

Comments
 (0)