mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-28 03:57:33 +01:00
Merge branch 'master' of https://github.com/Rsl1122/Plan-PlayerAnalytics
This commit is contained in:
commit
047446bcd6
@ -1,13 +1,15 @@
|
||||
package main.java.com.djrapitops.plan.data.analysis;
|
||||
|
||||
import com.djrapitops.plugin.api.TimeAmount;
|
||||
import java.util.List;
|
||||
import main.java.com.djrapitops.plan.data.TPS;
|
||||
import main.java.com.djrapitops.plan.ui.html.graphs.CPUGraphCreator;
|
||||
import main.java.com.djrapitops.plan.ui.html.graphs.TPSGraphCreator;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Part responsible for all TPS related analysis.
|
||||
*
|
||||
@ -15,7 +17,7 @@ import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
*
|
||||
* Placeholder values can be retrieved using the get method.
|
||||
*
|
||||
* Contains following place-holders: tpsscatterday, tpsscatterweek, averagetps,
|
||||
* Contains following place-holders: tpsscatterday, tpsscatterweek, cpuscatterday, cpuscatterweek, averagetps,
|
||||
* averagetpsday
|
||||
*
|
||||
* @author Rsl1122
|
||||
@ -37,10 +39,15 @@ public class TPSPart extends RawData<TPSPart> {
|
||||
|
||||
String tpsScatterDay = TPSGraphCreator.buildScatterDataStringTPS(day, TimeAmount.DAY.ms());
|
||||
String tpsScatterWeek = TPSGraphCreator.buildScatterDataStringTPS(week, TimeAmount.WEEK.ms());
|
||||
String cpuScatterDay = CPUGraphCreator.buildScatterDataString(day, TimeAmount.DAY.ms());
|
||||
String cpuScatterWeek = CPUGraphCreator.buildScatterDataString(week, TimeAmount.WEEK.ms());
|
||||
|
||||
addValue("tpsscatterday", tpsScatterDay);
|
||||
addValue("tpsscatterweek", tpsScatterWeek);
|
||||
|
||||
addValue("cpuscatterday", cpuScatterDay);
|
||||
addValue("cpuscatterweek", cpuScatterWeek);
|
||||
|
||||
double averageTPSweek = MathUtils.averageDouble(week.stream().map(TPS::getTps));
|
||||
double averageTPSday = MathUtils.averageDouble(day.stream().map(TPS::getTps));
|
||||
|
||||
|
@ -65,8 +65,11 @@ public class TPSCountTimer extends AbsRunnable {
|
||||
*/
|
||||
private TPS calculateTPS(long diff, long now) {
|
||||
OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
|
||||
int availableProcessors = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors();
|
||||
final double averageCPUUsage = MathUtils.round(operatingSystemMXBean.getSystemLoadAverage() / availableProcessors * 100.0);
|
||||
int availableProcessors = operatingSystemMXBean.getAvailableProcessors();
|
||||
double averageCPUUsage = MathUtils.round(operatingSystemMXBean.getSystemLoadAverage() / availableProcessors * 100.0);
|
||||
if (averageCPUUsage < 0) { // If Unavailable, getSystemLoadAverage() returns -1
|
||||
averageCPUUsage = -1;
|
||||
}
|
||||
|
||||
int playersOnline = plugin.getServer().getOnlinePlayers().size();
|
||||
|
||||
|
@ -23,7 +23,7 @@ public class RecentPlayersButtonsCreator {
|
||||
for (int i = 0; i < names.size(); i++) {
|
||||
if (i < limit) {
|
||||
String name = names.get(i);
|
||||
html.append(Html.BUTTON.parse(HtmlUtils.getInspectUrl(name), name));
|
||||
html.append(Html.BUTTON.parse(HtmlUtils.getRelativeInspectUrl(name), name));
|
||||
html.append(" ");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,20 @@
|
||||
package main.java.com.djrapitops.plan.ui.html.graphs;
|
||||
|
||||
import main.java.com.djrapitops.plan.data.TPS;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.Point;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CPUGraphCreator {
|
||||
public static String buildScatterDataString(List<TPS> tpsData, long scale) {
|
||||
long now = MiscUtils.getTime();
|
||||
List<Point> points = tpsData.stream()
|
||||
.filter(tps -> tps.getDate() >= now - scale)
|
||||
.map(tps -> new Point(tps.getDate(), Double.parseDouble(FormatUtils.cutDecimals(tps.getCPUUsage()).replace(",", "."))))
|
||||
.collect(Collectors.toList());
|
||||
return ScatterGraphCreator.scatterGraph(points, true);
|
||||
}
|
||||
}
|
@ -688,6 +688,9 @@
|
||||
</div>
|
||||
<canvas id="tps7d" width="1000" height="600" style="width: 95%;"></canvas>
|
||||
</div>
|
||||
<div class="box column">
|
||||
<canvas id="cpu7d" width="1000" height="600" style="width: 95%;"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="box column">
|
||||
@ -712,6 +715,10 @@
|
||||
</div>
|
||||
<canvas id="tps24h" width="1000" height="600" style="width: 95%;"></canvas>
|
||||
</div>
|
||||
<div class="box column">
|
||||
<canvas id="cpu24h" width="1000" height="600" style="width: 95%;"></canvas>
|
||||
</div>
|
||||
<p>If CPU Graph displays '-1' CPU usage is not available for this platform.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab">
|
||||
@ -1302,6 +1309,131 @@
|
||||
});
|
||||
|
||||
</script>
|
||||
<script>
|
||||
// CPU Graph 24h
|
||||
var ctxcpu = document.getElementById("cpu24h");
|
||||
var datacpu = {
|
||||
datasets: [
|
||||
{
|
||||
label: "CPU Usage",
|
||||
fill: false,
|
||||
lineTension: 0.1,
|
||||
borderColor: "#e0d264",
|
||||
borderCapStyle: 'butt',
|
||||
borderDash: [],
|
||||
borderDashOffset: 0.0,
|
||||
borderJoinStyle: 'miter',
|
||||
pointBorderColor: "#e0d264",
|
||||
pointBackgroundColor: "#ede5aa",
|
||||
pointBorderWidth: 1,
|
||||
pointHoverRadius: 5,
|
||||
pointHoverBackgroundColor: "#e0d264",
|
||||
pointHoverBorderColor: "#8fabc6",
|
||||
pointHoverBorderWidth: 2,
|
||||
pointRadius: 1,
|
||||
pointHitRadius: 10,
|
||||
spanGaps: false,
|
||||
data: %cpuscatterday%
|
||||
}]
|
||||
};
|
||||
var cpuChart = new Chart(ctxcpu, {
|
||||
type: 'scatter',
|
||||
data: datacpu,
|
||||
options: {
|
||||
tooltips: {
|
||||
callbacks: {
|
||||
label: function(tooltipItems, data) {
|
||||
var newDate = new Date();
|
||||
newDate.setTime(tooltipItems.xLabel);
|
||||
dateString = newDate.toUTCString();
|
||||
return dateString+ ': '+ tooltipItems.yLabel + '%';
|
||||
}
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
yAxes: [{
|
||||
type: 'linear',
|
||||
position: 'left',
|
||||
ticks: {
|
||||
suggestedMax: 100,
|
||||
suggestedMin: 0
|
||||
},
|
||||
scaleLabel: {
|
||||
display: true,
|
||||
labelString: 'CPU Usage'
|
||||
}
|
||||
}],
|
||||
xAxes: [{
|
||||
type: 'linear',
|
||||
display: false
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
<script>
|
||||
// CPU Graph 7d
|
||||
var ctxcpu = document.getElementById("cpu7d");
|
||||
var datacpu = {
|
||||
datasets: [
|
||||
{
|
||||
label: "CPU Usage",
|
||||
fill: false,
|
||||
lineTension: 0.1,
|
||||
borderColor: "#e0d264",
|
||||
borderCapStyle: 'butt',
|
||||
borderDash: [],
|
||||
borderDashOffset: 0.0,
|
||||
borderJoinStyle: 'miter',
|
||||
pointBorderColor: "#e0d264",
|
||||
pointBackgroundColor: "#ede5aa",
|
||||
pointBorderWidth: 1,
|
||||
pointHoverRadius: 5,
|
||||
pointHoverBackgroundColor: "#e0d264",
|
||||
pointHoverBorderColor: "#8fabc6",
|
||||
pointHoverBorderWidth: 2,
|
||||
pointRadius: 1,
|
||||
pointHitRadius: 10,
|
||||
spanGaps: false,
|
||||
data: %cpuscatterweek%
|
||||
}]
|
||||
};
|
||||
var cpuChart = new Chart(ctxcpu, {
|
||||
type: 'scatter',
|
||||
data: datacpu,
|
||||
options: {
|
||||
tooltips: {
|
||||
callbacks: {
|
||||
label: function(tooltipItems, data) {
|
||||
var newDate = new Date();
|
||||
newDate.setTime(tooltipItems.xLabel);
|
||||
dateString = newDate.toUTCString();
|
||||
return dateString+ ': '+ tooltipItems.yLabel + '%';
|
||||
}
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
yAxes: [{
|
||||
type: 'linear',
|
||||
position: 'left',
|
||||
ticks: {
|
||||
suggestedMax: 100,
|
||||
suggestedMin: 0
|
||||
},
|
||||
scaleLabel: {
|
||||
display: true,
|
||||
labelString: 'CPU Usage'
|
||||
}
|
||||
}],
|
||||
xAxes: [{
|
||||
type: 'linear',
|
||||
display: false
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
// ActivityPie Graph
|
||||
var ctxactivitypie = document.getElementById("activityPie");
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: Plan
|
||||
author: Rsl1122
|
||||
main: main.java.com.djrapitops.plan.Plan
|
||||
version: 3.5.4
|
||||
version: 3.5.5
|
||||
|
||||
softdepend:
|
||||
- OnTime
|
||||
|
Loading…
Reference in New Issue
Block a user