Add experimental "show grid users online" console command to show grid users online from a standalone/robust instance.

This is not guaranteed to be accurate since users may be left "online" in certain situations.
For example, if a simulator crashes and they never login/logout again.
To counter this somewhat, only users continuously online for less than 5 days are shown.
This commit is contained in:
Justin Clark-Casey (justincc)
2013-09-03 00:04:12 +01:00
parent 857f24a5e2
commit 4035badd20
2 changed files with 43 additions and 4 deletions

View File

@@ -47,6 +47,45 @@ namespace OpenSim.Services.UserAccountService
public GridUserService(IConfigSource config) : base(config)
{
m_log.Debug("[GRID USER SERVICE]: Starting user grid service");
MainConsole.Instance.Commands.AddCommand(
"Users", false,
"show grid users online",
"show grid users online",
"Show number of grid users registered as online.",
"This number may not be accurate as a region may crash or not be cleanly shutdown and leave grid users shown as online\n."
+ "For this reason, users online for more than 5 days are not currently counted",
HandleShowGridUsersOnline);
}
protected void HandleShowGridUsersOnline(string module, string[] cmdparams)
{
// if (cmdparams.Length != 4)
// {
// MainConsole.Instance.Output("Usage: show grid users online");
// return;
// }
// int onlineCount;
int onlineRecentlyCount = 0;
DateTime now = DateTime.UtcNow;
foreach (GridUserData gu in m_Database.GetAll(""))
{
if (bool.Parse(gu.Data["Online"]))
{
// onlineCount++;
int unixLoginTime = int.Parse(gu.Data["Login"]);
DateTime loginDateTime = Util.UnixEpoch.AddSeconds(unixLoginTime);
if ((loginDateTime - now).Days < 5)
onlineRecentlyCount++;
}
}
MainConsole.Instance.OutputFormat("Users online within last 5 days: {0}", onlineRecentlyCount);
}
public virtual GridUserInfo GetGridUserInfo(string userID)