diff options
author | Justin Clarke Casey | 2008-01-25 19:24:25 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-01-25 19:24:25 +0000 |
commit | 90c853685c14e186a3dfd06b7a584d16bf520ccf (patch) | |
tree | c55acd1c4577b257da0cb73f9b092e1ac79912e7 /OpenSim/Framework/Statistics | |
parent | Implemented a suggestion from Mic Bowman regarding border crossing and Signif... (diff) | |
download | opensim-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/Framework/Statistics')
-rwxr-xr-x | OpenSim/Framework/Statistics/UserStatsReporter.cs | 82 |
1 files changed, 82 insertions, 0 deletions
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 | |||
29 | using System.Text; | ||
30 | using System.Timers; | ||
31 | |||
32 | namespace 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} | ||
78 | Successful logins yesterday : {1}", | ||
79 | SuccessfulLoginsToday, SuccessfulLoginsYesterday); | ||
80 | } | ||
81 | } | ||
82 | } | ||