Skip to content

Commit a0e2fda

Browse files
committed
cherrypy_internal_stats
Signed-off-by: hwassman <[email protected]>
1 parent 6f4cd52 commit a0e2fda

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-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: 7 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,8 @@
3840
from prometheus import PrometheusExporter
3941
from watcher import ConfigWatcher
4042
from cherrypy import _cperror
43+
from cherrypy.lib import cpstats
44+
from cherrypy.lib.cpstats import StatsPage
4145

4246
ENDPOINTS = {}
4347

@@ -114,6 +118,7 @@ def bind_opentsdb_server(args):
114118
opentsdb_server.ssl_module = 'builtin'
115119
opentsdb_server.ssl_certificate = certPath
116120
opentsdb_server.ssl_private_key = keyPath
121+
opentsdb_server.statistics = analytics.cherrypy_internal_stats
117122
opentsdb_server.subscribe()
118123

119124

@@ -126,6 +131,7 @@ def bind_prometheus_server(args):
126131
prometheus_server.ssl_module = 'builtin'
127132
prometheus_server.ssl_certificate = certPath
128133
prometheus_server.ssl_private_key = keyPath
134+
prometheus_server.statistics = analytics.cherrypy_internal_stats
129135
prometheus_server.subscribe()
130136

131137

@@ -278,7 +284,6 @@ def main(argv):
278284
{'request.dispatch': cherrypy.dispatch.MethodDispatcher()}
279285
}
280286
)
281-
282287
registered_apps.append("OpenTSDB Api listening on Grafana queries")
283288

284289
if args.get('prometheus', None):
@@ -317,6 +322,7 @@ def main(argv):
317322
}
318323
)
319324
registered_apps.append("Prometheus Exporter Api listening on Prometheus requests")
325+
cherrypy.tree.mount(StatsPage(), '/cherrypy_internal_stats')
320326

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

0 commit comments

Comments
 (0)