aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/LoginService.cs26
-rw-r--r--OpenSim/Framework/Servers/BaseOpenSimServer.cs43
-rwxr-xr-xOpenSim/Framework/Statistics/UserStatsReporter.cs82
3 files changed, 149 insertions, 2 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}