Added timings capture and server log copy on server kill inside server monitor.
This commit is contained in:
parent
890c9d59e1
commit
921292a5c6
@ -16,6 +16,8 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@ -42,10 +44,12 @@ public class ServerMonitor
|
||||
private static Map<String, ServerGroup> _serverGroupMap = null;
|
||||
private static List<DedicatedServer> _dedicatedServers = null;
|
||||
private static HashSet<String> _deadServers = new HashSet<String>();
|
||||
private static HashSet<String> _delayedKill = new HashSet<String>();
|
||||
private static HashSet<String> _laggyServers = new HashSet<String>();
|
||||
|
||||
private static SimpleDateFormat _dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
|
||||
private static Logger _logger = Logger.getLogger("ServerMonitor");
|
||||
private static Timer _timer = new Timer();
|
||||
|
||||
private static int _totalPlayers = 0;
|
||||
private static Region _region;
|
||||
@ -124,12 +128,15 @@ public class ServerMonitor
|
||||
|
||||
for (MinecraftServer minecraftServer : _serverStatuses)
|
||||
{
|
||||
if (minecraftServer.getMotd().contains("Finished") || (minecraftServer.getGroup().equalsIgnoreCase("UltraHardcore") && minecraftServer.getMotd().contains("Restarting") && minecraftServer.getPlayerCount() == 0))
|
||||
if (!ignoreServer(minecraftServer.getGroup()))
|
||||
{
|
||||
killServer(minecraftServer.getName(), minecraftServer.getPublicAddress(), minecraftServer.getPlayerCount(), "[KILLED] [FINISHED] " + minecraftServer.getName() + ":" + minecraftServer.getPublicAddress(), true);
|
||||
|
||||
handleUserServerGroup(_serverGroupMap.get(minecraftServer.getGroup()));
|
||||
continue;
|
||||
if (minecraftServer.getMotd().contains("Finished") || (minecraftServer.getGroup().equalsIgnoreCase("UltraHardcore") && minecraftServer.getMotd().contains("Restarting") && minecraftServer.getPlayerCount() == 0))
|
||||
{
|
||||
killServer(minecraftServer.getName(), minecraftServer.getPublicAddress(), minecraftServer.getPlayerCount(), "[KILLED] [FINISHED] " + minecraftServer.getName() + ":" + minecraftServer.getPublicAddress(), true);
|
||||
|
||||
handleUserServerGroup(_serverGroupMap.get(minecraftServer.getGroup()));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (DedicatedServer server : _dedicatedServers)
|
||||
@ -202,6 +209,9 @@ public class ServerMonitor
|
||||
|
||||
for (ServerGroup groupStatus : _serverGroups)
|
||||
{
|
||||
if (ignoreServer(groupStatus.getName()))
|
||||
continue;
|
||||
|
||||
NautHashMap<Integer, MinecraftServer> serverMap = new NautHashMap<Integer, MinecraftServer>();
|
||||
|
||||
for (Iterator<MinecraftServer> serverIterator = groupStatus.getServers().iterator(); serverIterator.hasNext();)
|
||||
@ -226,17 +236,6 @@ public class ServerMonitor
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if (groupStatus.getHost() == null || groupStatus.getHost().isEmpty())
|
||||
{
|
||||
if (groupStatus.getName().startsWith("0"))
|
||||
{
|
||||
int serverCount = groupStatus.getServers().size();
|
||||
log(groupStatus.getName() + " : " + groupStatus.getPlayerCount() + " players on " + serverCount + " servers " + String.format("%.2f", ((double)serverCount * (double)groupStatus.getRequiredCpu() / totalCPU)) + "% CPU," + String.format("%.2f", ((double)serverCount * (double)groupStatus.getRequiredRam() / totalRAM)) + "% RAM", false);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
HashSet<String> onlineServers = new HashSet<String>();
|
||||
@ -386,21 +385,35 @@ public class ServerMonitor
|
||||
deadServers.addAll(_deadServers);
|
||||
|
||||
_deadServers.clear();
|
||||
for (MinecraftServer deadServer : _repository.getDeadServers())
|
||||
for (final MinecraftServer deadServer : _repository.getDeadServers())
|
||||
{
|
||||
if (deadServer.getUptime() <= 10 || ignoreServer(deadServer.getGroup()))
|
||||
continue;
|
||||
|
||||
if (_count == 0 || deadServers.contains(deadServer.getName()))
|
||||
{
|
||||
copyServerLog(deadServer);
|
||||
killServer(deadServer.getName(), deadServer.getPublicAddress(), deadServer.getPlayerCount(), "[KILLED] [DEAD] " + deadServer.getName() + ":" + deadServer.getPublicAddress(), true);
|
||||
|
||||
handleUserServerGroup(_serverGroupMap.get(deadServer.getGroup()));
|
||||
}
|
||||
else
|
||||
{
|
||||
_deadServers.add(deadServer.getName());
|
||||
log("[IMPENDING DEATH] : " + deadServer.getName() + ":" + deadServer.getPublicAddress());
|
||||
else if (!_delayedKill.contains(deadServer.getName()))
|
||||
{
|
||||
startTimingReport(deadServer);
|
||||
|
||||
_timer.schedule(new TimerTask()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_deadServers.add(deadServer.getName());
|
||||
_delayedKill.remove(deadServer.getName());
|
||||
|
||||
stopTimingReport(deadServer);
|
||||
log("[IMPENDING DEATH] : " + deadServer.getName() + ":" + deadServer.getPublicAddress());
|
||||
}
|
||||
}, 20 * 1000);
|
||||
|
||||
_delayedKill.add(deadServer.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -653,6 +666,105 @@ public class ServerMonitor
|
||||
killServer(serverToKill.getName(), serverToKill.getPublicAddress(), serverToKill.getPlayerCount(), message, true);
|
||||
}
|
||||
|
||||
private static void startTimingReport(final MinecraftServer server)
|
||||
{
|
||||
if (_debug)
|
||||
return;
|
||||
|
||||
String cmd = "/home/mineplex/remoteStartTiming.sh";
|
||||
|
||||
ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, server.getPublicAddress(), server.getName() });
|
||||
pr.start(new GenericRunnable<Boolean>()
|
||||
{
|
||||
public void run(Boolean error)
|
||||
{
|
||||
if (error)
|
||||
log("[TIMING START] Errored " + server.getName() + "(" + server.getPublicAddress() + ")");
|
||||
else
|
||||
log("[TIMING START] Succeeded " + server.getName() + "(" + server.getPublicAddress() + ")");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
pr.join(100);
|
||||
}
|
||||
catch (InterruptedException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
if (!pr.isDone())
|
||||
_processes.add(pr);
|
||||
}
|
||||
|
||||
private static void stopTimingReport(final MinecraftServer server)
|
||||
{
|
||||
if (_debug)
|
||||
return;
|
||||
|
||||
String cmd = "/home/mineplex/remoteStopTiming.sh";
|
||||
|
||||
ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, server.getPublicAddress(), server.getName() });
|
||||
pr.start(new GenericRunnable<Boolean>()
|
||||
{
|
||||
public void run(Boolean error)
|
||||
{
|
||||
if (error)
|
||||
log("[TIMING PASTE] Errored " + server.getName() + "(" + server.getPublicAddress() + ")");
|
||||
else
|
||||
log("[TIMING PASTE] Succeeded " + server.getName() + "(" + server.getPublicAddress() + ")");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
pr.join(100);
|
||||
}
|
||||
catch (InterruptedException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
if (!pr.isDone())
|
||||
_processes.add(pr);
|
||||
}
|
||||
|
||||
private static void copyServerLog(final MinecraftServer server)
|
||||
{
|
||||
if (_debug)
|
||||
return;
|
||||
|
||||
String cmd = "/home/mineplex/easyRemoteCopyLog.sh";
|
||||
|
||||
ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, server.getPublicAddress(), server.getName() });
|
||||
pr.start(new GenericRunnable<Boolean>()
|
||||
{
|
||||
public void run(Boolean error)
|
||||
{
|
||||
if (error)
|
||||
log("[COPY LOG] Errored " + server.getName() + "(" + server.getPublicAddress() + ")");
|
||||
else
|
||||
log("[COPY LOG] Succeeded " + server.getName() + "(" + server.getPublicAddress() + ")");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
try
|
||||
{
|
||||
pr.join(100);
|
||||
}
|
||||
catch (InterruptedException e1)
|
||||
{
|
||||
e1.printStackTrace();
|
||||
}
|
||||
|
||||
if (!pr.isDone())
|
||||
_processes.add(pr);
|
||||
}
|
||||
|
||||
private static void startServer(final DedicatedServer serverSpace, final ServerGroup serverGroup, final int serverNum, final boolean free)
|
||||
{
|
||||
if (_debug)
|
||||
|
Loading…
Reference in New Issue
Block a user