aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clarke Casey2008-01-25 19:24:25 +0000
committerJustin Clarke Casey2008-01-25 19:24:25 +0000
commit90c853685c14e186a3dfd06b7a584d16bf520ccf (patch)
treec55acd1c4577b257da0cb73f9b092e1ac79912e7 /OpenSim
parentImplemented a suggestion from Mic Bowman regarding border crossing and Signif... (diff)
downloadopensim-SC_OLD-90c853685c14e186a3dfd06b7a584d16bf520ccf.zip
opensim-SC_OLD-90c853685c14e186a3dfd06b7a584d16bf520ccf.tar.gz
opensim-SC_OLD-90c853685c14e186a3dfd06b7a584d16bf520ccf.tar.bz2
opensim-SC_OLD-90c853685c14e186a3dfd06b7a584d16bf520ccf.tar.xz
* Add very basic initial login stats to the user server
* Typing 'stats' on the command line will given total number of successful logins today and yesterday * A little bit more to come, probably * Refactoring will follow next
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Communications/LoginService.cs26
-rw-r--r--OpenSim/Framework/Servers/BaseOpenSimServer.cs43
-rwxr-xr-xOpenSim/Framework/Statistics/UserStatsReporter.cs82
-rw-r--r--OpenSim/Grid/AssetServer/Main.cs11
-rw-r--r--OpenSim/Grid/UserServer/Main.cs12
-rw-r--r--OpenSim/Grid/UserServer/UserLoginService.cs8
-rw-r--r--OpenSim/Region/Application/OpenSimMain.cs3
-rw-r--r--OpenSim/Region/Communications/Local/LocalLoginService.cs10
-rw-r--r--OpenSim/Region/Examples/SimpleApp/Program.cs3
9 files changed, 180 insertions, 18 deletions
diff --git a/OpenSim/Framework/Communications/LoginService.cs b/OpenSim/Framework/Communications/LoginService.cs
index 3a68bfb..1707607 100644
--- a/OpenSim/Framework/Communications/LoginService.cs
+++ b/OpenSim/Framework/Communications/LoginService.cs
@@ -38,6 +38,7 @@ using Nwc.XmlRpc;
38 38
39using OpenSim.Framework.Communications.Cache; 39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Console; 40using OpenSim.Framework.Console;
41using OpenSim.Framework.Statistics;
41 42
42namespace OpenSim.Framework.UserManagement 43namespace OpenSim.Framework.UserManagement
43{ 44{
@@ -47,16 +48,28 @@ namespace OpenSim.Framework.UserManagement
47 protected UserManagerBase m_userManager = null; 48 protected UserManagerBase m_userManager = null;
48 protected Mutex m_loginMutex = new Mutex(false); 49 protected Mutex m_loginMutex = new Mutex(false);
49 50
51 protected UserStatsReporter m_statsCollector;
52
50 /// <summary> 53 /// <summary>
51 /// Used during login to send the skeleton of the OpenSim Library to the client. 54 /// Used during login to send the skeleton of the OpenSim Library to the client.
52 /// </summary> 55 /// </summary>
53 protected LibraryRootFolder m_libraryRootFolder; 56 protected LibraryRootFolder m_libraryRootFolder;
54 57
55 public LoginService( 58 /// <summary>
56 UserManagerBase userManager, LibraryRootFolder libraryRootFolder, string welcomeMess) 59 /// Constructor
60 /// </summary>
61 /// <param name="userManager"></param>
62 /// <param name="libraryRootFolder"></param>
63 /// <param name="statsCollector">
64 /// An object for collecting statistical information.
65 /// Can be null if statistics are not required</param>
66 /// <param name="welcomeMess"></param>
67 public LoginService(UserManagerBase userManager, LibraryRootFolder libraryRootFolder,
68 UserStatsReporter statsCollector, string welcomeMess)
57 { 69 {
58 m_userManager = userManager; 70 m_userManager = userManager;
59 m_libraryRootFolder = libraryRootFolder; 71 m_libraryRootFolder = libraryRootFolder;
72 m_statsCollector = statsCollector;
60 73
61 if (welcomeMess != String.Empty) 74 if (welcomeMess != String.Empty)
62 { 75 {
@@ -211,6 +224,11 @@ namespace OpenSim.Framework.UserManagement
211 //return logResponse.ToXmlRpcResponse(); 224 //return logResponse.ToXmlRpcResponse();
212 } 225 }
213 CommitAgent(ref userProfile); 226 CommitAgent(ref userProfile);
227
228 // If we reach this point, then the login has successfully logged onto the grid
229 if (m_statsCollector != null)
230 m_statsCollector.AddSuccessfulLogin();
231
214 return logResponse.ToXmlRpcResponse(); 232 return logResponse.ToXmlRpcResponse();
215 } 233 }
216 234
@@ -338,6 +356,10 @@ namespace OpenSim.Framework.UserManagement
338 } 356 }
339 357
340 CommitAgent(ref userProfile); 358 CommitAgent(ref userProfile);
359
360 // If we reach this point, then the login has successfully logged onto the grid
361 if (m_statsCollector != null)
362 m_statsCollector.AddSuccessfulLogin();
341 363
342 return logResponse.ToLLSDResponse(); 364 return logResponse.ToLLSDResponse();
343 } 365 }
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
new file mode 100644
index 0000000..28a5b25
--- /dev/null
+++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs
@@ -0,0 +1,43 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System;
30
31namespace OpenSim.Framework.Servers
32{
33 /// <summary>
34 /// Common base for the main OpenSimServers (user, grid, inventory, region, etc)
35 /// XXX Not yet implemented, may not grow up for some time
36 /// </summary>
37 public class BaseOpenSimServer
38 {
39 public BaseOpenSimServer()
40 {
41 }
42 }
43}
diff --git a/OpenSim/Framework/Statistics/UserStatsReporter.cs b/OpenSim/Framework/Statistics/UserStatsReporter.cs
new file mode 100755
index 0000000..9b3a13f
--- /dev/null
+++ b/OpenSim/Framework/Statistics/UserStatsReporter.cs
@@ -0,0 +1,82 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28
29using System.Text;
30using System.Timers;
31
32namespace OpenSim.Framework.Statistics
33{
34 /// <summary>
35 /// Description of UserStatsReporter.
36 /// </summary>
37 public class UserStatsReporter
38 {
39 private Timer ageStatsTimer = new Timer(24 * 60 * 60 * 1000);
40
41 private int successfulLoginsToday;
42 public int SuccessfulLoginsToday { get { return successfulLoginsToday; } }
43
44 private int successfulLoginsYesterday;
45 public int SuccessfulLoginsYesterday { get { return successfulLoginsYesterday; } }
46
47 public UserStatsReporter()
48 {
49 ageStatsTimer.Elapsed += new ElapsedEventHandler(OnAgeing);
50 ageStatsTimer.Enabled = true;
51 }
52
53 private void OnAgeing(object source, ElapsedEventArgs e)
54 {
55 successfulLoginsYesterday = successfulLoginsToday;
56
57 // There is a possibility that an asset request could occur between the execution of these
58 // two statements. But we're better off without the synchronization overhead.
59 successfulLoginsToday = 0;
60 }
61
62 /// <summary>
63 /// Record a successful login
64 /// </summary>
65 public void AddSuccessfulLogin()
66 {
67 successfulLoginsToday++;
68 }
69
70 /// <summary>
71 /// Report back collected statistical information.
72 /// </summary>
73 /// <returns></returns>
74 public string Report()
75 {
76 return string.Format(
77@"Successful logins today : {0}
78Successful logins yesterday : {1}",
79 SuccessfulLoginsToday, SuccessfulLoginsYesterday);
80 }
81 }
82}
diff --git a/OpenSim/Grid/AssetServer/Main.cs b/OpenSim/Grid/AssetServer/Main.cs
index 4fc66f7..1e0dced 100644
--- a/OpenSim/Grid/AssetServer/Main.cs
+++ b/OpenSim/Grid/AssetServer/Main.cs
@@ -53,7 +53,7 @@ namespace OpenSim.Grid.AssetServer
53 53
54 private IAssetProvider m_assetProvider; 54 private IAssetProvider m_assetProvider;
55 55
56 private AssetStatsReporter stats; 56 protected AssetStatsReporter m_stats;
57 57
58 [STAThread] 58 [STAThread]
59 public static void Main(string[] args) 59 public static void Main(string[] args)
@@ -100,10 +100,9 @@ namespace OpenSim.Grid.AssetServer
100 m_console.Verbose("ASSET", "Starting HTTP process"); 100 m_console.Verbose("ASSET", "Starting HTTP process");
101 BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); 101 BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort);
102 102
103 // XXX Hardcoded - could be a plugin later on 103 m_stats = new AssetStatsReporter();
104 stats = new AssetStatsReporter();
105 104
106 httpServer.AddStreamHandler(new GetAssetStreamHandler(this, m_assetProvider, stats)); 105 httpServer.AddStreamHandler(new GetAssetStreamHandler(this, m_assetProvider, m_stats));
107 httpServer.AddStreamHandler(new PostAssetStreamHandler(this, m_assetProvider)); 106 httpServer.AddStreamHandler(new PostAssetStreamHandler(this, m_assetProvider));
108 107
109 httpServer.Start(); 108 httpServer.Start();
@@ -179,12 +178,12 @@ namespace OpenSim.Grid.AssetServer
179 case "help": 178 case "help":
180 m_console.Notice( 179 m_console.Notice(
181 @"shutdown - shutdown this asset server (USE CAUTION!) 180 @"shutdown - shutdown this asset server (USE CAUTION!)
182 stats - statistical information for this asset server"); 181 stats - statistical information for this server");
183 182
184 break; 183 break;
185 184
186 case "stats": 185 case "stats":
187 MainLog.Instance.Notice("STATS", Environment.NewLine + stats.Report()); 186 MainLog.Instance.Notice("STATS", Environment.NewLine + m_stats.Report());
188 break; 187 break;
189 188
190 case "shutdown": 189 case "shutdown":
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs
index a2881e6..1ae4bee 100644
--- a/OpenSim/Grid/UserServer/Main.cs
+++ b/OpenSim/Grid/UserServer/Main.cs
@@ -34,6 +34,7 @@ using OpenSim.Framework;
34using OpenSim.Framework.Communications.Cache; 34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Framework.Servers; 36using OpenSim.Framework.Servers;
37using OpenSim.Framework.Statistics;
37 38
38namespace OpenSim.Grid.UserServer 39namespace OpenSim.Grid.UserServer
39{ 40{
@@ -47,6 +48,8 @@ namespace OpenSim.Grid.UserServer
47 public UserManager m_userManager; 48 public UserManager m_userManager;
48 public UserLoginService m_loginService; 49 public UserLoginService m_loginService;
49 public MessageServersConnector m_messagesService; 50 public MessageServersConnector m_messagesService;
51
52 protected UserStatsReporter m_stats;
50 53
51 private LogBase m_console; 54 private LogBase m_console;
52 private LLUUID m_lastCreatedUser = LLUUID.Random(); 55 private LLUUID m_lastCreatedUser = LLUUID.Random();
@@ -91,9 +94,11 @@ namespace OpenSim.Grid.UserServer
91 m_userManager = new UserManager(); 94 m_userManager = new UserManager();
92 m_userManager._config = Cfg; 95 m_userManager._config = Cfg;
93 m_userManager.AddPlugin(Cfg.DatabaseProvider); 96 m_userManager.AddPlugin(Cfg.DatabaseProvider);
97
98 m_stats = new UserStatsReporter();
94 99
95 m_loginService = new UserLoginService( 100 m_loginService = new UserLoginService(
96 m_userManager, new LibraryRootFolder(), Cfg, Cfg.DefaultStartupMsg); 101 m_userManager, new LibraryRootFolder(), m_stats, Cfg, Cfg.DefaultStartupMsg);
97 102
98 m_messagesService = new MessageServersConnector(MainLog.Instance); 103 m_messagesService = new MessageServersConnector(MainLog.Instance);
99 104
@@ -180,6 +185,7 @@ namespace OpenSim.Grid.UserServer
180 { 185 {
181 case "help": 186 case "help":
182 m_console.Notice("create user - create a new user"); 187 m_console.Notice("create user - create a new user");
188 m_console.Notice("stats - statistical information for this server");
183 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)"); 189 m_console.Notice("shutdown - shutdown the grid (USE CAUTION!)");
184 break; 190 break;
185 191
@@ -192,6 +198,10 @@ namespace OpenSim.Grid.UserServer
192 m_console.Close(); 198 m_console.Close();
193 Environment.Exit(0); 199 Environment.Exit(0);
194 break; 200 break;
201
202 case "stats":
203 MainLog.Instance.Notice("STATS", Environment.NewLine + m_stats.Report());
204 break;
195 205
196 case "test-inventory": 206 case "test-inventory":
197 // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>(); 207 // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>();
diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs
index 98d19f7..0f02ad2 100644
--- a/OpenSim/Grid/UserServer/UserLoginService.cs
+++ b/OpenSim/Grid/UserServer/UserLoginService.cs
@@ -38,6 +38,7 @@ using OpenSim.Framework.Communications.Cache;
38using OpenSim.Framework.Console; 38using OpenSim.Framework.Console;
39using OpenSim.Framework.Data; 39using OpenSim.Framework.Data;
40using OpenSim.Framework.Servers; 40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Statistics;
41using OpenSim.Framework.UserManagement; 42using OpenSim.Framework.UserManagement;
42using InventoryFolder=OpenSim.Framework.InventoryFolder; 43using InventoryFolder=OpenSim.Framework.InventoryFolder;
43 44
@@ -53,8 +54,9 @@ namespace OpenSim.Grid.UserServer
53 public UserConfig m_config; 54 public UserConfig m_config;
54 55
55 public UserLoginService( 56 public UserLoginService(
56 UserManagerBase userManager, LibraryRootFolder libraryRootFolder, UserConfig config, string welcomeMess) 57 UserManagerBase userManager, LibraryRootFolder libraryRootFolder,
57 : base(userManager, libraryRootFolder, welcomeMess) 58 UserStatsReporter statsCollector, UserConfig config, string welcomeMess)
59 : base(userManager, libraryRootFolder, statsCollector, welcomeMess)
58 { 60 {
59 m_config = config; 61 m_config = config;
60 } 62 }
@@ -290,4 +292,4 @@ namespace OpenSim.Grid.UserServer
290 } 292 }
291 } 293 }
292 } 294 }
293} \ No newline at end of file 295}
diff --git a/OpenSim/Region/Application/OpenSimMain.cs b/OpenSim/Region/Application/OpenSimMain.cs
index 9da1c05..9484e15 100644
--- a/OpenSim/Region/Application/OpenSimMain.cs
+++ b/OpenSim/Region/Application/OpenSimMain.cs
@@ -327,9 +327,10 @@ namespace OpenSim
327 inventoryService, backendService, backendService, m_dumpAssetsToFile); 327 inventoryService, backendService, backendService, m_dumpAssetsToFile);
328 m_commsManager = localComms; 328 m_commsManager = localComms;
329 329
330 // TODO No user stats collection yet for standalone
330 m_loginService = 331 m_loginService =
331 new LocalLoginService(userService, m_standaloneWelcomeMessage, localComms, m_networkServersInfo, 332 new LocalLoginService(userService, m_standaloneWelcomeMessage, localComms, m_networkServersInfo,
332 m_standaloneAuthenticate); 333 null, m_standaloneAuthenticate);
333 m_loginService.OnLoginToRegion += backendService.AddNewSession; 334 m_loginService.OnLoginToRegion += backendService.AddNewSession;
334 335
335 // XMLRPC action 336 // XMLRPC action
diff --git a/OpenSim/Region/Communications/Local/LocalLoginService.cs b/OpenSim/Region/Communications/Local/LocalLoginService.cs
index 38f1970..7dee2cb 100644
--- a/OpenSim/Region/Communications/Local/LocalLoginService.cs
+++ b/OpenSim/Region/Communications/Local/LocalLoginService.cs
@@ -34,6 +34,7 @@ using libsecondlife;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37using OpenSim.Framework.Statistics;
37using OpenSim.Framework.UserManagement; 38using OpenSim.Framework.UserManagement;
38using InventoryFolder=OpenSim.Framework.InventoryFolder; 39using InventoryFolder=OpenSim.Framework.InventoryFolder;
39 40
@@ -52,9 +53,10 @@ namespace OpenSim.Region.Communications.Local
52 53
53 public event LoginToRegionEvent OnLoginToRegion; 54 public event LoginToRegionEvent OnLoginToRegion;
54 55
55 public LocalLoginService(UserManagerBase userManager, string welcomeMess, CommunicationsLocal parent, 56 public LocalLoginService(UserManagerBase userManager, string welcomeMess,
56 NetworkServersInfo serversInfo, bool authenticate) 57 CommunicationsLocal parent, NetworkServersInfo serversInfo,
57 : base(userManager, parent.UserProfileCacheService.libraryRoot, welcomeMess) 58 UserStatsReporter statsCollector, bool authenticate)
59 : base(userManager, parent.UserProfileCacheService.libraryRoot, statsCollector, welcomeMess)
58 { 60 {
59 m_Parent = parent; 61 m_Parent = parent;
60 this.serversInfo = serversInfo; 62 this.serversInfo = serversInfo;
@@ -228,4 +230,4 @@ namespace OpenSim.Region.Communications.Local
228 230
229 } 231 }
230 } 232 }
231} \ No newline at end of file 233}
diff --git a/OpenSim/Region/Examples/SimpleApp/Program.cs b/OpenSim/Region/Examples/SimpleApp/Program.cs
index 8b8bcf4..485d657 100644
--- a/OpenSim/Region/Examples/SimpleApp/Program.cs
+++ b/OpenSim/Region/Examples/SimpleApp/Program.cs
@@ -88,7 +88,8 @@ namespace SimpleApp
88 m_commsManager = localComms; 88 m_commsManager = localComms;
89 89
90 LocalLoginService loginService = 90 LocalLoginService loginService =
91 new LocalLoginService(userService, String.Empty, localComms, m_networkServersInfo, false); 91 new LocalLoginService(
92 userService, String.Empty, localComms, m_networkServersInfo, null, false);
92 loginService.OnLoginToRegion += backendService.AddNewSession; 93 loginService.OnLoginToRegion += backendService.AddNewSession;
93 94
94 m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod); 95 m_httpServer.AddXmlRPCHandler("login_to_simulator", loginService.XmlRpcLoginMethod);