1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 DEFAULT_HTTP_PORT = 8091
16
17 import Globals
18
19 from Products.ZenHub.PBDaemon import PBDaemon
20 from Products.ZenModel.PerformanceConf import performancePath
21 from RenderServer import RenderServer as OrigRenderServer
22 from Products.ZenUtils.ObjectCache import ObjectCache
23
24 from twisted.web import resource, server
25 from twisted.internet import reactor
26
27 import os
28 import mimetypes
29
40
42
43 isLeaf = True
44
46 args = request.args.copy()
47 for k, v in args.items():
48 if len(v) == 1:
49 args[k] = v[0]
50 command = request.postpath[-1]
51 zr.log.debug("Processing %s request" % command)
52 args.setdefault('ftype', 'PNG')
53 ftype = args['ftype']
54 del args['ftype']
55 mimetype = mimetypes.guess_type('.%s'%ftype)[0]
56 if not mimetype: mimetype = 'image/%s'%ftype
57 request.setHeader('Content-type', mimetype)
58 return getattr(zr, 'remote_' + command)(**args)
59
61
62 initialServices = ['ZenRender']
63 name = 'zenrender'
64
68
70 return self.rs.render(*args, **kw)
71
74
77
80
83
86
88 return self.rs.plugin(*args, **kw)
89
91 return self.rs.summary(*args, **kw)
92
95
104
105
106 if __name__ == '__main__':
107 zr = zenrender()
108 reactor.listenTCP(int(zr.options.httpport), server.Site(HttpRender()))
109 zr.run()
110