-
Notifications
You must be signed in to change notification settings - Fork 36
/
metrics-watcher.min.js
1 lines (1 loc) · 14.7 KB
/
metrics-watcher.min.js
1
(function(e,t,r){function d(e,t,r,d,s,a){this.divId=e,this.className=t,this.metricName=r,this.max=d,this.title=s,this.type=a,this.getMax=function(){return this.max},this.getMetricNode=function(e,t,r){return r[e]?r[e][t]:null}}function s(e,t){var r=100*(e/t);return r.toFixed(0)}function a(e,t){return t||(t=1),e.toFixed(t)}function n(e){return e.charAt(0).toUpperCase()+e.slice(1)}function i(e,t,r,s,a,n,i,o){var l=new d(e,t,r,s,a,"timer");return l.getMeterInfo=function(){var e=this.divId+" div.timerGraph td.meterGraph",t=new d(e,this.className,this.metricName,this.max,"Frequency","meter");return t.getMetricNode=function(e,t,r){return r[e]?r[e][t].rate:null},t.eventType=n,t},l.getTimerStatsDivId=function(){return"#"+this.divId+" div.timerGraph td.timerStatsGraph"},l.getTimerHistogramDivId=function(){return"#"+this.divId+" div.timerGraph td.timerHistogram"},l.durationMax=i,l.isNested=o,l}function o(e){var r=t("#"+e.divId),d="<div class='metricsWatcher counter counterGraph'><h3>"+e.title+"</h3><div class='progress'><div class='progress-bar' style='width: 0%;'></div></div></div>";r.html(d)}function l(e,r){var d=e.getMetricNode(e.className,e.metricName,r),a=s(d.count,e.getMax(r));t("#"+e.divId+" div.progress div.progress-bar").css("width",a+"%"),t("#"+e.divId+" div.progress div.progress-bar").html(d.count+"/"+e.getMax(r))}function m(e){var r=t("#"+e.divId),d=e.isNested?" nested":"",s="<div class='metricsWatcher timer timerGraph"+d+" col-md-12'>"+"<fieldset><legend><h1>"+e.title+"</h1></legend>"+"<div class='timerContainer col-md-12'>"+"<table><tr>"+"<td class='meterGraph col-md-4'></td>"+"<td class='timerStatsGraph col-md-4'></td>"+"<td class='timerHistogram col-md-4'></td>"+"</tr></table></div></fieldset>";r.html(s),f(e.getMeterInfo()),c(e),u(e)}function c(e){var r="<h3>Duration</h3><p></p><div class='metricGraph'><table class='progressTable'>"+w("Min","min")+w("Mean","mean")+w("Median","median")+w("Max","max")+w("Std Dev","std_dev")+"</table></div>",d=t(e.getTimerStatsDivId());d.html(r)}function u(e){var r="<h3>Histogram</h3><p>Percentiles</p><div class='metricGraph'><table class='progressTable'>"+w("99.9%","p999")+w("99%","p99")+w("98%","p98")+w("95%","p95")+w("75%","p75")+"</table></div>",d=t(e.getTimerHistogramDivId());d.html(r)}function h(e,t){b(e.getMeterInfo(),t),v(e,t),g(e,t)}function v(e,r){var d=e.getMetricNode(e.className,e.metricName,r);if(d){var s=d.duration,a=t(e.getTimerStatsDivId()+" p");a.html(n(s.unit)),p(e.getTimerStatsDivId(),s,"min",e.durationMax),p(e.getTimerStatsDivId(),s,"mean",e.durationMax),p(e.getTimerStatsDivId(),s,"median",e.durationMax),p(e.getTimerStatsDivId(),s,"max",e.durationMax),p(e.getTimerStatsDivId(),s,"std_dev",e.durationMax)}}function p(e,r,d,n){t(e+" tr."+d+" td.progressValue").html(a(r[d])),t(e+" tr."+d+" td.progressBar div.progress div.progress-bar").css("width",s(r[d],n)+"%")}function g(e,t){var r=e.getMetricNode(e.className,e.metricName,t);if(r){var d=r.duration;p(e.getTimerHistogramDivId(),d,"p999",e.durationMax),p(e.getTimerHistogramDivId(),d,"p99",e.durationMax),p(e.getTimerHistogramDivId(),d,"p98",e.durationMax),p(e.getTimerHistogramDivId(),d,"p95",e.durationMax),p(e.getTimerHistogramDivId(),d,"p75",e.durationMax)}}function f(e){var r=t("#"+e.divId),d="<div class='metricsWatcher metric metricGraph'><h3>"+e.title+"</h3><p></p><table class='progressTable'>"+w("1 min","onemin")+w("5 min","fivemin")+w("15 min","fifteenmin")+w("Mean","mean")+"</table></div>";r.html(d)}function w(e,t){return"<tr class='"+t+"'><td class='progressLabel'>"+e+"</td>"+"<td class='progressBar'><div class='progress'><div class='progress-bar' style='width: 0%;'></div>"+"</div></td><td class='progressValue'>0</td></tr>"}function b(e,t){var r=e.getMetricNode(e.className,e.metricName,t);r&&I(e,r)}function I(e,r){var d=t("#"+e.divId+" p"),s=e.eventType;s||(s=r.event_type),r.count>1&&"get"===s?s="gets":r.count>1&&"put"===s&&(s="puts");var a=r.unit;"seconds"===a&&(a="second"),d.html(s+" per "+a+" ("+r.count+" total)"),y(e,r,"mean","mean"),y(e,r,"m1","onemin"),y(e,r,"m5","fivemin"),y(e,r,"m15","fifteenmin")}function y(e,r,d,n){t("#"+e.divId+" tr."+n+" td.progressValue").html(a(r[d])),t("#"+e.divId+" tr."+n+" td.progressBar div.progress div.progress-bar").css("width",s(r[d],e.max)+"%")}function M(e){var r=t("#"+e.divId),d="<div class='metricsWatcher metric metricGraph'><h3>"+e.title+"</h3><h1></h1></div>";r.html(d)}function S(e,t){var r=e.getMetricNode(e.className,e.metricName,t);r&&C(e,r)}function C(e,r){var d=t("#"+e.divId+" h1");d.html(r.value)}function T(e,r){var d=t("#"+e),s="<div class='metricsWatcher metric metricGraph nested'><fieldset><legend><h1>"+r+"</h1></legend>"+"<div class='gaugeTableContainer'><table class='gaugeTable'></table></div></fieldset></div>";d.html(s)}function G(e,r,d){for(var s=t("#"+e+" table"),a="",n=r.length,i=0;n>i;i++){var o=r[i];a+="<tr><td><h5>"+o.title+"</h5></td>"+"<td><h4>"+o.getMetricNode(o.className,o.metricName,d).value+"</h4></td></tr>"}s.html(a)}function N(e){var r=t("#"+e.divId),d="<div class='metricsWatcher cache cacheGraph col-md-12'><fieldset><legend><h1>"+e.title+"</h1></legend>"+"<div class='cacheContainer col-md-12'>"+" <div class='row'>"+" <div class='col-md-3'><div id='"+e.divId+"Statistics'></div></div>"+" <div class='col-md-9'>"+" <div id='"+e.divId+"gettimer'></div>"+" <div id='"+e.divId+"puttimer'></div>"+" </div>"+" </div>"+"</div></fieldset></div>";r.html(d);for(var s=e.components.gauges.length,a=0;s>a;a++)M(e.components.gauges[a]);m(e.getTimer),m(e.putTimer),T(e.divId+"Statistics","Statistics",e.components.gauges)}function x(e,r){for(var d=e.components.gauges.length,s=0;d>s;s++){var a=e.components.gauges[s],n=a.getMetricNode(e.className,a.metricName,r);if(n){var i=t("#"+a.divId+" div.metricGraph h1");i.html(n.value)}}h(e.getTimer,r),h(e.putTimer,r),G(e.divId+"Statistics",e.components.gauges,r)}function j(e){var r=t("#"+e.divId),d="<div class='metricsWatcher jvm metricGraph col-md-12'><fieldset><legend><h1>"+e.title+"</h1></legend>"+"<div class='jvmContainer col-md-12'>"+" <div id='"+e.divId+"Vm'></div>"+"</div>"+"</fieldset></div>";r.html(d)}function H(e,r){var d=t("#"+e.divId+"Vm"),s=r[e.className],n="<div class='row'><div class='col-md-3'><table class='jvmTable'><tr><td class='rowName'><h5>Name</h5></td><td>"+s.vm.name+"</td></tr>"+"<tr><td><h5>Version</h5></td><td>"+s.vm.version+"</td></tr>"+"<tr><td><h5>Current Time</h5></td><td>"+s.current_time+"</td></tr>"+"<tr><td><h5>Uptime</h5></td><td>"+s.uptime+"</td></tr>"+"<tr><td><h5>FD Usage</h5></td><td>"+a(s.fd_usage,2)+"</td></tr>"+"<tr><td><h5>Daemon Threads</h5></td><td>"+s.daemon_thread_count+"</td></tr>"+"<tr><td><h5>Threads</h5></td><td>"+s.thread_count+"</td></tr>"+"</table></div>"+"<div class='col-md-3'><table class='jvmTable'>"+"<tr><td><h5>Total Init</h5></td><td>"+s.memory.totalInit+"</td></tr>"+"<tr><td><h5>Total Used</h5></td><td>"+s.memory.totalUsed+"</td></tr>"+"<tr><td><h5>Total Max</h5></td><td>"+s.memory.totalMax+"</td></tr>"+"<tr><td><h5>Total Committed</h5></td><td>"+s.memory.totalCommitted+"</td></tr>"+"<tr><td><h5>Heap Init</h5></td><td>"+s.memory.heapInit+"</td></tr>"+"<tr><td><h5>Heap Used</h5></td><td>"+s.memory.heapUsed+"</td></tr>"+"<tr><td><h5>Heap Max</h5></td><td>"+s.memory.heapMax+"</td></tr>"+"<tr><td><h5>Heap Committed</h5></td><td>"+s.memory.heapCommitted+"</td></tr>"+"<tr><td><h5>Heap Usage</h5></td><td>"+a(s.memory.heap_usage,2)+"</td></tr>"+"<tr><td><h5>Non Heap Usage</h5></td><td>"+a(s.memory.non_heap_usage,2)+"</td></tr>"+"</table></div>"+"<div class='col-md-3'><table class='jvmTable'>"+"<tr><td><h5>Code Cache</h5></td><td>"+a(s.memory.memory_pool_usages["Code Cache"],2)+"</td></tr>"+"<tr><td><h5>PS Eden Space</h5></td><td>"+a(s.memory.memory_pool_usages["PS Eden Space"],2)+"</td></tr>"+"<tr><td><h5>PS Old Gen</h5></td><td>"+a(s.memory.memory_pool_usages["PS Old Gen"],2)+"</td></tr>"+"<tr><td><h5>PS Perm Gen</h5></td><td>"+a(s.memory.memory_pool_usages["PS Perm Gen"],2)+"</td></tr>"+"<tr><td><h5>PS Survivor Space</h5></td><td>"+a(s.memory.memory_pool_usages["PS Survivor Space"],2)+"</td></tr>"+"<tr><td><h5>PS Mark Sweep Runs</h5></td><td>"+s["garbage-collectors"]["PS MarkSweep"].runs+"</td></tr>"+"<tr><td><h5>PS Mark Sweep Time</h5></td><td>"+s["garbage-collectors"]["PS MarkSweep"].time+"</td></tr>"+"<tr><td><h5>PS Scavenge Runs</h5></td><td>"+s["garbage-collectors"]["PS Scavenge"].runs+"</td></tr>"+"<tr><td><h5>PS Scavenge Time</h5></td><td>"+s["garbage-collectors"]["PS Scavenge"].time+"</td></tr>"+"</table></div>"+"<div class='col-md-3'><table class='jvmTable'>"+"<tr><td><h5>Terminated</h5></td><td>"+s["thread-states"].terminated+"</td></tr>"+"<tr><td><h5>Timed Waiting</h5></td><td>"+a(s["thread-states"].timed_waiting,2)+"</td></tr>"+"<tr><td><h5>Blocked</h5></td><td>"+a(s["thread-states"].blocked,2)+"</td></tr>"+"<tr><td><h5>Waiting</h5></td><td>"+a(s["thread-states"].waiting,2)+"</td></tr>"+"<tr><td><h5>Runnable</h5></td><td>"+a(s["thread-states"].runnable,2)+"</td></tr>"+"<tr><td><h5>New</h5></td><td>"+s["thread-states"]["new"]+"</td></tr>"+"</table></div></div>";d.html(n)}function D(e){var r=t("#"+e.divId),d="<div class='metricsWatcher web metricGraph col-md-12'><fieldset><legend><h1>"+e.title+"</h1></legend>"+"<div class='webContainer col-md-12'>"+" <div id='"+e.divId+"Web'></div>"+"<table><tr>"+"<td colspan='4' class='requestsGraph col-md-12'></td>"+"</tr><tr>"+"<td class='activeRequestsGraph col-md-3'></td>"+"<td class='responseCodesOkGraph col-md-3'></td>"+"<td class='responseCodesCreatedGraph col-md-3'></td>"+"<td class='responseCodesOtherGraph col-md-3'></td>"+"</tr><tr>"+"<td class='responseCodesBadRequestGraph col-md-3'></td>"+"<td class='responseCodesNoContentGraph col-md-3'></td>"+"<td class='responseCodesNotFoundGraph col-md-3'></td>"+"<td class='responseCodesServerErrorGraph col-md-3'></td>"+"</tr></table>"+"</div>"+"</fieldset></div>";r.html(d),m(e.components.requestsInfo),o(e.components.activeRequestsInfo);for(var s=e.components.meters.length,a=0;s>a;a++)f(e.components.meters[a])}function _(e,t){h(e.components.requestsInfo,t),l(e.components.activeRequestsInfo,t);for(var r=e.components.meters.length,d=0;r>d;d++)b(e.components.meters[d],t)}function q(e){var r=t("#"+e.divId),d="<div class='metricsWatcher log4j metricGraph col-md-12'><fieldset><legend><h1>"+e.title+"</h1></legend>"+"<div class='log4jContainer col-md-12'>"+" <div id='"+e.divId+"Log4j'></div>"+"<table><tr>"+"<td colspan='4' class='col-md-12'></td>"+"</tr><tr>"+"<td class='all col-md-3'></td>"+"<td class='fatal col-md-3'></td>"+"<td class='error col-md-3'></td>"+"<td class='warn col-md-3'></td>"+"</tr><tr>"+"<td class='info col-md-3'></td>"+"<td class='debug col-md-3'></td>"+"<td class='trace col-md-3'></td>"+"</tr></table>"+"</div>"+"</fieldset></div>";r.html(d);for(var s=e.components.meters.length,a=0;s>a;a++)f(e.components.meters[a])}function P(e,t){for(var r=e.components.meters.length,d=0;r>d;d++)b(e.components.meters[d],t)}e.addGauge=function(e,t,r,s){var a=new d(e,t,r,null,s,"gauge");R.push(a)},e.addMeter=function(e,t,s,a,n,i){i==r&&(i="Calls");var o=new d(e,t,s,a,n,"meter");o.eventType=i,R.push(o)},e.addCounter=function(e,t,r,s,a){var n=new d(e,t,r,s,a,"counter");R.push(n)},e.addLinkedCounter=function(e,t,r,s,a,n){var i=new d(e,t,r,null,n,"counter");i.maxClassName=s,i.maxMetricName=a,i.getMax=function(e){var t=this.getMetricNode(this.maxClassName,this.maxMetricName,e);return t.count},R.push(i)},e.addTimer=function(e,t,r,d,s,a,n){var o=i(e,t,r,d,s,a,n,!1);R.push(o)},e.addCache=function(e,t,r){var s=new d(e,t,null,null,r,"cache");s.components={gauges:[new d(null,t,"hits",null,"Hits","gauge"),new d(null,t,"misses",null,"Misses","gauge"),new d(null,t,"objects",null,"Objects","gauge"),new d(null,t,"eviction-count",null,"Eviction Count","gauge"),new d(null,t,"in-memory-hits",null,"In Memory Hits","gauge"),new d(null,t,"in-memory-misses",null,"In Memory Misses","gauge"),new d(null,t,"in-memory-objects",null,"In Memory Objects","gauge"),new d(null,t,"off-heap-hits",null,"Off Heap Hits","gauge"),new d(null,t,"off-heap-misses",null,"Off Heap Misses","gauge"),new d(null,t,"off-heap-objects",null,"Off Heap Objects","gauge"),new d(null,t,"on-disk-hits",null,"On Disk Hits","gauge"),new d(null,t,"on-disk-misses",null,"On Disk Misses","gauge"),new d(null,t,"on-disk-objects",null,"On Disk Objects","gauge"),new d(null,t,"mean-get-time",null,"Mean Get Time","gauge"),new d(null,t,"mean-search-time",null,"Mean Search Time","gauge"),new d(null,t,"searches-per-second",null,"Searches Per Sec","gauge"),new d(null,t,"writer-queue-size",null,"Writer Queue Size","gauge"),new d(null,t,"accuracy",null,"Accuracy","gauge")]},s.getTimer=i(e+"gettimer",t,"get",1e3,"Get","get",1e3,!0),s.putTimer=i(e+"puttimer",t,"put",1e3,"Put","put",1e4,!0),R.push(s)},e.addJvm=function(e,t,r){var s=new d(e,t,null,null,r,"jvm");R.push(s)},e.addWeb=function(e,t,r){var s=new d(e,t,null,null,r,"web");s.components={meters:[new d(e+" td.responseCodesOkGraph",t,"responseCodes.ok",10,"OK Responses","meter"),new d(e+" td.responseCodesBadRequestGraph",t,"responseCodes.badRequest",10,"Bad Requests","meter"),new d(e+" td.responseCodesCreatedGraph",t,"responseCodes.created",10,"Created Responses","meter"),new d(e+" td.responseCodesNoContentGraph",t,"responseCodes.noContent",10,"No Content Responses","meter"),new d(e+" td.responseCodesNotFoundGraph",t,"responseCodes.notFound",10,"Not Found Responses","meter"),new d(e+" td.responseCodesOtherGraph",t,"responseCodes.other",10,"Other Responses","meter"),new d(e+" td.responseCodesServerErrorGraph",t,"responseCodes.serverError",10,"Server Error Responses","meter")],activeRequestsInfo:new d(e+" td.activeRequestsGraph",t,"activeRequests",10,"Active Requests","counter"),requestsInfo:i(e+" td.requestsGraph",t,"requests",100,"Requests","requests",100,!0)},R.push(s)},e.addLog4j=function(e,t,r){var s=new d(e,t,null,null,r,"log4j");s.components={meters:[new d(e+" td.all",t,"all",100,"all","meter"),new d(e+" td.fatal",t,"fatal",100,"fatal","meter"),new d(e+" td.error",t,"error",100,"error","meter"),new d(e+" td.warn",t,"warn",100,"warn","meter"),new d(e+" td.info",t,"info",100,"info","meter"),new d(e+" td.debug",t,"debug",100,"debug","meter"),new d(e+" td.trace",t,"trace",100,"trace","meter")]},R.push(s)},e.initGraphs=function(){for(var e=0;e<R.length;e++)R[e].type=="gauge"?M(R[e]):R[e].type=="meter"?f(R[e]):R[e].type=="counter"?o(R[e]):R[e].type=="timer"?m(R[e]):R[e].type=="cache"?N(R[e]):R[e].type=="jvm"?j(R[e]):R[e].type=="web"?D(R[e]):R[e].type=="log4j"?q(R[e]):alert("Unknown meter info type: "+R[e].type)},e.updateGraphs=function(e){for(var t=0;t<R.length;t++)R[t].type=="gauge"?S(R[t],e):R[t].type=="meter"?b(R[t],e):R[t].type=="counter"?l(R[t],e):R[t].type=="timer"?h(R[t],e):R[t].type=="cache"?x(R[t],e):R[t].type=="jvm"?H(R[t],e):R[t].type=="web"?_(R[t],e):R[t].type=="log4j"?P(R[t],e):alert("Unknown meter info type: "+R[t].type)};var R=[]})(window.metricsWatcher=window.metricsWatcher||{},jQuery);