mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-09-07 04:18:26 +02:00
Performance insights
This commit is contained in:
parent
4d48954473
commit
df26710e47
@ -28,7 +28,10 @@ import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@ -68,7 +71,7 @@ public class PerformanceJSONParser implements TabJSONParser<Map<String, Object>>
|
||||
List<TPS> tpsData = db.query(TPSQueries.fetchTPSDataOfServer(monthAgo, now, serverUUID));
|
||||
|
||||
serverOverview.put("numbers", createNumbersMap(tpsData));
|
||||
serverOverview.put("insights", createInsightsMap(tpsData, serverUUID));
|
||||
serverOverview.put("insights", createInsightsMap(tpsData));
|
||||
return serverOverview;
|
||||
}
|
||||
|
||||
@ -122,24 +125,21 @@ public class PerformanceJSONParser implements TabJSONParser<Map<String, Object>>
|
||||
return decimalFormatter.apply(value);
|
||||
}
|
||||
|
||||
private Map<String, Object> createInsightsMap(List<TPS> tpsData, UUID serverUUID) {
|
||||
Database db = dbSystem.getDatabase();
|
||||
long now = System.currentTimeMillis();
|
||||
long monthAgo = now - TimeUnit.DAYS.toMillis(30L);
|
||||
|
||||
private Map<String, Object> createInsightsMap(List<TPS> tpsData) {
|
||||
TPSMutator tpsMutator = new TPSMutator(tpsData);
|
||||
Integer tpsThreshold = config.get(DisplaySettings.GRAPH_TPS_THRESHOLD_MED);
|
||||
TPSMutator lowTPS = tpsMutator.filterTPSBetween(-1, tpsThreshold);
|
||||
|
||||
Map<String, Object> insights = new HashMap<>();
|
||||
|
||||
insights.put("low_tps_players", decimalFormatter.apply(lowTPS.averagePlayersOnline()));
|
||||
insights.put("low_tps_cpu", decimalFormatter.apply(lowTPS.averageCPU()));
|
||||
insights.put("low_tps_entities", decimalFormatter.apply(lowTPS.averageEntities()));
|
||||
insights.put("low_tps_chunks", decimalFormatter.apply(lowTPS.averageChunks()));
|
||||
|
||||
insights.put("low_tps_disconnects", "Not implemented");
|
||||
insights.put("low_disk_space_dates", Collections.emptyList());
|
||||
double avgPlayersOnline = lowTPS.averagePlayersOnline();
|
||||
double averageCPU = lowTPS.averageCPU();
|
||||
double averageEntities = lowTPS.averageEntities();
|
||||
double averageChunks = lowTPS.averageChunks();
|
||||
insights.put("low_tps_players", avgPlayersOnline != -1 ? decimalFormatter.apply(avgPlayersOnline) : "No low tps spikes");
|
||||
insights.put("low_tps_cpu", averageCPU != -1 ? decimalFormatter.apply(averageCPU) : "-");
|
||||
insights.put("low_tps_entities", averageEntities != -1 ? decimalFormatter.apply(averageEntities) : "-");
|
||||
insights.put("low_tps_chunks", averageChunks != -1 ? decimalFormatter.apply(averageChunks) : "-");
|
||||
|
||||
return insights;
|
||||
}
|
||||
|
@ -336,7 +336,8 @@ function loadPerformanceValues(json, error) {
|
||||
|
||||
$(element).find('#data_low_tps_players').text(data.low_tps_players);
|
||||
$(element).find('#data_low_tps_entities').text(data.low_tps_entities);
|
||||
$(element).find('#data_low_tps_disconnects').text(data.low_tps_disconnects);
|
||||
$(element).find('#data_low_tps_chunks').text(data.low_tps_chunks);
|
||||
$(element).find('#data_low_tps_cpu').text(data.low_tps_cpu);
|
||||
|
||||
dates = data.low_disk_space_dates;
|
||||
dateString = '';
|
||||
|
@ -1141,15 +1141,13 @@
|
||||
<div class="card-body" id="data_insights">
|
||||
<p>During Low TPS Spikes:</p>
|
||||
<p><i class="fa fa-fw fa-users col-red"></i> Average Players<span
|
||||
class="float-right"><b id="data_low_tps_players"></b></p>
|
||||
class="float-right"><b id="data_low_tps_players"></b></span></p>
|
||||
<p><i class="fa fa-fw fa-dragon col-red"></i> Average Entities<span
|
||||
class="float-right"><b id="data_low_tps_entities"></b></p>
|
||||
<p><i class="fa fa-fw fa-user-times col-red"></i> Average Disconnects<span
|
||||
class="float-right"><b id="data_low_tps_disconnects"></b></span></p>
|
||||
<p><i class="fa fa-fw fa-hdd col-red"></i><i
|
||||
class="fa fa-exclamation col-red"></i>
|
||||
Disk Space low on<span class="float-right"><span
|
||||
id="data_low_disk_space_dates"></span></span></p>
|
||||
class="float-right"><b id="data_low_tps_entities"></b></span></p>
|
||||
<p><i class="fa fa-fw fa-dragon col-red"></i> Average Chunks<span
|
||||
class="float-right"><b id="data_low_tps_chunks"></b></span></p>
|
||||
<p><i class="fa fa-fw fa-dragon col-red"></i> Average CPU<span
|
||||
class="float-right"><b id="data_low_tps_cpu"></b></span></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user