<commit_before><!DOCTYPE html>
<html>
    <head>
        <title>nGrinder Agent Info</title>
       	<#include "../common/common.ftl">
       	<#include "../common/jqplot.ftl">
       	<style>
            .left { border-right: 1px solid #878988 }
            div.chart { border: 1px solid #878988; height:250px; min-width:615px; margin-bottom:12px; padding: 5px }
        </style>
    </head>

    <body>
        <#include "../common/navigator.ftl">
        <div class="container">
            <div class="page-header pageHeader" style="margin-bottom: 10px">
			<span>
				<h3><@spring.message "agent.info.title"/></h3>
			</span>
		</div>
            <div class="row">
                <div class="span3">
                    <table class="table table-bordered table-striped" style="border-top:#cccccc solid 1px">
				    <tbody>
					    <tr>
					    	<th><@spring.message "agent.table.IP"/></th>
					    </tr>
	                    <tr>
					    	<td>${(agent.ip)!}</td>
					    </tr>
					    <tr>
					    	<th><@spring.message "agent.table.port"/></th>
					    </tr>
	                    <tr>
					    	<td>${(agent.port)!}</td>
					    </tr>
					    <tr>
					    	<th><@spring.message "agent.table.name"/></th>
					    </tr>
	                    <tr>
					   		<td>${(agent.hostName)!}</td>
					    </tr>
					    	<th><@spring.message "agent.table.region"/></th>
					    </tr>
	                    <tr>
					    	<td>${(agent.region)!}</td>
					    </tr>
					    </tr>
					    <tr>
					    	<th><@spring.message "agent.table.status"/></th>
					    </tr>
	                    <tr>
					    	<td>${(agent.status)!}</td>
					    </tr>
				    </tbody>
				    </table>
				    <label><@spring.message "agent.info.refreshInterval"/></label>
                    <input id="rinterval" type="text" class="span3" placeholder="number" value="1">
                </div>
                <div class="span9">
					<div class="tabbable" style="margin-left:20px">
                        <ul class="nav nav-tabs" id="chartTab">
                            <li><a href="#systemData" data-toggle="tab"><@spring.message "agent.info.systemData"/></a></li>
                            <li><a href="#javaData" data-toggle="tab"><@spring.message "agent.info.javaData"/></a></li>
                        </ul>
                        <div class="tab-content">
                            <div class="tab-pane active" id="systemData">
								<div class="page-header">
									<h4>CPU</h4>
								</div>
                                <div class="chart" id="cpuDiv"></div>
								<div class="page-header">
									<h4>Memory</h4>
								</div>
                                <div class="chart" id="memoryDiv"></div>
                            </div>
                            <div class="tab-pane" id="javaData">
								<div class="page-header">
									<h4>Heap Memory</h4>
								</div>
                                <div class="chart" id="heapMemoryDiv"></div>
								<div class="page-header">
									<h4>NonHeap Memory</h4>
								</div>
                                <div class="chart" id="nonHeapMemoryDiv"></div>
								<div class="page-header">
									<h4>Thread Count</h4>
								</div>
                                <div class="chart" id="threadCountDiv"></div>
								<div class="page-header">
									<h4>CPU</h4>
								</div>
                                <div class="chart" id="jvmCpuDiv"></div>
                            </div>
					     </div>
                    </div>
                </div>
            </div>
        	<#include "../common/copyright.ftl">
    	<!--content-->
        </div>
        <script src="${req.getContextPath()}/js/queue.js"></script>
        <script>
            var interval;
            var timer;
            var java_heapUsedMemory = new Queue();
			var java_nonHeapUsedMemory = new Queue();
			var java_cpuUsedPercentage = new Queue();
			var java_threadCount = new Queue();
			var sys_totalCpuValue = new Queue();
			var sys_usedMemory = new Queue();
			var jqplots = [];
            $(document).ready(function() {
            	$("#chartTab a:first").tab('show');
            	
                $("#returnBtn").on('click', function() {
                    history.back();
                });
                
                $("#rinterval").keyup(function() {
                    var number = $(this).val();
                    $(this).val(number.replace(/[\D]/g,""))
                });
                
                $("#rinterval").blur(function() {
                    if(timer){
                        window.clearInterval(timer);
                    }
                    interval = $(this).val();
                    if(interval == 0){
                        interval = 1;
                    }
                    cleanChartData();
                    timer=window.setInterval("getMonitorData()",interval * 1000);
                });
                
                $('#chartTab a').click(function () {
					resetFooter();
				});
				
                getMonitorData();
                $("#rinterval").blur();
            });
            var maxCPU = 0;
            var maxMemory = 0;
            var maxHeapMemory = 0;
            var maxNonHeapMemory = 0;
            var maxThreadCount = 0;
            var maxJVMCpu = 0;
            
            function getMax(prev, current) {
            	var currentMax = 0;
            	for (var i = 0; current.length > i; i++) {
	            	if (current[i] > currentMax) {
	            		currentMax = current[i];
	            	}
            	}
            	if (prev > currentMax) {
            		return prev;
            	}
            	return currentMax;
            }
            function getMonitorData(){
                $.ajax({
                    url: "${req.getContextPath()}/monitor/getCurrentMonitorData",
                    dataType:'json',
                    data: {'ip': '${(agent.ip)!}',
                           'imgWidth':700},
                    success: function(res) {
                        if (res.success) {
                        	getChartData(res);
                        	if ($("#chartTab li:first").hasClass("active")) {
                        		maxCPU = getMax(maxCPU, sys_totalCpuValue.aElement);
                        		showChart('CPU', 'cpuDiv', sys_totalCpuValue.aElement, 0, formatPercentage, maxCPU);
                        		maxMemory = getMax(maxMemory, sys_usedMemory.aElement);
                            	showChart('Memory', 'memoryDiv', sys_usedMemory.aElement, 1, formatAmount, maxMemory);
                        	} else {
                        		
                        		maxHeapMemory = getMax(maxHeapMemory, java_heapUsedMemory.aElement);
	                            showChart('Heap Memory', 'heapMemoryDiv', java_heapUsedMemory.aElement, 2, formatAmount, maxHeapMemory);
	                            maxNonHeapMemory = getMax(maxNonHeapMemory, java_nonHeapUsedMemory.aElement);
	                            showChart('NonHeap Memory', 'nonHeapMemoryDiv', java_nonHeapUsedMemory.aElement, 3, formatAmount, maxNonHeapMemory);
	                            maxThreadCount = getMax(maxThreadCount, java_threadCount.aElement);
	                            showChart('Thread Count', 'threadCountDiv', java_threadCount.aElement, 4, maxThreadCount);
	                            maxJVMCpu = getMax(maxJVMCpu, java_cpuUsedPercentage.aElement);
	                            showChart('CPU', 'jvmCpuDiv', java_cpuUsedPercentage.aElement, 5, formatPercentage, maxJVMCpu);
                        	}
                            return true;
                        } else {
                            showErrorMsg("Get monitor data failed.");
                            return false;
                        }
                    },
                    error: function() {
                        showErrorMsg("Error!");
                        return false;
                    }
                });<commit_msg>[NGRINDER-83] Add the UI Element to beauty <commit_after><!DOCTYPE html>
<html>
    <head>
        <title>nGrinder Agent Info</title>
       	<#include "../common/common.ftl">
       	<#include "../common/jqplot.ftl">
       	<style>
            .left { border-right: 1px solid #878988 }
            div.chart { border: 1px solid #878988; height:250px; min-width:615px; margin-bottom:12px; padding: 5px }
        </style>
    </head>

    <body>
        <#include "../common/navigator.ftl">
        <div class="container">
            <div class="page-header pageHeader" style="margin-bottom: 10px">
			<span>
				<h3><@spring.message "agent.info.title"/></h3>
			</span>
		</div>
            <div class="row">
                <div class="span3">
                    <table class="table table-bordered table-striped" style="border-top:#cccccc solid 1px">
				    <tbody>
					    <tr>
					    	<th><@spring.message "agent.table.IP"/></th>
					    </tr>
	                    <tr>
					    	<td>${(agent.ip)!}</td>
					    </tr>
					    <tr>
					    	<th><@spring.message "agent.table.port"/></th>
					    </tr>
	                    <tr>
					    	<td>${(agent.port)!}</td>
					    </tr>
					    <tr>
					    	<th><@spring.message "agent.table.name"/></th>
					    </tr>
	                    <tr>
					   		<td>${(agent.hostName)!}</td>
					    </tr>
					    	<th><@spring.message "agent.table.region"/></th>
					    </tr>
	                    <tr>
					    	<td>${(agent.region)!}</td>
					    </tr>
					    </tr>
					    <tr>
					    	<th><@spring.message "agent.table.status"/></th>
					    </tr>
	                    <tr>
					    	<td>${(agent.status)!}</td>
					    </tr>
				    </tbody>
				    </table>
				    <label><@spring.message "agent.info.refreshInterval"/></label>
                    <input id="rinterval" type="text" class="span3" placeholder="number" value="1">
                </div>
                <div class="span9">
					<div class="tabbable" style="margin-left:20px">
                        <ul class="nav nav-tabs" id="chartTab">
                            <li><a href="#systemData" data-toggle="tab"><@spring.message "agent.info.systemData"/></a></li>
                            <li><a href="#javaData" data-toggle="tab"><@spring.message "agent.info.javaData"/></a></li>
                        </ul>
                        <div class="tab-content">
                            <div class="tab-pane active" id="systemData">
								<div class="page-header">
									<h4>CPU</h4>
								</div>
                                <div class="chart" id="cpuDiv"></div>
								<div class="page-header">
									<h4>Memory</h4>
								</div>
                                <div class="chart" id="memoryDiv"></div>
                            </div>
                            <div class="tab-pane" id="javaData">
								<div class="page-header">
									<h4>Heap Memory</h4>
								</div>
                                <div class="chart" id="heapMemoryDiv"></div>
								<div class="page-header">
									<h4>NonHeap Memory</h4>
								</div>
                                <div class="chart" id="nonHeapMemoryDiv"></div>
								<div class="page-header">
									<h4>Thread Count</h4>
								</div>
                                <div class="chart" id="threadCountDiv"></div>
								<div class="page-header">
									<h4>CPU</h4>
								</div>
                                <div class="chart" id="jvmCpuDiv"></div>
                            </div>
					     </div>
                    </div>
                </div>
            </div>
        	<#include "../common/copyright.ftl">
    	<!--content-->
        </div>
        <script src="${req.getContextPath()}/js/queue.js"></script>
        <script>
            var interval;
            var timer;
            var java_heapUsedMemory = new Queue();
			var java_nonHeapUsedMemory = new Queue();
			var java_cpuUsedPercentage = new Queue();
			var java_threadCount = new Queue();
			var sys_totalCpuValue = new Queue();
			var sys_usedMemory = new Queue();
			var jqplots = [];
            $(document).ready(function() {
            	$("#chartTab a:first").tab('show');
            	
                $("#returnBtn").on('click', function() {
                    history.back();
                });
                
                $("#rinterval").keyup(function() {
                    var number = $(this).val();
                    $(this).val(number.replace(/[\D]/g,""))
                });
                
                $("#rinterval").blur(function() {
                    if(timer){
                        window.clearInterval(timer);
                    }
                    interval = $(this).val();
                    if(interval == 0){
                        interval = 1;
                    }
                    cleanChartData();
                    timer=window.setInterval("getMonitorData()",interval * 1000);
                });
                
                $('#chartTab a').click(function () {
					resetFooter();
				});
				
                getMonitorData();
                $("#rinterval").blur();
            });
            var maxCPU = 0;
            var maxMemory = 0;
            var maxHeapMemory = 0;
            var maxNonHeapMemory = 0;
            var maxThreadCount = 0;
            var maxJVMCpu = 0;
            
            function getMax(prev, current) {
            	var currentMax = 0;
            	for (var i = 0; current.length > i; i++) {
	            	if (current[i] > currentMax) {
	            		currentMax = current[i];
	            	}
            	}
            	if (prev > currentMax) {
            		return prev;
            	}
            	return currentMax;
            }
            function getMonitorData(){
                $.ajax({
                    url: "${req.getContextPath()}/monitor/getCurrentMonitorData",
                    dataType:'json',
                    data: {'ip': '${(agent.ip)!}',
                           'imgWidth':700},
                    success: function(res) {
                        if (res.success) {
                        	getChartData(res);
                        	if ($("#chartTab li:first").hasClass("active")) {
                        		maxCPU = getMax(maxCPU, sys_totalCpuValue.aElement);
                        		showChart('CPU', 'cpuDiv', sys_totalCpuValue.aElement, 0, formatPercentage, maxCPU);
                        		maxMemory = getMax(maxMemory, sys_usedMemory.aElement);
                            	showChart('Memory', 'memoryDiv', sys_usedMemory.aElement, 1, formatAmount, maxMemory);
                        	} else {
                        		
                        		maxHeapMemory = getMax(maxHeapMemory, java_heapUsedMemory.aElement);
	                            showChart('Heap Memory', 'heapMemoryDiv', java_heapUsedMemory.aElement, 2, formatAmount, maxHeapMemory);
	                            maxNonHeapMemory = getMax(maxNonHeapMemory, java_nonHeapUsedMemory.aElement);
	                            showChart('NonHeap Memory', 'nonHeapMemoryDiv', java_nonHeapUsedMemory.aElement, 3, formatAmount, maxNonHeapMemory);
	                            maxThreadCount = getMax(maxThreadCount, java_threadCount.aElement);
	                            showChart('Thread Count', 'threadCountDiv', java_threadCount.aElement, 4, formatAmount, maxThreadCount);
	                            maxJVMCpu = getMax(maxJVMCpu, java_cpuUsedPercentage.aElement);
	                            showChart('CPU', 'jvmCpuDiv', java_cpuUsedPercentage.aElement, 5, formatPercentage, maxJVMCpu);
                        	}
                            return true;
                        } else {
                            showErrorMsg("Get monitor data failed.");
                            return false;
                        }
                    },
                    error: function() {
                        showErrorMsg("Error!");
                        return false;
                    }
                });
{'fraction_non_alphanumeric': 0.14098728496634255, 'fraction_numerical': 0.008726003490401396, 'mean_word_length': 1.2297109505280712, 'pattern_counts': {'":': 0, '<': 285, '<?xml version=': 0, '>': 291, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3873426', 'n_tokens_mistral': 5134, 'n_tokens_neox': 4289, 'n_words': 762}