Added account metric for Minetest.

This commit is contained in:
Christian P. MOMON 2022-03-08 01:49:46 +01:00
parent 87a6a15f10
commit f7efce5c4f
3 changed files with 42 additions and 33 deletions

View file

@ -88,6 +88,7 @@ public class GiteaProber
SQLDatabase database = new SQLDatabase(databaseConfig.getUrl(), databaseConfig.getUser(), databaseConfig.getPassword()); SQLDatabase database = new SQLDatabase(databaseConfig.getUrl(), databaseConfig.getUser(), databaseConfig.getPassword());
database.open(); database.open();
result.putAll(DatabaseProber.probe(database)); result.putAll(DatabaseProber.probe(database));
database.close();
} }
else else
{ {

View file

@ -73,7 +73,10 @@ public class MinetestProber
result = MinetestLogAnalyzer.probe(logs); result = MinetestLogAnalyzer.probe(logs);
// metrics.service.database.bytes // metrics.service.database.bytes
// metrics.service.accounts
{
long databaseSize = 0; long databaseSize = 0;
StringList timemarks = result.getNowTimeMarks();
try try
{ {
System.out.println("Probing database [" + playerDatabaseConfig.getUrl() + "]"); System.out.println("Probing database [" + playerDatabaseConfig.getUrl() + "]");
@ -82,6 +85,13 @@ public class MinetestProber
SQLDatabase database = new SQLDatabase(playerDatabaseConfig.getUrl(), playerDatabaseConfig.getUser(), playerDatabaseConfig.getPassword()); SQLDatabase database = new SQLDatabase(playerDatabaseConfig.getUrl(), playerDatabaseConfig.getUser(), playerDatabaseConfig.getPassword());
database.open(); database.open();
databaseSize += database.getDatabaseSize(); databaseSize += database.getDatabaseSize();
// metrics.service.accounts
long accountCount = database.queryNumber("select count(*) from player;");
result.set(accountCount, "metrics.service.accounts", timemarks);
//
database.close();
} }
else else
{ {
@ -103,6 +113,7 @@ public class MinetestProber
SQLDatabase database = new SQLDatabase(worldDatabaseConfig.getUrl(), worldDatabaseConfig.getUser(), worldDatabaseConfig.getPassword()); SQLDatabase database = new SQLDatabase(worldDatabaseConfig.getUrl(), worldDatabaseConfig.getUser(), worldDatabaseConfig.getPassword());
database.open(); database.open();
databaseSize += database.getDatabaseSize(); databaseSize += database.getDatabaseSize();
database.close();
} }
else else
{ {
@ -115,12 +126,9 @@ public class MinetestProber
} }
} }
StringList timemarks = result.getNowTimeMarks();
result.set(databaseSize, "metrics.service.database.bytes", timemarks);
// result.putAll(MumbleDatabaseAnalyzer.probe());
// metrics.service.accounts
// metrics.service.database.bytes // metrics.service.database.bytes
result.set(databaseSize, "metrics.service.database.bytes", timemarks);
}
// metrics.service.files.bytes // metrics.service.files.bytes

View file

@ -355,7 +355,7 @@ public class SQLDatabase
this.connection = DriverManager.getConnection(this.url, this.login, this.password); this.connection = DriverManager.getConnection(this.url, this.login, this.password);
this.status = Status.OPENED; this.status = Status.OPENED;
logger.info("Single connection opened with [{}].", this.url); logger.info("Single connection opened with [{}].", this.url);
} }
} }
catch (ClassNotFoundException exception) catch (ClassNotFoundException exception)