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());
database.open();
result.putAll(DatabaseProber.probe(database));
database.close();
}
else
{

View file

@ -73,55 +73,63 @@ public class MinetestProber
result = MinetestLogAnalyzer.probe(logs);
// metrics.service.database.bytes
long databaseSize = 0;
try
{
System.out.println("Probing database [" + playerDatabaseConfig.getUrl() + "]");
if (playerDatabaseConfig.isSet())
{
SQLDatabase database = new SQLDatabase(playerDatabaseConfig.getUrl(), playerDatabaseConfig.getUser(), playerDatabaseConfig.getPassword());
database.open();
databaseSize += database.getDatabaseSize();
}
else
{
System.out.println("Minetest Players Database undefined.");
}
}
catch (SQLException exception)
{
logger.error("ERROR with database.", exception);
}
if (!StringUtils.equals(playerDatabaseConfig.getUrl(), worldDatabaseConfig.getUrl()))
// metrics.service.accounts
{
long databaseSize = 0;
StringList timemarks = result.getNowTimeMarks();
try
{
System.out.println("Probing database [" + worldDatabaseConfig.getUrl() + "]");
if (worldDatabaseConfig.isSet())
System.out.println("Probing database [" + playerDatabaseConfig.getUrl() + "]");
if (playerDatabaseConfig.isSet())
{
SQLDatabase database = new SQLDatabase(worldDatabaseConfig.getUrl(), worldDatabaseConfig.getUser(), worldDatabaseConfig.getPassword());
SQLDatabase database = new SQLDatabase(playerDatabaseConfig.getUrl(), playerDatabaseConfig.getUser(), playerDatabaseConfig.getPassword());
database.open();
databaseSize += database.getDatabaseSize();
// metrics.service.accounts
long accountCount = database.queryNumber("select count(*) from player;");
result.set(accountCount, "metrics.service.accounts", timemarks);
//
database.close();
}
else
{
System.out.println("Minetest Worlds Database undefined.");
System.out.println("Minetest Players Database undefined.");
}
}
catch (SQLException exception)
{
logger.error("ERROR with database.", exception);
}
if (!StringUtils.equals(playerDatabaseConfig.getUrl(), worldDatabaseConfig.getUrl()))
{
try
{
System.out.println("Probing database [" + worldDatabaseConfig.getUrl() + "]");
if (worldDatabaseConfig.isSet())
{
SQLDatabase database = new SQLDatabase(worldDatabaseConfig.getUrl(), worldDatabaseConfig.getUser(), worldDatabaseConfig.getPassword());
database.open();
databaseSize += database.getDatabaseSize();
database.close();
}
else
{
System.out.println("Minetest Worlds Database undefined.");
}
}
catch (SQLException exception)
{
logger.error("ERROR with database.", exception);
}
}
// metrics.service.database.bytes
result.set(databaseSize, "metrics.service.database.bytes", timemarks);
}
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.files.bytes
//

View file

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