Initial Commit

Initial commit of project.
This commit is contained in:
Alex Stewart
2019-03-09 01:21:44 -08:00
parent e54e9653ed
commit 13420951b1
124 changed files with 5883 additions and 0 deletions
+66
View File
@@ -0,0 +1,66 @@
package commands;
import core.Command;
import core.CommandManager.ThreadData;
import dataStructures.KittyChannel;
import dataStructures.KittyGuild;
import dataStructures.KittyRating;
import dataStructures.KittyRole;
import dataStructures.KittyUser;
import dataStructures.Response;
import dataStructures.UserInput;
import core.Stats;
public class CommandStats extends Command
{
public CommandStats(KittyRole level, KittyRating rating) { super(level, rating); }
@Override
public String HelpText() { return "Displays the actively running KittyBot application information"; }
// Called when the command is run!
@Override
public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res)
{
String out = "```\n";
Stats stats = Stats.instance;
out += "----- [General] -----\n";
out += " Messages observed: " + stats.GetMessagesSeen() + "\n";
out += "Commands processed: " + stats.GetCommandsProcessed() + "\n";
out += " KittyBot uptime: " + stats.GetFormattedUptime() + "\n";
out += "\n";
out += "----- [Health] -----\n";
out += " SMT cores: " + stats.GetCPUAvailable() + "\n";
// If CPU load works on this OS, list it.
double CPULoad = stats.GetSystemCPULoad();
if(CPULoad > -0.9) // -1.0 is the error state
out += "System CPU Load: " + (CPULoad * 100) + "%\n";
ThreadData data = stats.GetThreadData();
Integer terminated = data.states.get(Thread.State.TERMINATED);
Integer runnable = data.states.get(Thread.State.RUNNABLE);
Integer blocked = data.states.get(Thread.State.BLOCKED);
Integer timed_waiting = data.states.get(Thread.State.TIMED_WAITING);
Integer waiting = data.states.get(Thread.State.WAITING);
out += " Child threads:"
+ " run: " + (runnable == null ? 0 : runnable)
+ " block: " + (blocked == null ? 0 : blocked)
+ " sleep: " + (timed_waiting == null ? 0 : timed_waiting)
+ " wait: " + (waiting == null ? 0 : waiting)
+ " term: " + (terminated == null ? 0 : terminated)
+ "\n";
Integer guildCount = stats.GetGuildCount();
Integer userCount = stats.GetUserCount();
out += "\n----- [Counts] -----\n"
+ "Guilds: " + guildCount + "\n"
+ " Users: " + userCount;
out += "\n```";
res.Call(out);
}
}