diff options
author | Justin Clark-Casey (justincc) | 2013-09-03 00:04:12 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-09-04 00:47:13 +0100 |
commit | 49228f9855d2cc6a524f91ff392740925c52d065 (patch) | |
tree | b7e8b364e0aa0a9ef377ea9840370a8e4dcd82f7 /OpenSim/Services/UserAccountService/GridUserService.cs | |
parent | Allow one to specify a DefaultHGRegion flag in [GridService] in order to allo... (diff) | |
download | opensim-SC_OLD-49228f9855d2cc6a524f91ff392740925c52d065.zip opensim-SC_OLD-49228f9855d2cc6a524f91ff392740925c52d065.tar.gz opensim-SC_OLD-49228f9855d2cc6a524f91ff392740925c52d065.tar.bz2 opensim-SC_OLD-49228f9855d2cc6a524f91ff392740925c52d065.tar.xz |
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.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Services/UserAccountService/GridUserService.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs index b1cdd45..f9cfa12 100644 --- a/OpenSim/Services/UserAccountService/GridUserService.cs +++ b/OpenSim/Services/UserAccountService/GridUserService.cs | |||
@@ -47,6 +47,45 @@ namespace OpenSim.Services.UserAccountService | |||
47 | public GridUserService(IConfigSource config) : base(config) | 47 | public GridUserService(IConfigSource config) : base(config) |
48 | { | 48 | { |
49 | m_log.Debug("[GRID USER SERVICE]: Starting user grid service"); | 49 | m_log.Debug("[GRID USER SERVICE]: Starting user grid service"); |
50 | |||
51 | MainConsole.Instance.Commands.AddCommand( | ||
52 | "Users", false, | ||
53 | "show grid users online", | ||
54 | "show grid users online", | ||
55 | "Show number of grid users registered as online.", | ||
56 | "This number may not be accurate as a region may crash or not be cleanly shutdown and leave grid users shown as online\n." | ||
57 | + "For this reason, users online for more than 5 days are not currently counted", | ||
58 | HandleShowGridUsersOnline); | ||
59 | } | ||
60 | |||
61 | protected void HandleShowGridUsersOnline(string module, string[] cmdparams) | ||
62 | { | ||
63 | // if (cmdparams.Length != 4) | ||
64 | // { | ||
65 | // MainConsole.Instance.Output("Usage: show grid users online"); | ||
66 | // return; | ||
67 | // } | ||
68 | |||
69 | // int onlineCount; | ||
70 | int onlineRecentlyCount = 0; | ||
71 | |||
72 | DateTime now = DateTime.UtcNow; | ||
73 | |||
74 | foreach (GridUserData gu in m_Database.GetAll("")) | ||
75 | { | ||
76 | if (bool.Parse(gu.Data["Online"])) | ||
77 | { | ||
78 | // onlineCount++; | ||
79 | |||
80 | int unixLoginTime = int.Parse(gu.Data["Login"]); | ||
81 | DateTime loginDateTime = Util.UnixEpoch.AddSeconds(unixLoginTime); | ||
82 | |||
83 | if ((loginDateTime - now).Days < 5) | ||
84 | onlineRecentlyCount++; | ||
85 | } | ||
86 | } | ||
87 | |||
88 | MainConsole.Instance.OutputFormat("Users online within last 5 days: {0}", onlineRecentlyCount); | ||
50 | } | 89 | } |
51 | 90 | ||
52 | public virtual GridUserInfo GetGridUserInfo(string userID) | 91 | public virtual GridUserInfo GetGridUserInfo(string userID) |