Zope按请求的低级别统计数据。
项目描述
简介
这是Enfold Systems的ZODB低级统计工具[1]。
安装
在Plone内部
在Plone中安装,请将 collective.stats 添加到 plone.recipe.zope2instance 部分的 eggs 参数中,例如:
[instance] recipe = plone.recipe.zope2instance eggs = Plone … collective.stats
Plone 3.3 使用需要将 [oldzope] 添加到 collective.stats
[instance] recipe = plone.recipe.zope2instance eggs = Plone … collective.stats [oldzope]
在Windows上使用Plone 3.3需要编译 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 来禁用日志。只有数字1会导致 collective.stats 不记录日志。
environment-vars = COLLECTIVE_STATS_DISABLE_LOG 1
您仍然会得到 X-Stats 响应头。
Plone之外
要在Plone之外使用它,配置 collective.stats 在Plone内部使用(如上所述),然后在您的buildout中配置一个 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
文档
列标题详细信息
标题 |
详情 |
time |
在发布者内部的总时间 |
t traverse |
这是Zope发布者获取可发布对象的时间 |
t commit |
transaction.commit() 上的时间 |
t transchain |
在 plone.transformchain.applyTransform 中的时间 |
setstate |
Connection.setstate 内部的总时间 |
total |
总ZODB对象加载 |
total cached |
从缓存加载的总数 |
modified |
总修改对象 |
rss before |
请求前的RAM使用 |
rss after |
请求后的RAM使用 |
示例
如果您启用collective.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 = commit()的总时间(在IPubBeforeCommit中执行的时间)如果您使用plone.app.caching或plone.app.theming,这两个都使用commit事件;因此,根据collective.stats如何注册,这些可能没有被捕获。
在这个例子中,3.3秒在commit中“丢失”。在这种情况下,这是由于未优化的plone.app.theming / diazo规则文件引起的。
享受吧!
变更日志
1.1.0 (2022-08-25)
添加对Python 3的支持 [mamico]
1.0.2 (2015-12-01)
提供一个方法,在没有日志记录的情况下仍然具有功能 [frapell]
1.0.1 (2015-06-23)
修复与 thread._local 的 AttributeError,适应新的 psutil API。参考:http://stackoverflow.com/questions/20640679 [thet]
1.0.0 (2012-03-29)
为 plone.transformchain applyTransform 添加统计信息 [fafhrd91]
将统计信息添加到失败请求中。 [fafhrd91]
0.9.1 (2011-12-01)
将输出标题详细信息添加到README [aclark]
修复拼写错误 [jean]
0.9.0 (2011-09-22)
修复文档 [aclark]
0.8 (2011-09-22)
修复文档 [aclark]
0.7 (2011-09-22)
从 enfold.stats 0.7 tarball 进行初始导入 [aclark]
项目详情
collective.stats-1.1.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 364e36fad66799b70088db9a887380333abb6044bb940a8d66314deba00e5907 |
|
MD5 | c853caad0c5fef837711424def23781c |
|
BLAKE2b-256 | c456a67ae0e079f1493b3d9b46eddcb9bb0adacf98302ccbe34e95ac3a19eb17 |