[#737] Free Disk Space Tracking

- Added a new free disk space to TPS, in megabytes
- Added Gathering method to TPSCountTimers
- Added Column to plan_tps
- Added Patch for adding plan_tps column
- Added Disk usage point mutation method to TPSMutator
  - Filtered out -1 values in Disk and CPU graphs
- Added DiskGraph and its factory method
- Added 'diskSeries' placeholder replacement to AnalysisContainer
- Added diskGraph.js for drawing disk graph
- Added 'diskMedium' & 'diskHigh' threshold placeholders
- Added Medium and high disk threholds to settings
- Replaced MB references with Mb, since B is bit and b is byte
- Added Html Lang
This commit is contained in:
Rsl1122 2018-10-24 22:25:43 +03:00
parent 98aaff0328
commit 7bb97f4ffc
43 changed files with 319 additions and 92 deletions

View File

@ -24,6 +24,7 @@ public class TPS implements DateHolder {
private final long usedMemory;
private final int entityCount;
private final int chunksLoaded;
private final long freeDiskSpace;
/**
* Constructor.
@ -32,11 +33,21 @@ public class TPS implements DateHolder {
* @param ticksPerSecond average ticksPerSecond for the last minute.
* @param players players for the minute.
* @param cpuUsage CPU usage for the minute
* @param usedMemory used memory at the time of fetching
* @param usedMemory used memory (megabytes) at the time of fetching
* @param entityCount amount of entities at the time of fetching
* @param chunksLoaded amount of chunks loaded at the time of fetching
* @param freeDiskSpace free megabytes in the partition the server is running in.
*/
public TPS(long date, double ticksPerSecond, int players, double cpuUsage, long usedMemory, int entityCount, int chunksLoaded) {
public TPS(
long date,
double ticksPerSecond,
int players,
double cpuUsage,
long usedMemory,
int entityCount,
int chunksLoaded,
long freeDiskSpace
) {
this.date = date;
this.ticksPerSecond = ticksPerSecond;
this.players = players;
@ -44,6 +55,7 @@ public class TPS implements DateHolder {
this.usedMemory = usedMemory;
this.entityCount = entityCount;
this.chunksLoaded = chunksLoaded;
this.freeDiskSpace = freeDiskSpace;
}
@Override
@ -105,6 +117,15 @@ public class TPS implements DateHolder {
return chunksLoaded;
}
/**
* Get free megabytes of disk space on the server disk.
*
* @return Amount of megabytes in use.
*/
public long getFreeDiskSpace() {
return freeDiskSpace;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
@ -116,12 +137,13 @@ public class TPS implements DateHolder {
Double.compare(tps.cpuUsage, cpuUsage) == 0 &&
usedMemory == tps.usedMemory &&
entityCount == tps.entityCount &&
chunksLoaded == tps.chunksLoaded;
chunksLoaded == tps.chunksLoaded &&
freeDiskSpace == tps.freeDiskSpace;
}
@Override
public int hashCode() {
return Objects.hash(date, ticksPerSecond, players, cpuUsage, usedMemory, entityCount, chunksLoaded);
return Objects.hash(date, ticksPerSecond, players, cpuUsage, usedMemory, entityCount, chunksLoaded, freeDiskSpace);
}
@Override
@ -133,6 +155,7 @@ public class TPS implements DateHolder {
"cpuUsage=" + cpuUsage + ", " +
"usedMemory=" + usedMemory + ", " +
"entityCount=" + entityCount + ", " +
"chunksLoaded=" + chunksLoaded + '}';
"chunksLoaded=" + chunksLoaded + ", " +
"freeDiskSpace=" + freeDiskSpace + '}';
}
}

View File

@ -20,6 +20,7 @@ public class TPSBuilder {
protected long usedMemory = -1;
protected int entityCount = -1;
protected int chunksLoaded = -1;
protected long freeDiskSpace = -1;
/**
* Hides constructor.
@ -28,11 +29,11 @@ public class TPSBuilder {
}
public static TPSBuilder.Date get() {
return new TPSBuilder.Chunks();
return new TPSBuilder.DiskSpace();
}
public TPS toTPS() {
return new TPS(date, ticksPerSecond, players, cpuUsage, usedMemory, entityCount, chunksLoaded);
return new TPS(date, ticksPerSecond, players, cpuUsage, usedMemory, entityCount, chunksLoaded, freeDiskSpace);
}
public static class Date extends TPSBuilder {
@ -89,8 +90,15 @@ public class TPSBuilder {
public static class Chunks extends Entities {
public TPSBuilder chunksLoaded(int chunksLoaded) {
public DiskSpace chunksLoaded(int chunksLoaded) {
this.chunksLoaded = chunksLoaded;
return (DiskSpace) this;
}
}
public static class DiskSpace extends Chunks {
public TPSBuilder freeDiskSpace(long freeDiskSpace) {
this.freeDiskSpace = freeDiskSpace;
return this;
}
}

View File

@ -122,6 +122,8 @@ public class AnalysisContainer extends DataContainer {
putRawData(AnalysisKeys.FIRST_DAY, 1);
putRawData(AnalysisKeys.TPS_MEDIUM, config.getNumber(Settings.THEME_GRAPH_TPS_THRESHOLD_MED));
putRawData(AnalysisKeys.TPS_HIGH, config.getNumber(Settings.THEME_GRAPH_TPS_THRESHOLD_HIGH));
putRawData(AnalysisKeys.DISK_MEDIUM, config.getNumber(Settings.THEME_GRAPH_DISK_THRESHOLD_MED));
putRawData(AnalysisKeys.DISK_HIGH, config.getNumber(Settings.THEME_GRAPH_DISK_THRESHOLD_HIGH));
addServerProperties();
addThemeColors();
@ -360,6 +362,7 @@ public class AnalysisContainer extends DataContainer {
putSupplier(AnalysisKeys.TPS_SERIES, () -> graphs.line().tpsGraph(getUnsafe(AnalysisKeys.TPS_MUTATOR)).toHighChartsSeries());
putSupplier(AnalysisKeys.CPU_SERIES, () -> graphs.line().cpuGraph(getUnsafe(AnalysisKeys.TPS_MUTATOR)).toHighChartsSeries());
putSupplier(AnalysisKeys.RAM_SERIES, () -> graphs.line().ramGraph(getUnsafe(AnalysisKeys.TPS_MUTATOR)).toHighChartsSeries());
putSupplier(AnalysisKeys.DISK_SERIES, () -> graphs.line().diskGraph(getUnsafe(AnalysisKeys.TPS_MUTATOR)).toHighChartsSeries());
putSupplier(AnalysisKeys.ENTITY_SERIES, () -> graphs.line().entityGraph(getUnsafe(AnalysisKeys.TPS_MUTATOR)).toHighChartsSeries());
putSupplier(AnalysisKeys.CHUNK_SERIES, () -> graphs.line().cpuGraph(getUnsafe(AnalysisKeys.TPS_MUTATOR)).toHighChartsSeries());
putSupplier(AnalysisKeys.WORLD_MAP_SERIES, () ->

View File

@ -30,6 +30,8 @@ public class AnalysisKeys {
public static final PlaceholderKey<Integer> FIRST_DAY = new PlaceholderKey<>(Integer.class, "firstDay");
public static final PlaceholderKey<Integer> TPS_MEDIUM = new PlaceholderKey<>(Integer.class, "tpsMedium");
public static final PlaceholderKey<Integer> TPS_HIGH = new PlaceholderKey<>(Integer.class, "tpsHigh");
public static final PlaceholderKey<Integer> DISK_MEDIUM = new PlaceholderKey<>(Integer.class, "diskMedium");
public static final PlaceholderKey<Integer> DISK_HIGH = new PlaceholderKey<>(Integer.class, "diskHigh");
public static final PlaceholderKey<Integer> PLAYERS_MAX = new PlaceholderKey<>(Integer.class, "playersMax");
public static final PlaceholderKey<Integer> PLAYERS_ONLINE = CommonPlaceholderKeys.PLAYERS_ONLINE;
public static final PlaceholderKey<Integer> PLAYERS_TOTAL = CommonPlaceholderKeys.PLAYERS_TOTAL;
@ -127,6 +129,7 @@ public class AnalysisKeys {
public static final PlaceholderKey<String> RAM_SERIES = new PlaceholderKey<>(String.class, "ramSeries");
public static final PlaceholderKey<String> ENTITY_SERIES = new PlaceholderKey<>(String.class, "entitySeries");
public static final PlaceholderKey<String> CHUNK_SERIES = new PlaceholderKey<>(String.class, "chunkSeries");
public static final PlaceholderKey<String> DISK_SERIES = new PlaceholderKey<>(String.class, "diskSeries");
public static final PlaceholderKey<String> PUNCHCARD_SERIES = new PlaceholderKey<>(String.class, "punchCardSeries");
public static final PlaceholderKey<String> WORLD_MAP_SERIES = CommonPlaceholderKeys.WORLD_MAP_SERIES;
public static final PlaceholderKey<String> ACTIVITY_STACK_SERIES = CommonPlaceholderKeys.ACTIVITY_STACK_SERIES;

View File

@ -65,6 +65,7 @@ public class TPSMutator {
public List<Point> cpuPoints() {
return tpsData.stream()
.map(tps -> new Point(tps.getDate(), tps.getCPUUsage()))
.filter(point -> point.getY() != -1)
.collect(Collectors.toList());
}
@ -86,6 +87,13 @@ public class TPSMutator {
.collect(Collectors.toList());
}
public List<Point> freeDiskPoints() {
return tpsData.stream()
.map(tps -> new Point(tps.getDate(), tps.getFreeDiskSpace()))
.filter(point -> point.getY() != -1)
.collect(Collectors.toList());
}
public long serverDownTime() {
long lastDate = -1;
long downTime = 0;

View File

@ -180,7 +180,8 @@ public abstract class SQLDB extends Database {
new IPHashPatch(this),
new IPAnonPatch(this),
new NicknameLastSeenPatch(this),
new VersionTableRemovalPatch(this)
new VersionTableRemovalPatch(this),
new DiskUsagePatch(this)
};
try {

View File

@ -0,0 +1,23 @@
package com.djrapitops.plan.system.database.databases.sql.patches;
import com.djrapitops.plan.system.database.databases.sql.SQLDB;
import com.djrapitops.plan.system.database.databases.sql.tables.TPSTable;
public class DiskUsagePatch extends Patch {
public DiskUsagePatch(SQLDB db) {
super(db);
}
@Override
public boolean hasBeenApplied() {
return hasColumn(TPSTable.TABLE_NAME, TPSTable.Col.FREE_DISK.get());
}
@Override
public void apply() {
addColumn(TPSTable.TABLE_NAME,
TPSTable.Col.FREE_DISK + " bigint NOT NULL DEFAULT -1"
);
}
}

View File

@ -28,8 +28,10 @@ import java.util.*;
*/
public class TPSTable extends Table {
public static final String TABLE_NAME = "plan_tps";
public TPSTable(SQLDB db) {
super("plan_tps", db);
super(TABLE_NAME, db);
serverTable = db.getServerTable();
insertStatement = "INSERT INTO " + tableName + " ("
+ Col.SERVER_ID + ", "
@ -39,10 +41,11 @@ public class TPSTable extends Table {
+ Col.CPU_USAGE + ", "
+ Col.RAM_USAGE + ", "
+ Col.ENTITIES + ", "
+ Col.CHUNKS
+ Col.CHUNKS + ", "
+ Col.FREE_DISK
+ ") VALUES ("
+ serverTable.statementSelectServerID + ", "
+ "?, ?, ?, ?, ?, ?, ?)";
+ "?, ?, ?, ?, ?, ?, ?, ?)";
}
private final ServerTable serverTable;
@ -59,6 +62,7 @@ public class TPSTable extends Table {
.column(Col.RAM_USAGE, Sql.LONG).notNull()
.column(Col.ENTITIES, Sql.INT).notNull()
.column(Col.CHUNKS, Sql.INT).notNull()
.column(Col.FREE_DISK, Sql.LONG).notNull()
.foreignKey(Col.SERVER_ID, serverTable.getTableName(), ServerTable.Col.SERVER_ID)
.toString()
);
@ -88,6 +92,7 @@ public class TPSTable extends Table {
.usedMemory(set.getLong(Col.RAM_USAGE.get()))
.entities(set.getInt(Col.ENTITIES.get()))
.chunksLoaded(set.getInt(Col.CHUNKS.get()))
.freeDiskSpace(set.getLong(Col.FREE_DISK.get()))
.toTPS();
data.add(tps);
@ -142,6 +147,7 @@ public class TPSTable extends Table {
statement.setLong(6, tps.getUsedMemory());
statement.setDouble(7, tps.getEntityCount());
statement.setDouble(8, tps.getChunksLoaded());
statement.setLong(9, tps.getFreeDiskSpace());
}
});
}
@ -176,6 +182,7 @@ public class TPSTable extends Table {
.usedMemory(set.getLong(Col.RAM_USAGE.get()))
.entities(set.getInt(Col.ENTITIES.get()))
.chunksLoaded(set.getInt(Col.CHUNKS.get()))
.freeDiskSpace(set.getLong(Col.FREE_DISK.get()))
.toTPS();
return Optional.of(tps);
@ -208,6 +215,7 @@ public class TPSTable extends Table {
Col.RAM_USAGE + ", " +
Col.ENTITIES + ", " +
Col.CHUNKS + ", " +
Col.FREE_DISK + ", " +
serverUUIDColumn +
" FROM " + tableName +
" INNER JOIN " + serverTable + " on " + serverIDColumn + "=" + Col.SERVER_ID;
@ -229,6 +237,7 @@ public class TPSTable extends Table {
.usedMemory(set.getLong(Col.RAM_USAGE.get()))
.entities(set.getInt(Col.ENTITIES.get()))
.chunksLoaded(set.getInt(Col.CHUNKS.get()))
.freeDiskSpace(set.getLong(Col.FREE_DISK.get()))
.toTPS();
tpsList.add(tps);
@ -298,6 +307,7 @@ public class TPSTable extends Table {
statement.setLong(6, tps.getUsedMemory());
statement.setDouble(7, tps.getEntityCount());
statement.setDouble(8, tps.getChunksLoaded());
statement.setLong(9, tps.getFreeDiskSpace());
statement.addBatch();
}
}
@ -346,7 +356,8 @@ public class TPSTable extends Table {
CPU_USAGE("cpu_usage"),
RAM_USAGE("ram_usage"),
ENTITIES("entities"),
CHUNKS("chunks_loaded");
CHUNKS("chunks_loaded"),
FREE_DISK("free_disk_space");
private final String column;

View File

@ -51,7 +51,10 @@ public enum ServerPageLang implements Lang {
USED_COMMANDS("Used Commands"),
UNIQUE_TEXT("Unique"),
COMMAND(" Command"),
TIMES_USED("Times Used");
TIMES_USED("Times Used"),
FREE_DISK_SPACE("Free Disk Space"),
DISK_SPACE("DISK SPACE"),
;
private final String defaultValue;

View File

@ -37,6 +37,7 @@ public class TPSInsertProcessor implements CriticalRunnable {
long averageUsedMemory = (long) history.stream().mapToLong(TPS::getUsedMemory).average().orElse(0);
int averageEntityCount = (int) history.stream().mapToInt(TPS::getEntityCount).average().orElse(0);
int averageChunksLoaded = (int) history.stream().mapToInt(TPS::getChunksLoaded).average().orElse(0);
long freeDiskSpace = (long) history.stream().mapToLong(TPS::getFreeDiskSpace).average().orElse(0);
TPS tps = TPSBuilder.get()
.date(lastDate)
@ -46,6 +47,7 @@ public class TPSInsertProcessor implements CriticalRunnable {
.usedMemory(averageUsedMemory)
.entities(averageEntityCount)
.chunksLoaded(averageChunksLoaded)
.freeDiskSpace(freeDiskSpace)
.toTPS();
database.save().insertTPSforThisServer(tps);

View File

@ -92,6 +92,8 @@ public enum Settings implements Setting {
THEME_BASE("Theme.Base"),
THEME_GRAPH_TPS_THRESHOLD_HIGH("Theme.Graphs.TPS.High-Threshold"),
THEME_GRAPH_TPS_THRESHOLD_MED("Theme.Graphs.TPS.Medium-Threshold"),
THEME_GRAPH_DISK_THRESHOLD_HIGH("Theme.Graphs.Disk.High-Threshold"),
THEME_GRAPH_DISK_THRESHOLD_MED("Theme.Graphs.Disk.Medium-Threshold"),
// StringList
HIDE_FACTIONS("Plugins.Factions.HideFactions"),

View File

@ -8,6 +8,7 @@ import com.djrapitops.plugin.logging.console.PluginLogger;
import com.djrapitops.plugin.logging.error.ErrorHandler;
import com.djrapitops.plugin.task.AbsRunnable;
import java.io.File;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.util.ArrayList;
@ -27,6 +28,8 @@ public abstract class TPSCountTimer extends AbsRunnable {
protected final PluginLogger logger;
protected final ErrorHandler errorHandler;
private boolean diskErrored = false;
protected int latestPlayersOnline = 0;
public TPSCountTimer(
@ -89,4 +92,17 @@ public abstract class TPSCountTimer extends AbsRunnable {
}
return averageCPUUsage * 100.0;
}
protected long getFreeDiskSpace() {
try {
File file = new File(new File("").getAbsolutePath());
return file.getFreeSpace() / 1000000L;
} catch (SecurityException noPermission) {
if (!diskErrored) {
errorHandler.log(L.WARN, this.getClass(), noPermission);
}
diskErrored = true;
return -1;
}
}
}

View File

@ -40,6 +40,7 @@ public class BungeeTPSCountTimer extends TPSCountTimer {
.usedMemory(getUsedMemory())
.entities(-1)
.chunksLoaded(-1)
.freeDiskSpace(getFreeDiskSpace())
.toTPS();
history.add(tps);

View File

@ -40,6 +40,7 @@ public class VelocityTPSCountTimer extends TPSCountTimer {
.usedMemory(getUsedMemory())
.entities(-1)
.chunksLoaded(-1)
.freeDiskSpace(getFreeDiskSpace())
.toTPS();
history.add(tps);

View File

@ -2,6 +2,7 @@ package com.djrapitops.plan.system.tasks.server.bukkit;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.TPS;
import com.djrapitops.plan.data.container.builders.TPSBuilder;
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.processing.processors.Processors;
@ -59,30 +60,21 @@ public class BukkitTPSCountTimer extends TPSCountTimer {
*/
private TPS calculateTPS(long diff, long now) {
double averageCPUUsage = getCPUUsage();
long usedMemory = getUsedMemory();
long freeDiskSpace = getFreeDiskSpace();
int playersOnline = serverProperties.getOnlinePlayers();
latestPlayersOnline = playersOnline;
int loadedChunks = getLoadedChunks();
int entityCount;
int entityCount = getEntityCount();
entityCount = getEntityCount();
return getTPS(diff, now, averageCPUUsage, usedMemory, entityCount, loadedChunks, playersOnline);
return getTPS(diff, now, averageCPUUsage, usedMemory, entityCount, loadedChunks, playersOnline, freeDiskSpace);
}
/**
* Gets the TPS for Spigot / Bukkit
*
* @param diff The difference between the last run and this run
* @param now The time right now
* @param cpuUsage The usage of the CPU
* @param playersOnline The amount of players that are online
* @return the TPS
*/
protected TPS getTPS(long diff, long now, double cpuUsage, long usedMemory, int entityCount, int chunksLoaded, int playersOnline) {
protected TPS getTPS(long diff, long now,
double cpuUsage, long usedMemory,
int entityCount, int chunksLoaded,
int playersOnline, long freeDiskSpace) {
long difference = diff;
if (difference < TimeUnit.SECONDS.toNanos(1L)) { // No tick count above 20
difference = TimeUnit.SECONDS.toNanos(1L);
@ -91,13 +83,31 @@ public class BukkitTPSCountTimer extends TPSCountTimer {
long twentySeconds = TimeUnit.SECONDS.toNanos(20L);
while (difference > twentySeconds) {
// Add 0 TPS since more than 20 ticks has passed.
history.add(new TPS(now, 0, playersOnline, cpuUsage, usedMemory, entityCount, chunksLoaded));
history.add(TPSBuilder.get()
.date(now)
.tps(0)
.playersOnline(playersOnline)
.usedCPU(cpuUsage)
.usedMemory(usedMemory)
.entities(entityCount)
.chunksLoaded(chunksLoaded)
.freeDiskSpace(freeDiskSpace)
.toTPS());
difference -= twentySeconds;
}
double tpsN = twentySeconds * 1.0 / difference;
return new TPS(now, tpsN, playersOnline, cpuUsage, usedMemory, entityCount, chunksLoaded);
return TPSBuilder.get()
.date(now)
.tps(0)
.playersOnline(playersOnline)
.usedCPU(cpuUsage)
.usedMemory(usedMemory)
.entities(entityCount)
.chunksLoaded(chunksLoaded)
.freeDiskSpace(freeDiskSpace)
.toTPS();
}
/**

View File

@ -2,6 +2,7 @@ package com.djrapitops.plan.system.tasks.server.bukkit;
import com.djrapitops.plan.Plan;
import com.djrapitops.plan.data.container.TPS;
import com.djrapitops.plan.data.container.builders.TPSBuilder;
import com.djrapitops.plan.system.info.server.properties.ServerProperties;
import com.djrapitops.plan.system.processing.Processing;
import com.djrapitops.plan.system.processing.processors.Processors;
@ -26,19 +27,28 @@ public class PaperTPSCountTimer extends BukkitTPSCountTimer {
}
@Override
protected TPS getTPS(long diff, long now, double cpuUsage, long usedMemory, int entityCount, int chunksLoaded, int playersOnline) {
protected TPS getTPS(long diff, long now, double cpuUsage, long usedMemory, int entityCount, int chunksLoaded, int playersOnline, long freeDiskSpace) {
double tps;
try {
tps = plugin.getServer().getTPS()[0];
} catch (NoSuchMethodError e) {
return super.getTPS(diff, now, cpuUsage, usedMemory, entityCount, chunksLoaded, playersOnline);
return super.getTPS(diff, now, cpuUsage, usedMemory, entityCount, chunksLoaded, playersOnline, freeDiskSpace);
}
if (tps > 20) {
tps = 20;
}
return new TPS(now, tps, playersOnline, cpuUsage, usedMemory, entityCount, chunksLoaded);
return TPSBuilder.get()
.date(now)
.tps(tps)
.playersOnline(playersOnline)
.usedCPU(cpuUsage)
.usedMemory(usedMemory)
.entities(entityCount)
.chunksLoaded(chunksLoaded)
.freeDiskSpace(freeDiskSpace)
.toTPS();
}
@Override

View File

@ -66,6 +66,7 @@ public class SpongeTPSCountTimer extends TPSCountTimer {
latestPlayersOnline = playersOnline;
int loadedChunks = -1; // getLoadedChunks();
int entityCount = getEntityCount();
long freeDiskSpace = getFreeDiskSpace();
return TPSBuilder.get()
.date(now)
@ -75,6 +76,7 @@ public class SpongeTPSCountTimer extends TPSCountTimer {
.usedMemory(usedMemory)
.entities(entityCount)
.chunksLoaded(loadedChunks)
.freeDiskSpace(freeDiskSpace)
.toTPS();
}

View File

@ -173,6 +173,7 @@ public class HtmlExport extends SpecificExport {
"web/js/charts/playerGraph.js",
"web/js/charts/playerGraphNoNav.js",
"web/js/charts/resourceGraph.js",
"web/js/charts/diskGraph.js",
"web/js/charts/tpsGraph.js",
"web/js/charts/worldGraph.js",
"web/js/charts/worldMap.js",

View File

@ -0,0 +1,17 @@
package com.djrapitops.plan.utilities.html.graphs.line;
import com.djrapitops.plan.data.store.mutators.TPSMutator;
/**
* Graph about Disk Usage gathered by TPSCountTimer.
*
* @author Rsl1122
* @see com.djrapitops.plan.system.tasks.TPSCountTimer
* @since 4.5.0
*/
class DiskGraph extends LineGraph {
DiskGraph(TPSMutator mutator, boolean displayGaps) {
super(mutator.freeDiskPoints(), displayGaps);
}
}

View File

@ -57,4 +57,8 @@ public class LineGraphFactory {
public LineGraph tpsGraph(TPSMutator mutator) {
return new TPSGraph(mutator, config.isTrue(Settings.DISPLAY_GAPS_IN_GRAPH_DATA));
}
public LineGraph diskGraph(TPSMutator mutator) {
return new DiskGraph(mutator, config.isTrue(Settings.DISPLAY_GAPS_IN_GRAPH_DATA));
}
}

View File

@ -50,6 +50,7 @@ public class AnalysisPage implements Page {
placeholderReplacer.addAllPlaceholdersFrom(analysisContainer,
VERSION, SERVER_NAME, TIME_ZONE,
FIRST_DAY, TPS_MEDIUM, TPS_HIGH,
DISK_MEDIUM, DISK_HIGH,
PLAYERS_MAX, PLAYERS_ONLINE, PLAYERS_TOTAL,
WORLD_PIE_COLORS, GM_PIE_COLORS, ACTIVITY_PIE_COLORS,
@ -163,7 +164,8 @@ public class AnalysisPage implements Page {
ACTIVITY_PIE_SERIES, CALENDAR_SERIES,
UNIQUE_PLAYERS_SERIES, NEW_PLAYERS_SERIES,
COUNTRY_CATEGORIES, COUNTRY_SERIES,
AVG_PING_SERIES, MAX_PING_SERIES, MIN_PING_SERIES
AVG_PING_SERIES, MAX_PING_SERIES, MIN_PING_SERIES,
DISK_SERIES
);
timings.end(CHANNEL, CHANNEL + " Chart Series");
}

View File

@ -116,33 +116,6 @@ Theme:
Font:
FontStyleSheet: https://fonts.googleapis.com/css?family=Quicksand:300,400
FontFamily: "'Quicksand', sans-serif"
Color:
Dark: Base
Light: Base
Colors:
Main: Base
Main-Dark: Base
Secondary: Base
Secondary-Dark: Base
Tertiary: Base
Background: Base
Table-Light: Base
Table-Dark: Base
Graphs:
PunchCard: Base
PlayersOnline: Base
TPS:
High: Base
Medium: Base
Low: Base
CPU: Base
RAM: Base
Chunks: Base
Entities: Base
WorldPie: '"#438c99", "#639A67", "#D8EBB5", "#D9BF77", "#0099C6", "#66AA00", "#316395", "#994499", "#22AA99", "#AAAA11", "#6633CC", "#E67300", "#329262", "#5574A6"'
ActivityPie: '"#228B22", "#A9A9A9", "#808080", "#951800"'
ServerPreferencePie: '"#0099C6", "#66AA00", "#316395", "#994499", "#22AA99", "#AAAA11", "#6633CC", "#E67300", "#329262", "#5574A6"'
# -----------------------------------------------------
Servers:
Example:

View File

@ -138,6 +138,10 @@ Theme:
TPS:
High-Threshold: 18
Medium-Threshold: 10
# Free Disk space thresholds, in megabytes.
Disk:
High-Threshold: 500
Medium-Threshold: 100
# -----------------------------------------------------
Plugins:
Factions:

View File

@ -332,4 +332,6 @@ Health - Regular Activity Change Zero || stayed the same (+${0})
Health - Regular Activity Remain || ${0} of regular players have remained active (${1}/${2})
Health - Single Servers Inaccuracy || Single Bukkit/Sponge server to gather session data.
Health - TPS Above Low Threshold || Average TPS was above Low Threshold ${0} of the time
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
HTML - FREE_DISK_SPACE || Free Disk Space
HTML - DISK_SPACE || DISK SPACE

View File

@ -331,4 +331,6 @@ Health - Regular Activity Change Zero || stayed the same (+${0})
Health - Regular Activity Remain || ${0} of regular players have remained active (${1}/${2})
Health - Single Servers Inaccuracy || Single Bukkit/Sponge server to gather session data.
Health - TPS Above Low Threshold || Average TPS was above Low Threshold ${0} of the time
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
HTML - FREE_DISK_SPACE || Free Disk Space
HTML - DISK_SPACE || DISK SPACE

View File

@ -331,4 +331,6 @@ Health - Regular Activity Change Zero || stayed the same (+${0})
Health - Regular Activity Remain || ${0} of regular players have remained active (${1}/${2})
Health - Single Servers Inaccuracy || Single Bukkit/Sponge server to gather session data.
Health - TPS Above Low Threshold || Average TPS was above Low Threshold ${0} of the time
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
HTML - FREE_DISK_SPACE || Free Disk Space
HTML - DISK_SPACE || DISK SPACE

View File

@ -331,4 +331,6 @@ Health - Regular Activity Change Zero || stayed the same (+${0})
Health - Regular Activity Remain || ${0} of regular players have remained active (${1}/${2})
Health - Single Servers Inaccuracy || Single Bukkit/Sponge server to gather session data.
Health - TPS Above Low Threshold || Average TPS was above Low Threshold ${0} of the time
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
HTML - FREE_DISK_SPACE || Free Disk Space
HTML - DISK_SPACE || DISK SPACE

View File

@ -330,4 +330,6 @@ Health - Regular Activity Change Zero || pysynyt samana (+${0})
Health - Regular Activity Remain || ${0} kestopelaajista on pysynyt aktiivisena (${1}/${2})
Health - Single Servers Inaccuracy || Yksi Bukkit/Sponge palvelin sessio tietojen keräykseen.
Health - TPS Above Low Threshold || Keskimääräinen TPS oli alarajan yläpuolella ${0} ajasta
Health - TPS Low Dips || Keskimääräinen TPS putosi alarajan alapuolelle (${0}) ${1} kertaa
Health - TPS Low Dips || Keskimääräinen TPS putosi alarajan alapuolelle (${0}) ${1} kertaa
HTML - FREE_DISK_SPACE || Vapaa Levytila
HTML - DISK_SPACE || LEVYTILA

View File

@ -331,4 +331,6 @@ Health - Regular Activity Change Zero || stayed the same (+${0})
Health - Regular Activity Remain || ${0} of regular players have remained active (${1}/${2})
Health - Single Servers Inaccuracy || Single Bukkit/Sponge server to gather session data.
Health - TPS Above Low Threshold || Average TPS was above Low Threshold ${0} of the time
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
HTML - FREE_DISK_SPACE || Free Disk Space
HTML - DISK_SPACE || DISK SPACE

View File

@ -331,4 +331,6 @@ Health - Regular Activity Change Zero || stayed the same (+${0})
Health - Regular Activity Remain || ${0} of regular players have remained active (${1}/${2})
Health - Single Servers Inaccuracy || Single Bukkit/Sponge server to gather session data.
Health - TPS Above Low Threshold || Average TPS was above Low Threshold ${0} of the time
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
HTML - FREE_DISK_SPACE || Free Disk Space
HTML - DISK_SPACE || DISK SPACE

View File

@ -331,4 +331,6 @@ Health - Regular Activity Change Zero || stayed the same (+${0})
Health - Regular Activity Remain || ${0} of regular players have remained active (${1}/${2})
Health - Single Servers Inaccuracy || Single Bukkit/Sponge server to gather session data.
Health - TPS Above Low Threshold || Average TPS was above Low Threshold ${0} of the time
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
HTML - FREE_DISK_SPACE || Free Disk Space
HTML - DISK_SPACE || DISK SPACE

View File

@ -331,4 +331,6 @@ Health - Regular Activity Change Zero || stayed the same (+${0})
Health - Regular Activity Remain || ${0} of regular players have remained active (${1}/${2})
Health - Single Servers Inaccuracy || Single Bukkit/Sponge server to gather session data.
Health - TPS Above Low Threshold || Average TPS was above Low Threshold ${0} of the time
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
HTML - FREE_DISK_SPACE || Free Disk Space
HTML - DISK_SPACE || DISK SPACE

View File

@ -331,4 +331,6 @@ Health - Regular Activity Change Zero || stayed the same (+${0})
Health - Regular Activity Remain || ${0} of regular players have remained active (${1}/${2})
Health - Single Servers Inaccuracy || Single Bukkit/Sponge server to gather session data.
Health - TPS Above Low Threshold || Average TPS was above Low Threshold ${0} of the time
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
HTML - FREE_DISK_SPACE || Free Disk Space
HTML - DISK_SPACE || DISK SPACE

View File

@ -331,4 +331,6 @@ Health - Regular Activity Change Zero || stayed the same (+${0})
Health - Regular Activity Remain || ${0} of regular players have remained active (${1}/${2})
Health - Single Servers Inaccuracy || Single Bukkit/Sponge server to gather session data.
Health - TPS Above Low Threshold || Average TPS was above Low Threshold ${0} of the time
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
HTML - FREE_DISK_SPACE || Free Disk Space
HTML - DISK_SPACE || DISK SPACE

View File

@ -331,4 +331,6 @@ Health - Regular Activity Change Zero || stayed the same (+${0})
Health - Regular Activity Remain || ${0} of regular players have remained active (${1}/${2})
Health - Single Servers Inaccuracy || Single Bukkit/Sponge server to gather session data.
Health - TPS Above Low Threshold || Average TPS was above Low Threshold ${0} of the time
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
Health - TPS Low Dips || Average TPS dropped below Low Threshold (${0}) ${1} times
HTML - FREE_DISK_SPACE || Free Disk Space
HTML - DISK_SPACE || DISK SPACE

View File

@ -0,0 +1,41 @@
function diskChart(id, series) {
Highcharts.stockChart(id, {
rangeSelector: {
selected: 2,
buttons: [{
type: 'hour',
count: 12,
text: '12h'
}, {
type: 'hour',
count: 24,
text: '24h'
}, {
type: 'day',
count: 7,
text: '7d'
}, {
type: 'month',
count: 1,
text: '30d'
}, {
type: 'all',
text: 'All'
}]
},
yAxis: {
labels: {
formatter: function () {
return this.value + ' Mb';
}
},
softMax: 2,
softMin: 0
},
title: {text: ''},
legend: {
enabled: true
},
series: series
});
}

View File

@ -48,7 +48,7 @@ function resourceChart(id, cpuSeries, ramSeries, playersOnlineSeries) {
}, {
labels: {
formatter: function () {
return this.value + ' MB';
return this.value + ' Mb';
}
}
}],

View File

@ -838,6 +838,9 @@
<li role="presentation"><a href="#ping" data-toggle="tab"><i
class="fa fa-signal"></i>
PING</a></li>
<li role="presentation"><a href="#disk" data-toggle="tab"><i
class="fa fa-hdd"></i>
DISK SPACE</a></li>
</ul>
</div>
</div>
@ -859,6 +862,9 @@
<div role="tabpanel" class="tab-pane fade" id="ping">
<div id="pingGraph" style="height: 500px;"></div>
</div>
<div role="tabpanel" class="tab-pane fade" id="disk">
<div id="diskGraph" style="height: 500px;"></div>
</div>
</div>
</div>
</div>
@ -1163,6 +1169,7 @@
<script src="js/charts/performanceGraph.js"></script>
<script src="js/charts/tpsGraph.js"></script>
<script src="js/charts/resourceGraph.js"></script>
<script src="js/charts/diskGraph.js"></script>
<script src="js/charts/worldGraph.js"></script>
<script src="js/charts/worldMap.js"></script>
<script src="js/charts/onlineActivityCalendar.js"></script>
@ -1199,6 +1206,8 @@
values: {
tpsMed: ${tpsMedium},
tpsHigh: ${tpsHigh},
diskMed: ${diskMedium},
diskHigh: ${diskHigh},
firstDay: ${firstDay}
},
data: {
@ -1223,7 +1232,8 @@
country: ${countrySeries},
avgPing: ${avgPingSeries},
maxPing: ${maxPingSeries},
minPing: ${minPingSeries}
minPing: ${minPingSeries},
disk: ${diskSeries}
}
};
@ -1235,12 +1245,13 @@
newPlayers: 'New Players',
tps: 'TPS',
cpu: 'CPU Usage (%)',
ram: 'RAM Usage (MB)',
ram: 'RAM Usage (Mb)',
entities: 'Loaded Entities',
chunks: 'Loaded Chunks',
maxPing: 'Worst Ping',
minPing: 'Best Ping',
avgPing: 'Average Ping'
avgPing: 'Average Ping',
disk: 'Free Disk Space (Mb)'
},
tooltip: {
twoDecimals: {
@ -1264,6 +1275,16 @@
}, {
value: 30,
color: v.colors.tpsHigh
}],
disk: [{
value: v.values.diskMed,
color: v.colors.tpsLow
}, {
value: v.values.diskHigh,
color: v.colors.tpsMed
}, {
value: Number.MAX_VALUE,
color: v.colors.tpsHigh
}]
}
};
@ -1383,6 +1404,13 @@
color: v.colors.chunks,
yAxis: 2
},
disk: {
name: s.name.disk,
type: s.type.spline,
zones: s.zones.disk,
tooltip: s.tooltip.zeroDecimals,
data: v.data.disk
},
activityPie: {
name: 'Players',
colorByPoint: true,
@ -1461,6 +1489,7 @@
onlineActivityCalendar('#calendar', v.data.calendar, v.values.firstDay);
horizontalBarChart('countryBarChart', v.data.countryCategories, [series.country], 'Players');
lineChart('pingGraph', [series.avgPing, series.maxPing, series.minPing]);
diskChart('diskGraph', [series.disk]);
${sessionTabGraphViewFunctions}
/**/

View File

@ -40,6 +40,7 @@ public class TPSMutatorTest {
.usedMemory(0)
.entities(0)
.chunksLoaded(0)
.freeDiskSpace(0)
.toTPS()
);
}
@ -63,6 +64,7 @@ public class TPSMutatorTest {
.usedMemory(0)
.entities(0)
.chunksLoaded(0)
.freeDiskSpace(0)
.toTPS()
)).serverDownTime();
assertEquals(expected, result);

View File

@ -37,6 +37,7 @@ import utilities.RandomData;
import utilities.TestConstants;
import utilities.mocks.PlanBukkitMocker;
import java.io.File;
import java.lang.management.ManagementFactory;
import java.lang.management.OperatingSystemMXBean;
import java.lang.reflect.Field;
@ -209,7 +210,7 @@ public class SQLiteTest {
List<TPS> expected = new ArrayList<>();
for (int i = 0; i < RandomData.randomInt(1, 5); i++) {
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), r.nextDouble(), r.nextLong(), r.nextInt(), r.nextInt()));
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), r.nextDouble(), r.nextLong(), r.nextInt(), r.nextInt(), r.nextLong()));
}
for (TPS tps : expected) {
@ -631,14 +632,15 @@ public class SQLiteTest {
Random r = new Random();
OperatingSystemMXBean operatingSystemMXBean = ManagementFactory.getOperatingSystemMXBean();
int availableProcessors = ManagementFactory.getOperatingSystemMXBean().getAvailableProcessors();
final double averageCPUUsage = operatingSystemMXBean.getSystemLoadAverage() / availableProcessors * 100.0;
final long usedMemory = 51231251254L;
final int entityCount = 6123;
final int chunksLoaded = 2134;
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), averageCPUUsage, usedMemory, entityCount, chunksLoaded));
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), averageCPUUsage, usedMemory, entityCount, chunksLoaded));
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), averageCPUUsage, usedMemory, entityCount, chunksLoaded));
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), averageCPUUsage, usedMemory, entityCount, chunksLoaded));
double averageCPUUsage = operatingSystemMXBean.getSystemLoadAverage() / availableProcessors * 100.0;
long usedMemory = 51231251254L;
int entityCount = 6123;
int chunksLoaded = 2134;
long freeDiskSpace = new File("").getUsableSpace();
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), averageCPUUsage, usedMemory, entityCount, chunksLoaded, freeDiskSpace));
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), averageCPUUsage, usedMemory, entityCount, chunksLoaded, freeDiskSpace));
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), averageCPUUsage, usedMemory, entityCount, chunksLoaded, freeDiskSpace));
expected.add(new TPS(r.nextLong(), r.nextDouble(), r.nextInt(100000000), averageCPUUsage, usedMemory, entityCount, chunksLoaded, freeDiskSpace));
for (TPS tps : expected) {
tpsTable.insertTPS(tps);
}

View File

@ -70,7 +70,7 @@ public class ImportBuilderTest {
public void serverDataBuilderConstructsCorrectItem() {
ServerImportData.ServerImportDataBuilder builder = ServerImportData.builder();
TPS tps = new TPS(randomInt, randomInt, randomInt, randomInt, randomInt, randomInt, randomInt);
TPS tps = new TPS(randomInt, randomInt, randomInt, randomInt, randomInt, randomInt, randomInt, randomInt);
ServerImportData data = builder.tpsData(tps)
.tpsData(tps)

View File

@ -23,7 +23,7 @@ public class LineGraphTest {
@Before
public void setUp() {
for (int i = 0; i < 10; i++) {
tpsList.add(new TPS(i, i, i, i, i, i, i));
tpsList.add(new TPS(i, i, i, i, i, i, i, i));
}
}
@ -36,7 +36,8 @@ public class LineGraphTest {
new RamGraph(mutator, true),
new TPSGraph(mutator, false),
new EntityGraph(mutator, true),
new ChunkGraph(mutator, false)
new ChunkGraph(mutator, false),
new DiskGraph(mutator, false)
};
for (LineGraph graph : graphs) {

View File

@ -40,7 +40,7 @@ public class RandomData {
for (int i = 0; i < 20; i++) {
int randInt = r.nextInt();
long randLong = r.nextLong();
test.add(new TPS(randLong, randLong, randInt, randLong, randLong, randInt, randInt));
test.add(new TPS(randLong, randLong, randInt, randLong, randLong, randInt, randInt, randLong));
}
return test;
}