diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Util.cs | 8 | ||||
-rw-r--r-- | OpenSim/Services/UserAccountService/GridUserService.cs | 39 |
2 files changed, 43 insertions, 4 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index f0e5bc1..52f5432 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -130,7 +130,7 @@ namespace OpenSim.Framework | |||
130 | private static SmartThreadPool m_ThreadPool; | 130 | private static SmartThreadPool m_ThreadPool; |
131 | 131 | ||
132 | // Unix-epoch starts at January 1st 1970, 00:00:00 UTC. And all our times in the server are (or at least should be) in UTC. | 132 | // Unix-epoch starts at January 1st 1970, 00:00:00 UTC. And all our times in the server are (or at least should be) in UTC. |
133 | private static readonly DateTime unixEpoch = | 133 | public static readonly DateTime UnixEpoch = |
134 | DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", DateTimeFormatInfo.InvariantInfo).ToUniversalTime(); | 134 | DateTime.ParseExact("1970-01-01 00:00:00 +0", "yyyy-MM-dd hh:mm:ss z", DateTimeFormatInfo.InvariantInfo).ToUniversalTime(); |
135 | 135 | ||
136 | private static readonly string rawUUIDPattern | 136 | private static readonly string rawUUIDPattern |
@@ -521,19 +521,19 @@ namespace OpenSim.Framework | |||
521 | 521 | ||
522 | public static int ToUnixTime(DateTime stamp) | 522 | public static int ToUnixTime(DateTime stamp) |
523 | { | 523 | { |
524 | TimeSpan t = stamp.ToUniversalTime() - unixEpoch; | 524 | TimeSpan t = stamp.ToUniversalTime() - UnixEpoch; |
525 | return (int) t.TotalSeconds; | 525 | return (int) t.TotalSeconds; |
526 | } | 526 | } |
527 | 527 | ||
528 | public static DateTime ToDateTime(ulong seconds) | 528 | public static DateTime ToDateTime(ulong seconds) |
529 | { | 529 | { |
530 | DateTime epoch = unixEpoch; | 530 | DateTime epoch = UnixEpoch; |
531 | return epoch.AddSeconds(seconds); | 531 | return epoch.AddSeconds(seconds); |
532 | } | 532 | } |
533 | 533 | ||
534 | public static DateTime ToDateTime(int seconds) | 534 | public static DateTime ToDateTime(int seconds) |
535 | { | 535 | { |
536 | DateTime epoch = unixEpoch; | 536 | DateTime epoch = UnixEpoch; |
537 | return epoch.AddSeconds(seconds); | 537 | return epoch.AddSeconds(seconds); |
538 | } | 538 | } |
539 | 539 | ||
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) |