Added config setting to disable disk gathering

'Data_gathering.Disk_space' default 'true'

Also fixed all performance average calculations where -1
might be present

Affects issues:
- Close #1360
This commit is contained in:
Risto Lahtela 2020-03-13 10:28:47 +02:00
parent d6e920c31d
commit 154cfc4a2b
7 changed files with 23 additions and 2 deletions

View File

@ -20,6 +20,8 @@ import com.djrapitops.plan.gathering.ServerSensor;
import com.djrapitops.plan.gathering.SystemUsage;
import com.djrapitops.plan.gathering.domain.builders.TPSBuilder;
import com.djrapitops.plan.identification.ServerInfo;
import com.djrapitops.plan.settings.config.PlanConfig;
import com.djrapitops.plan.settings.config.paths.DataGatheringSettings;
import com.djrapitops.plan.storage.database.DBSystem;
import com.djrapitops.plan.storage.database.transactions.events.TPSStoreTransaction;
import com.djrapitops.plan.utilities.analysis.Average;
@ -50,12 +52,13 @@ public class ProxyTPSCounter extends TPSCounter {
@Inject
public ProxyTPSCounter(
ServerSensor<Object> serverSensor,
PlanConfig config,
DBSystem dbSystem,
ServerInfo serverInfo,
PluginLogger logger,
ErrorHandler errorHandler
) {
super(logger, errorHandler);
super(config.get(DataGatheringSettings.DISK_SPACE), logger, errorHandler);
this.serverSensor = serverSensor;
this.dbSystem = dbSystem;

View File

@ -20,6 +20,8 @@ import com.djrapitops.plan.gathering.ServerSensor;
import com.djrapitops.plan.gathering.SystemUsage;
import com.djrapitops.plan.gathering.domain.builders.TPSBuilder;
import com.djrapitops.plan.identification.ServerInfo;
import com.djrapitops.plan.settings.config.PlanConfig;
import com.djrapitops.plan.settings.config.paths.DataGatheringSettings;
import com.djrapitops.plan.storage.database.DBSystem;
import com.djrapitops.plan.storage.database.transactions.events.TPSStoreTransaction;
import com.djrapitops.plan.utilities.analysis.Average;
@ -54,12 +56,13 @@ public class ServerTPSCounter<W> extends TPSCounter {
@Inject
public ServerTPSCounter(
ServerSensor<W> serverSensor,
PlanConfig config,
DBSystem dbSystem,
ServerInfo serverInfo,
PluginLogger logger,
ErrorHandler errorHandler
) {
super(logger, errorHandler);
super(config.get(DataGatheringSettings.DISK_SPACE), logger, errorHandler);
noDirectTPS = !serverSensor.supportsDirectTPS();
this.serverSensor = serverSensor;

View File

@ -29,15 +29,18 @@ import com.djrapitops.plugin.task.AbsRunnable;
*/
public abstract class TPSCounter extends AbsRunnable {
private boolean gatherDiskSpace;
protected final PluginLogger logger;
protected final ErrorHandler errorHandler;
private boolean diskErrored = false;
public TPSCounter(
boolean gatherDiskSpace,
PluginLogger logger,
ErrorHandler errorHandler
) {
this.gatherDiskSpace = gatherDiskSpace;
this.logger = logger;
this.errorHandler = errorHandler;
@ -64,6 +67,7 @@ public abstract class TPSCounter extends AbsRunnable {
public abstract void pulse();
protected long getFreeDiskSpace() {
if (!gatherDiskSpace) return -1;
try {
return SystemUsage.getFreeDiskSpace();
} catch (SecurityException noPermission) {

View File

@ -29,6 +29,7 @@ public class DataGatheringSettings {
public static final Setting<Boolean> GEOLOCATIONS = new BooleanSetting("Data_gathering.Geolocations");
public static final Setting<Boolean> ACCEPT_GEOLITE2_EULA = new BooleanSetting("Data_gathering.Accept_GeoLite2_EULA");
public static final Setting<Boolean> PING = new BooleanSetting("Data_gathering.Ping");
public static final Setting<Boolean> DISK_SPACE = new BooleanSetting("Data_gathering.Disk_space");
public static final Setting<Boolean> LOG_UNKNOWN_COMMANDS = new BooleanSetting("Data_gathering.Commands.Log_unknown");
public static final Setting<Boolean> COMBINE_COMMAND_ALIASES = new BooleanSetting("Data_gathering.Commands.Log_aliases_as_main_command");

View File

@ -237,6 +237,7 @@ public class TPSQueries {
public static Query<Double> averageTPS(long after, long before, UUID serverUUID) {
String sql = SELECT + "AVG(" + TPS + ") as average" + FROM + TABLE_NAME +
WHERE + SERVER_ID + '=' + ServerTable.STATEMENT_SELECT_SERVER_ID +
AND + TPS + ">=0" +
AND + DATE + "<?" +
AND + DATE + ">?";
return new QueryStatement<Double>(sql) {
@ -257,6 +258,7 @@ public class TPSQueries {
public static Query<Double> averageCPU(long after, long before, UUID serverUUID) {
String sql = SELECT + "AVG(" + CPU_USAGE + ") as average" + FROM + TABLE_NAME +
WHERE + SERVER_ID + '=' + ServerTable.STATEMENT_SELECT_SERVER_ID +
AND + CPU_USAGE + ">=0" +
AND + DATE + "<?" +
AND + DATE + ">?";
return new QueryStatement<Double>(sql) {
@ -277,6 +279,7 @@ public class TPSQueries {
public static Query<Long> averageRAM(long after, long before, UUID serverUUID) {
String sql = SELECT + "AVG(" + RAM_USAGE + ") as average" + FROM + TABLE_NAME +
WHERE + SERVER_ID + '=' + ServerTable.STATEMENT_SELECT_SERVER_ID +
AND + RAM_USAGE + ">=0" +
AND + DATE + "<?" +
AND + DATE + ">?";
return new QueryStatement<Long>(sql) {
@ -297,6 +300,7 @@ public class TPSQueries {
public static Query<Long> averageChunks(long after, long before, UUID serverUUID) {
String sql = SELECT + "AVG(" + CHUNKS + ") as average" + FROM + TABLE_NAME +
WHERE + SERVER_ID + '=' + ServerTable.STATEMENT_SELECT_SERVER_ID +
AND + CHUNKS + ">=0" +
AND + DATE + "<?" +
AND + DATE + ">?";
return new QueryStatement<Long>(sql) {
@ -317,6 +321,7 @@ public class TPSQueries {
public static Query<Long> averageEntities(long after, long before, UUID serverUUID) {
String sql = SELECT + "AVG(" + ENTITIES + ") as average" + FROM + TABLE_NAME +
WHERE + SERVER_ID + '=' + ServerTable.STATEMENT_SELECT_SERVER_ID +
AND + ENTITIES + ">=0" +
AND + DATE + "<?" +
AND + DATE + ">?";
return new QueryStatement<Long>(sql) {
@ -337,6 +342,7 @@ public class TPSQueries {
public static Query<Long> maxFreeDisk(long after, long before, UUID serverUUID) {
String sql = SELECT + "MAX(" + FREE_DISK + ") as free" + FROM + TABLE_NAME +
WHERE + SERVER_ID + '=' + ServerTable.STATEMENT_SELECT_SERVER_ID +
AND + FREE_DISK + ">=0" +
AND + DATE + "<?" +
AND + DATE + ">?";
return new QueryStatement<Long>(sql) {
@ -357,6 +363,7 @@ public class TPSQueries {
public static Query<Long> minFreeDisk(long after, long before, UUID serverUUID) {
String sql = SELECT + "MIN(" + FREE_DISK + ") as free" + FROM + TABLE_NAME +
WHERE + SERVER_ID + '=' + ServerTable.STATEMENT_SELECT_SERVER_ID +
AND + FREE_DISK + ">=0" +
AND + DATE + "<?" +
AND + DATE + ">?";
return new QueryStatement<Long>(sql) {
@ -377,6 +384,7 @@ public class TPSQueries {
public static Query<Long> averageFreeDisk(long after, long before, UUID serverUUID) {
String sql = SELECT + "AVG(" + FREE_DISK + ") as average" + FROM + TABLE_NAME +
WHERE + SERVER_ID + '=' + ServerTable.STATEMENT_SELECT_SERVER_ID +
AND + FREE_DISK + ">=0" +
AND + DATE + "<?" +
AND + DATE + ">?";
return new QueryStatement<Long>(sql) {

View File

@ -65,6 +65,7 @@ Data_gathering:
# https://www.maxmind.com/en/geolite2/eula
Accept_GeoLite2_EULA: false
Ping: true
Disk_space: true
# -----------------------------------------------------
# Supported time units: MILLISECONDS, SECONDS, MINUTES, HOURS, DAYS
# -----------------------------------------------------

View File

@ -67,6 +67,7 @@ Data_gathering:
# https://www.maxmind.com/en/geolite2/eula
Accept_GeoLite2_EULA: false
Ping: true
Disk_space: true
Commands:
Log_unknown: false
Log_aliases_as_main_command: true