每个请求的Zope低级统计信息。
collective.stats的Python项目详细描述
简介
这是Enfold Systems’低级zodb统计工具[1]。
安装
内部PLONE
要在plone中安装,请将collective.stats添加到plone.recipe.zope2instance部分的eggs参数中,例如:
[instance] recipe = plone.recipe.zope2instance eggs = Plone … collective.stats
plone 3.3的用法要求在collective.stats:
后附加[oldzope][instance] recipe = plone.recipe.zope2instance eggs = Plone … collective.stats [oldzope]
windows上的plone 3.3需要python 2.4编译psutil包,可以在http://dist.enfoldsystems.com/simple
运行buildout并在前台运行plone,您将看到如下输出:
2011-09-22 22:25:30 INFO Zope Ready to handle requests 2011-09-22 22:25:50 INFO collective.stats | 0.0021 0.0014 0.0018 0.0004 0.0000 0000 0000 0000 | GET:/favicon.ico | t: 0.0000, t_c: 0.0000, t_nc: 0.0000 | RSS: 116708 - 116744 2011-09-22 22:25:55 INFO collective.stats | 0.1783 0.0021 0.1779 0.0004 0.0000 0000 0000 0000 | GET:/manage_main | t: 0.0000, t_c: 0.0000, t_nc: 0.0000 | RSS: 116756 - 116948 2011-09-22 22:25:55 INFO collective.stats | 0.0020 0.0013 0.0017 0.0004 0.0000 0000 0000 0000 | GET:/misc_/OFSP/dtmlmethod.gif | t: 0.0000, t_c: 0.0000, t_nc: 0.0000 | RSS: 117076 - 117076 2011-09-22 22:25:55 INFO collective.stats | 0.0018 0.0012 0.0016 0.0004 0.0000 0000 0000 0000 | GET:/misc_/TemporaryFolder/tempfolder.gif | t: 0.0000, t_c: 0.0000, t_nc: 0.0000 | RSS: 117076 - 117076 2011-09-22 22:25:55 INFO collective.stats | 0.0021 0.0013 0.0018 0.0004 0.0000 0000 0000 0000 | GET:/misc_/SiteAccess/VirtualHostMonster.gif | t: 0.0000, t_c: 0.0000, t_nc: 0.0000 | RSS: 117076 - 117076 2011-09-22 22:25:58 INFO collective.stats | 0.3960 0.0015 0.3957 0.0004 0.0000 0000 0000 0000 | GET:/@@plone-addsite | t: 0.0000, t_c: 0.0000, t_nc: 0.0000 | RSS: 117076 - 126352 2011-09-22 22:25:58 INFO collective.stats | 0.0020 0.0014 0.0017 0.0004 0.0000 0000 0000 0000 | GET:/++resource++plone-admin-ui.css | t: 0.0000, t_c: 0.0000, t_nc: 0.0000 | RSS: 126352 - 126356 2011-09-22 22:25:58 INFO collective.stats | 0.0014 0.0009 0.0012 0.0004 0.0000 0000 0000 0000 | GET:/++resource++plone-logo.png | t: 0.0000, t_c: 0.0000, t_nc: 0.0000 | RSS: 126356 - 126360
如果要在生产环境中使用此产品,并且不希望日志填满,则可以通过提供环境变量COLLECTIVE_STATS_DISABLE_LOG来删除日志记录。唯一会导致collective.stats不记录的值是数字1:
environment-vars = COLLECTIVE_STATS_DISABLE_LOG 1
您仍然可以得到X-Stats响应头。
外部扑通声
若要在plone外部使用它,请在将collective.stats配置为在plone内部使用(如上所述)之后,在构建中配置一个zc.recipe.egg节,如下所示:
[zopepy] recipe = zc.recipe.egg eggs = ${instance:eggs} interpreter = zopepy scripts = collective-stats
运行buildout,这将创建一个名为collective-stats的脚本,您可以使用它来解析plone日志并生成一个.csv文件:
$ bin/collective-stats var/log/instance.log … 1.3170 0.0196 1.3139 0.0004 0.0000 0000 0000 0003 | GET:/Plone 0.0283 0.0274 0.0278 0.0004 0.0000 0000 0000 0000 | GET:/Plone/portal_css/Sunburst Theme/member.css 0.0153 0.0147 0.0150 0.0003 0.0000 0000 0000 0000 | GET:/Plone/portal_css/Sunburst Theme/forms.css 0.0176 0.0167 0.0171 0.0003 0.0000 0000 0000 0000 | GET:/Plone/portal_css/Sunburst Theme/ploneKss.css 0.0704 0.0694 0.0699 0.0003 0.0000 0000 0000 0000 | GET:/Plone/portal_css/Sunburst Theme/++resource++plone.app.discussion.stylesheets/discussion.css 0.0096 0.0090 0.0093 0.0003 0.0000 0000 0000 0000 | GET:/Plone/portal_css/Sunburst Theme/print.css 0.0067 0.0061 0.0064 0.0003 0.0000 0000 0000 0000 | GET:/Plone/portal_css/Sunburst Theme/mobile.css 0.0920 0.0709 0.0915 0.0003 0.0000 0000 0000 0000 | GET:/Plone/portal_css/Sunburst Theme/++resource++tinymce.stylesheets/tinymce.css 0.0319 0.0313 0.0316 0.0003 0.0034 0004 0000 0000 | GET:/Plone/portal_css/Sunburst Theme/ploneCustom.css 0.0078 0.0069 0.0075 0.0003 0.0000 0000 0000 0000 | GET:/Plone/portal_kss/Sunburst Theme/plone.kss
检查当前目录,您将看到一个stats.csv文件:
$ ls -1 … lib/ parts/ setup.py src/ stats.csv var/
查看该文件的顶部可查看列标题:
$ head stats.csv url,time,t traverse,t commit,t transchain,setstate,total,total cached,modified,rss before,rss after GET:/favicon.ico,0.0021,0.0014,0.0018,0.0000,0000,0000,0000,116708,116744 GET:/manage_main,0.1783,0.0021,0.1779,0.0000,0000,0000,0000,116756,116948 GET:/manage_page_style.css,0.0110,0.0014,0.0108,0.0000,0000,0000,0000,116948,117012 GET:/p_/ltab,0.0023,0.0008,0.0021,0.0000,0000,0000,0000,117020,117032 GET:/p_/sp,0.0100,0.0054,0.0099,0.0039,0018,0004,0000,116992,117032 GET:/p_/rtab,0.0020,0.0012,0.0018,0.0000,0000,0000,0000,117032,117032 GET:/misc_/OFSP/Folder_icon.gif,0.0018,0.0012,0.0016,0.0000,0000,0000,0000,117032,117032 GET:/p_/ControlPanel_icon,0.0017,0.0009,0.0015,0.0000,0000,0000,0000,117036,117036 GET:/misc_/OFSP/UserFolder_icon.gif,0.0017,0.0012,0.0015,0.0000,0000,0000,0000,117036,117036
文档
列标题详细信息:
Header | Detail |
time | Total time inside publisher |
t traverse | This is time when zope publisher gets publishable object |
t commit | Time on transaction.commit() |
t transchain | Time in plone.transformchain.applyTransform |
setstate | Total time inside Connection.setstate |
total | Total zodb object loads |
total cached | Total loads from cache |
modified | Total modified objects |
rss before | RAM usage before request |
rss after | RAM usage after request |
示例
如果启用collective.stats在响应头中发出stats,您将看到一个响应行,如:
X-Stats:4.5556 0.0232 1.2539 0.6334 9266 1244 0000
破译:
4.555 - (time) is total time in Zope Publisher 0.023 - (t traverse) is after traverse time (callable object inside Publisher) time from BEGINNING of request to after TRAVERSE time. 1.253 - (t commit) is before commit() (we have a complete RESPONSE object) time from BEGINGING of request to before COMMIT 0.6334 - (setstate) total time in __setstate__ (time of ZODB spent unghostifying # of LOAD objects) 9266 - (total) total number of LOADS 1244 - (total cached) total number of HOT LOADS (cache hits in ZODB) 0000 - (modified) total number of MODIFIED objects.
小结
t_time-t_commit=total time to commit()(在ipubbeforecommit中执行的时间) 如果您使用plone.app.caching或plone.app.theming这两种方法都使用 提交事件;因此取决于collective.stats注册的方式-这是可能的 他们没有被抓获。
在这个例子中,3.3秒在提交时是“丢失”的。在这种特殊情况下 这是由于未优化的plone.app.theming/diazo规则文件。
享受吧!
[1] | ^{tt1}$ has been donated to the Plone collective by Enfold Systems under a BSD-like license (ZPL 2.1). |
更改日志
1.0.2(2015-12-01)
- 提供一种不需要记录就可以保持功能的方法 [弗雷佩尔]
1.0.1(2015-06-23)
- 用thread._local修复AttributeError,适应新的psutilapi。 参考号:http://stackoverflow.com/questions/20640679 [时间]
1.0.0(2012-03-29)
- 添加plone.transformchain applytransform的统计信息 [FAFHRD91]
- 向失败请求添加统计信息。 [FAFHRD91]
0.9.1(2011-12-01)
- 向自述文件添加输出标题详细信息 [标记]
- 修正打字错误 [琴]
0.9.0(2011-09-22)
- 修复文档 [标记]
0.8(2011-09-22)
- 修复文档 [标记]
0.7(2011-09-22)
- 从enfold.stats 0.7 tarball的初始导入 [标记]