diff options
author | Justin Clarke Casey | 2008-05-14 21:53:40 +0000 |
---|---|---|
committer | Justin Clarke Casey | 2008-05-14 21:53:40 +0000 |
commit | 0f501629618fe1655b7ba653802056b5c32dbae6 (patch) | |
tree | 8a7f2808a27f97a60d1901263155906256e6f46a /OpenSim/Framework | |
parent | * Refactor: Renaming non viewer statistics classes from Reporters to Collecto... (diff) | |
download | opensim-SC-0f501629618fe1655b7ba653802056b5c32dbae6.zip opensim-SC-0f501629618fe1655b7ba653802056b5c32dbae6.tar.gz opensim-SC-0f501629618fe1655b7ba653802056b5c32dbae6.tar.bz2 opensim-SC-0f501629618fe1655b7ba653802056b5c32dbae6.tar.xz |
* Refactor additional stats collection common code into base opensim server
* If extra stats not sent to the viewer are available on an opensim server, they are now uniformly accessible using the 'show stats' command
Diffstat (limited to 'OpenSim/Framework')
6 files changed, 72 insertions, 8 deletions
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 344309d..811a0db 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenSim.Framework.Console; | 29 | using OpenSim.Framework.Console; |
30 | using OpenSim.Framework.Statistics; | ||
30 | 31 | ||
31 | namespace OpenSim.Framework.Servers | 32 | namespace OpenSim.Framework.Servers |
32 | { | 33 | { |
@@ -44,6 +45,11 @@ namespace OpenSim.Framework.Servers | |||
44 | get { return m_httpServer; } | 45 | get { return m_httpServer; } |
45 | } | 46 | } |
46 | 47 | ||
48 | /// <summary> | ||
49 | /// Holds the non-viewer statistics collection object for this service/server | ||
50 | /// </summary> | ||
51 | protected IStatsCollector m_stats; | ||
52 | |||
47 | public BaseOpenSimServer() | 53 | public BaseOpenSimServer() |
48 | { | 54 | { |
49 | m_startuptime = DateTime.Now; | 55 | m_startuptime = DateTime.Now; |
@@ -72,6 +78,10 @@ namespace OpenSim.Framework.Servers | |||
72 | { | 78 | { |
73 | case "help": | 79 | case "help": |
74 | Notice("quit - equivalent to shutdown."); | 80 | Notice("quit - equivalent to shutdown."); |
81 | |||
82 | if (m_stats != null) | ||
83 | Notice("show stats - statistical information for this server"); | ||
84 | |||
75 | Notice("show uptime - show server startup and uptime."); | 85 | Notice("show uptime - show server startup and uptime."); |
76 | Notice("shutdown - shutdown the server.\n"); | 86 | Notice("shutdown - shutdown the server.\n"); |
77 | break; | 87 | break; |
@@ -97,7 +107,14 @@ namespace OpenSim.Framework.Servers | |||
97 | public virtual void Show(string ShowWhat) | 107 | public virtual void Show(string ShowWhat) |
98 | { | 108 | { |
99 | switch (ShowWhat) | 109 | switch (ShowWhat) |
100 | { | 110 | { |
111 | case "stats": | ||
112 | if (m_stats != null) | ||
113 | { | ||
114 | Notice(m_stats.Report()); | ||
115 | } | ||
116 | break; | ||
117 | |||
101 | case "uptime": | 118 | case "uptime": |
102 | Notice("Server has been running since " + m_startuptime.DayOfWeek + ", " + m_startuptime.ToString()); | 119 | Notice("Server has been running since " + m_startuptime.DayOfWeek + ", " + m_startuptime.ToString()); |
103 | Notice("That is an elapsed time of " + (DateTime.Now - m_startuptime).ToString()); | 120 | Notice("That is an elapsed time of " + (DateTime.Now - m_startuptime).ToString()); |
diff --git a/OpenSim/Framework/Statistics/AssetStatsCollector.cs b/OpenSim/Framework/Statistics/AssetStatsCollector.cs index afc42d2..bd36c3f 100644 --- a/OpenSim/Framework/Statistics/AssetStatsCollector.cs +++ b/OpenSim/Framework/Statistics/AssetStatsCollector.cs | |||
@@ -33,7 +33,7 @@ namespace OpenSim.Framework.Statistics | |||
33 | /// <summary> | 33 | /// <summary> |
34 | /// Asset service statistics collection | 34 | /// Asset service statistics collection |
35 | /// </summary> | 35 | /// </summary> |
36 | public class AssetStatsCollector | 36 | public class AssetStatsCollector : IStatsCollector |
37 | { | 37 | { |
38 | private Timer ageStatsTimer = new Timer(24 * 60 * 60 * 1000); | 38 | private Timer ageStatsTimer = new Timer(24 * 60 * 60 * 1000); |
39 | private DateTime startTime = DateTime.Now; | 39 | private DateTime startTime = DateTime.Now; |
diff --git a/OpenSim/Framework/Statistics/Interfaces/IStatsCollector.cs b/OpenSim/Framework/Statistics/Interfaces/IStatsCollector.cs new file mode 100644 index 0000000..768cd22 --- /dev/null +++ b/OpenSim/Framework/Statistics/Interfaces/IStatsCollector.cs | |||
@@ -0,0 +1,41 @@ | |||
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 | namespace OpenSim.Framework.Statistics | ||
29 | { | ||
30 | /// <summary> | ||
31 | /// Implemented by classes which collect up non-viewer statistical information | ||
32 | /// </summary> | ||
33 | public interface IStatsCollector | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// Report back collected statistical information. | ||
37 | /// </summary> | ||
38 | /// <returns></returns> | ||
39 | string Report(); | ||
40 | } | ||
41 | } | ||
diff --git a/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs b/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs index 4e69d17..2beb3a0 100644 --- a/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs +++ b/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs | |||
@@ -36,7 +36,7 @@ namespace OpenSim.Framework.Statistics | |||
36 | /// <summary> | 36 | /// <summary> |
37 | /// Collects sim statistics which aren't already being collected for the linden viewer's statistics pane | 37 | /// Collects sim statistics which aren't already being collected for the linden viewer's statistics pane |
38 | /// </summary> | 38 | /// </summary> |
39 | public class SimExtraStatsCollector | 39 | public class SimExtraStatsCollector : IStatsCollector |
40 | { | 40 | { |
41 | private long assetsInCache; | 41 | private long assetsInCache; |
42 | private long texturesInCache; | 42 | private long texturesInCache; |
@@ -135,7 +135,7 @@ Texture cache contains {2,6} textures using {3,10:0.000}K" + Environment.NewLine | |||
135 | /// <summary> | 135 | /// <summary> |
136 | /// Pull packet queue stats from packet queues and report | 136 | /// Pull packet queue stats from packet queues and report |
137 | /// </summary> | 137 | /// </summary> |
138 | public class PacketQueueStatsCollector | 138 | public class PacketQueueStatsCollector : IStatsCollector |
139 | { | 139 | { |
140 | private IPullStatsProvider m_statsProvider; | 140 | private IPullStatsProvider m_statsProvider; |
141 | 141 | ||
diff --git a/OpenSim/Framework/Statistics/StatsManager.cs b/OpenSim/Framework/Statistics/StatsManager.cs index 10251a5..3c97dde 100644 --- a/OpenSim/Framework/Statistics/StatsManager.cs +++ b/OpenSim/Framework/Statistics/StatsManager.cs | |||
@@ -46,27 +46,33 @@ namespace OpenSim.Framework.Statistics | |||
46 | /// Start collecting statistics related to assets. | 46 | /// Start collecting statistics related to assets. |
47 | /// Should only be called once. | 47 | /// Should only be called once. |
48 | /// </summary> | 48 | /// </summary> |
49 | public static void StartCollectingAssetStats() | 49 | public static AssetStatsCollector StartCollectingAssetStats() |
50 | { | 50 | { |
51 | assetStats = new AssetStatsCollector(); | 51 | assetStats = new AssetStatsCollector(); |
52 | |||
53 | return assetStats; | ||
52 | } | 54 | } |
53 | 55 | ||
54 | /// <summary> | 56 | /// <summary> |
55 | /// Start collecting statistics related to users. | 57 | /// Start collecting statistics related to users. |
56 | /// Should only be called once. | 58 | /// Should only be called once. |
57 | /// </summary> | 59 | /// </summary> |
58 | public static void StartCollectingUserStats() | 60 | public static UserStatsCollector StartCollectingUserStats() |
59 | { | 61 | { |
60 | userStats = new UserStatsCollector(); | 62 | userStats = new UserStatsCollector(); |
63 | |||
64 | return userStats; | ||
61 | } | 65 | } |
62 | 66 | ||
63 | /// <summary> | 67 | /// <summary> |
64 | /// Start collecting extra sim statistics apart from those collected for the client. | 68 | /// Start collecting extra sim statistics apart from those collected for the client. |
65 | /// Should only be called once. | 69 | /// Should only be called once. |
66 | /// </summary> | 70 | /// </summary> |
67 | public static void StartCollectingSimExtraStats() | 71 | public static SimExtraStatsCollector StartCollectingSimExtraStats() |
68 | { | 72 | { |
69 | simExtraStats = new SimExtraStatsCollector(); | 73 | simExtraStats = new SimExtraStatsCollector(); |
74 | |||
75 | return simExtraStats; | ||
70 | } | 76 | } |
71 | } | 77 | } |
72 | } | 78 | } |
diff --git a/OpenSim/Framework/Statistics/UserStatsCollector.cs b/OpenSim/Framework/Statistics/UserStatsCollector.cs index 80cd46e..f0f0417 100644 --- a/OpenSim/Framework/Statistics/UserStatsCollector.cs +++ b/OpenSim/Framework/Statistics/UserStatsCollector.cs | |||
@@ -32,7 +32,7 @@ namespace OpenSim.Framework.Statistics | |||
32 | /// <summary> | 32 | /// <summary> |
33 | /// Collects user service statistics | 33 | /// Collects user service statistics |
34 | /// </summary> | 34 | /// </summary> |
35 | public class UserStatsCollector | 35 | public class UserStatsCollector : IStatsCollector |
36 | { | 36 | { |
37 | private Timer ageStatsTimer = new Timer(24 * 60 * 60 * 1000); | 37 | private Timer ageStatsTimer = new Timer(24 * 60 * 60 * 1000); |
38 | 38 | ||