stats.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. biggraph = "arg=rpctotal&graph=diff"
  2. graphname = new Array(
  3. "arg=*&graph=diskbw",
  4. "<b>disk</b> bytes/second",
  5. "arg=*&graph=netbw",
  6. "<b>network</b> bytes/second",
  7. "arg=*&graph=iobw",
  8. "total: <b>disk+net</b> bytes/second",
  9. "arg=apartreadbyte&graph=diff",
  10. "arena read bytes/second",
  11. "arg=apartwritebyte&graph=diff",
  12. "arena write bytes/second",
  13. "arg=bloomfalsemiss&graph=pctdiff&arg2=bloomlookup&max=100",
  14. "bloom false hit %",
  15. "arg=bloomhit&graph=pctdiff&arg2=bloomlookup&max=100",
  16. "bloom miss %",
  17. "arg=bloomlookuptime&graph=divdiff&arg2=bloomlookup",
  18. "bloom lookup time",
  19. "arg=bloomones&graph=pct&arg2=bloombits&max=100",
  20. "bloom usage %",
  21. "arg=dcachedirty&graph=pct&arg2=dcachesize&max=100",
  22. "dcache dirty %",
  23. "arg=dcachehit&graph=pctdiff&arg2=dcachelookup&max=100",
  24. "dcache hit %",
  25. "arg=dcachelookuptime&graph=divdiff&arg2=dcachelookup",
  26. "dcache lookup time",
  27. "arg=dcachelookup&graph=diff",
  28. "dcache lookups/second",
  29. "arg=dcachewrite&graph=diff",
  30. "dcache writes/second",
  31. "arg=icachedirty&graph=pct&arg2=icachesize&max=100",
  32. "icache dirty %",
  33. "arg=icachehit&graph=pctdiff&arg2=icachelookup&max=100",
  34. "icache hit %",
  35. "arg=icachelookuptime&graph=divdiff&arg2=icachelookup",
  36. "icache lookup time",
  37. "arg=icacheprefetch&graph=diff",
  38. "icache prefetches/second",
  39. "arg=icachewrite&graph=diff",
  40. "icache writes/second",
  41. "arg=isectreadbyte&graph=diff",
  42. "isect read bytes/second",
  43. "arg=isectwritebyte&graph=diff",
  44. "isect write bytes/second",
  45. "arg=lcachehit&graph=pctdiff&arg2=lcachelookup&max=100",
  46. "lump cache hit %",
  47. "arg=lcachelookuptime&graph=divdiff&arg2=lcachelookup",
  48. "lump cache lookup time",
  49. "arg=lcachewrite&graph=diff",
  50. "lcache writes/second",
  51. "arg=rpcreadbyte&graph=diff",
  52. "read RPC bytes/second",
  53. "arg=rpctotal&graph=diff",
  54. "RPCs/second",
  55. "arg=rpcwritebyte&graph=diff",
  56. "write RPC bytes/second",
  57. "arg=rpcreadtime&graph=divdiff&arg2=rpcread",
  58. "read RPC time",
  59. "arg=rpcwritetime&graph=divdiff&arg2=rpcwrite",
  60. "write RPC time",
  61. "arg=rpcreadcachedtime&graph=divdiff&arg2=rpcreadcached",
  62. "cached read RPC time",
  63. "arg=rpcreaduncachedtime&graph=divdiff&arg2=rpcreaduncached",
  64. "uncached read RPC time",
  65. "arg=rpcwritenewtime&graph=divdiff&arg2=rpcwritenew",
  66. "fresh write RPC time",
  67. "arg=rpcwriteoldtime&graph=divdiff&arg2=rpcwriteold",
  68. "dup write RPC time",
  69. "arg=sumreadbyte&graph=diff",
  70. "checksum bytes/second",
  71. "arg=dblockstall",
  72. "threads stalled: dblock",
  73. "arg=dcachestall",
  74. "threads stalled: dcache",
  75. "arg=icachestall",
  76. "threads stalled: icache",
  77. "arg=lumpstall",
  78. "threads stalled: lump",
  79. "arg=END"
  80. )
  81. column0 = new Array(
  82. "column0",
  83. "!bandwidth",
  84. "arg=*&graph=iobw",
  85. "arg=*&graph=netbw",
  86. "arg=rpcreadbyte&graph=diff",
  87. "arg=rpcwritebyte&graph=diff",
  88. "arg=*&graph=diskbw",
  89. "arg=isectreadbyte&graph=diff",
  90. "arg=isectwritebyte&graph=diff",
  91. "arg=apartreadbyte&graph=diff",
  92. "arg=apartwritebyte&graph=diff",
  93. "arg=sumreadbyte&graph=diff",
  94. "!bloom filter",
  95. "arg=bloomhit&graph=pctdiff&arg2=bloomlookup&max=100",
  96. "arg=bloomfalsemiss&graph=pctdiff&arg2=bloomlookup&max=100",
  97. "arg=bloomones&graph=pct&arg2=bloombits&max=100",
  98. "END"
  99. )
  100. column1 = new Array(
  101. "column1",
  102. "!icache",
  103. "arg=icachedirty&graph=pct&arg2=icachesize&max=100",
  104. "arg=icachehit&graph=pctdiff&arg2=icachelookup&max=100",
  105. "arg=icachewrite&graph=diff",
  106. "arg=icacheprefetch&graph=diff",
  107. "!dcache",
  108. "arg=dcachedirty&graph=pct&arg2=dcachesize&max=100",
  109. "arg=dcachehit&graph=pctdiff&arg2=dcachelookup&max=100",
  110. "arg=dcachelookup&graph=diff",
  111. "arg=dcachewrite&graph=diff",
  112. "!lump cache",
  113. "arg=lcachehit&graph=pctdiff&arg2=lcachelookup&max=100",
  114. "arg=lcachewrite&graph=diff",
  115. "END"
  116. )
  117. column2 = new Array(
  118. "column2",
  119. "!stalls",
  120. "arg=icachestall",
  121. "arg=dcachestall",
  122. "arg=dblockstall",
  123. "arg=lumpstall",
  124. "!timings",
  125. "arg=bloomlookuptime&graph=divdiff&arg2=bloomlookup",
  126. "arg=icachelookuptime&graph=divdiff&arg2=icachelookup",
  127. "arg=lcachelookuptime&graph=divdiff&arg2=lcachelookup",
  128. "arg=dcachelookuptime&graph=divdiff&arg2=dcachelookup",
  129. "arg=rpcreadtime&graph=divdiff&arg2=rpcread",
  130. "arg=rpcwritetime&graph=divdiff&arg2=rpcwrite",
  131. "arg=rpcreadcachedtime&graph=divdiff&arg2=rpcreadcached",
  132. "arg=rpcreaduncachedtime&graph=divdiff&arg2=rpcreaduncached",
  133. "arg=rpcwritenewtime&graph=divdiff&arg2=rpcwritenew",
  134. "arg=rpcwriteoldtime&graph=divdiff&arg2=rpcwriteold",
  135. "END"
  136. )
  137. col0info = new Array(column0.length)
  138. col1info = new Array(column1.length)
  139. col2info = new Array(column2.length)
  140. function cleardebug() {
  141. var p = document.getElementById("debug")
  142. p.innerHTML = ""
  143. }
  144. function debug(s) {
  145. var p = document.getElementById("debug")
  146. if(p.innerHTML == "")
  147. p.innerHTML = "<a href=\"javascript:cleardebug()\">clear</a>\n"
  148. p.innerHTML += "<br>"+s
  149. }
  150. function Ginfo(y, fill, name) {
  151. var g = new Object()
  152. g.y = y
  153. g.fill = fill
  154. g.name = name
  155. return g
  156. }
  157. function cleartable(t) {
  158. for(var i=t.rows.length-1; i>=0; i--)
  159. t.deleteRow(i)
  160. }
  161. function textofname(name)
  162. {
  163. for(var i=0; i<graphname.length; i+=2)
  164. if(name == graphname[i])
  165. return graphname[i+1]
  166. }
  167. function graphrow(row, span, name, dt, wid, ht, fill, text) {
  168. var url = "/graph?"+name
  169. url = url+"&min=0"
  170. url = url+"&t0=-"+dt
  171. url = url+"&wid="+wid
  172. url = url+"&ht="+ht
  173. url = url+"&fill="+fill
  174. var s = "<td colSpan="+span
  175. s = s+" valign=bottom"
  176. s = s+" align=center"
  177. s = s+" width="+wid
  178. s = s+" height="+ht
  179. s = s+" style=\"background-image: url("+url+");\""
  180. s = s+">"+textofname(name)+text+"</td>"
  181. row.innerHTML = s
  182. }
  183. function graphcell(cell, name, dt, wid, ht, fill) {
  184. cell.vAlign = "bottom"
  185. cell.align = "center"
  186. cell.width = wid
  187. cell.height = ht
  188. }
  189. function redraw() {
  190. redrawgraphs()
  191. redrawsettings()
  192. }
  193. function redrawgraphs() {
  194. var t = document.getElementById("statgraphs")
  195. cleartable(t)
  196. for(var i=0; i<4; i++)
  197. t.insertRow(i)
  198. graphrow(t.rows[0], 3, biggraph, 86400, 900, 30, 0, " &ndash; showing 24 hours")
  199. graphrow(t.rows[1], 3, biggraph, 3600, 900, 30, 1, " &ndash; showing 1 hour")
  200. t.rows[2].innerHTML = "<td height=10></td>"
  201. var r = t.rows[3]
  202. graphtable(r.insertCell(0), column0, col0info, 0)
  203. graphtable(r.insertCell(1), column1, col1info, 2)
  204. graphtable(r.insertCell(2), column2, col2info, 4)
  205. }
  206. function graphtable(bigcell, list, infolist, fill) {
  207. bigcell.innerHTML = "<table id=\""+list[0]+"\"></table>"
  208. bigcell.vAlign = "top"
  209. var t = document.getElementById(list[0])
  210. t.onclick = columnclick
  211. for(var i=1; i<list.length; i++){
  212. var r = t.insertRow(t.rows.length)
  213. name = list[i]
  214. infolist[i] = Ginfo(t.offsetHeight, fill, name)
  215. if(name == "END")
  216. break
  217. if(name.substring(0,1) == "!"){
  218. name = name.substring(1)
  219. if(i > 1){
  220. r.innerHTML = "<td height=10></td>"
  221. r = t.insertRow(t.rows.length)
  222. }
  223. r.innerHTML = "<td align=center><b>"+name+"</b>"
  224. }else{
  225. graphrow(r, 1, name, 600, 300, 30, fill++, "")
  226. }
  227. }
  228. }
  229. function xpos(obj) {
  230. var x = 0
  231. if(obj.fixedx)
  232. return obj.fixedx
  233. if(obj.offsetParent){
  234. while(obj.offsetParent){
  235. x += obj.offsetLeft
  236. obj = obj.offsetParent
  237. }
  238. }else if(obj.x)
  239. x = obj.x
  240. return x
  241. }
  242. function ypos(obj) {
  243. var y = 0
  244. if(obj.fixedy)
  245. return obj.fixedy
  246. if(obj.offsetParent){
  247. while(obj.offsetParent){
  248. y += obj.offsetTop
  249. obj = obj.offsetParent
  250. }
  251. }else if(obj.y)
  252. y = obj.y
  253. return y
  254. }
  255. function scrollleft() {
  256. return document.body.scrollLeft
  257. }
  258. function scrolltop() {
  259. return document.body.scrollTop
  260. }
  261. function columnclick(e) {
  262. if(e.which && e.which != 1)
  263. return;
  264. var g = findgraph(scrollleft()+e.clientX, scrolltop()+e.clientY)
  265. if(g && g.name.substring(0,1) != "!"){
  266. biggraph = g.name
  267. var t = document.getElementById("statgraphs")
  268. graphrow(t.rows[0], 3, biggraph, 86400, 900, 30, 0, " &ndash; showing 24 hours")
  269. graphrow(t.rows[1], 3, biggraph, 3600, 900, 30, 1, " &ndash; showing 1 hour")
  270. }
  271. }
  272. function findgraph(x, y) {
  273. var g
  274. if(g = findgraphin(x, y, "column2", col2info))
  275. return g
  276. if(g = findgraphin(x, y, "column1", col1info))
  277. return g
  278. if(g = findgraphin(x, y, "column0", col0info))
  279. return g
  280. return
  281. }
  282. function findgraphin(x, y, tname, info) {
  283. var t = document.getElementById(tname)
  284. if(x < xpos(t))
  285. return
  286. y = y - ypos(t)
  287. for(var i=info.length-2; i>=1; i--){
  288. if(y > info[i].y)
  289. return info[i]
  290. }
  291. return
  292. }
  293. function setof(name, val, list) {
  294. var s = ""
  295. for(var i=0; i<list.length; i++){
  296. if(val == list[i])
  297. s = s+" <b>"+val+"</b>"
  298. else
  299. s = s+" <a href=\"javascript:set('"+name+"', '"+list[i]+"')\">"+list[i]+"</a>"
  300. }
  301. return s
  302. }
  303. function loglinks(list) {
  304. var s = ""
  305. for(var i=0; i<list.length; i++){
  306. s = s+" <a href=\"/log/"+list[i]+"\">"+list[i]+"</a>"
  307. }
  308. return s
  309. }
  310. first = 1
  311. function redrawsettings() {
  312. if(first){
  313. loadsettings()
  314. first = 0
  315. }
  316. var s = ""
  317. s = s+"<font size=-1>\n"
  318. s = s+"logging:"+setof("logging", logging, loggingchoices)
  319. s = s+" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "
  320. s = s+"stats:"+setof("stats", stats, statschoices)
  321. s = s+"\n<p/>\n"
  322. s = s+"compression:"+setof("compress", compress, compresschoices1)
  323. s = s+"<br>"+setof("compress", compress, compresschoices2)
  324. s = s+"\n<p/>\n"
  325. s = s+"<a href=/index>index</a> | <a href=/storage>storage</a> | "
  326. s = s+"log:"+loglinks(logs)
  327. s = s+"</font>"
  328. document.getElementById("settings").innerHTML = s
  329. }
  330. function set(name, value) {
  331. eval(name+"= \""+value+"\"")
  332. redrawsettings()
  333. // Works in FireFox, not in Safari
  334. parent.hidden.location.href = "/set/"+name+"/"+value
  335. }