diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/RegionInfo.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/BaseOpenSimServer.cs | 16 | ||||
-rw-r--r-- | OpenSim/Region/Application/OpenSimBase.cs | 64 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs | 115 | ||||
-rw-r--r-- | bin/OpenSim.ini.example | 4 |
6 files changed, 196 insertions, 7 deletions
diff --git a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs index 2bf5133..37f2c0b 100644 --- a/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs +++ b/OpenSim/ApplicationPlugins/CreateCommsManager/CreateCommsManagerPlugin.cs | |||
@@ -186,6 +186,8 @@ namespace OpenSim.ApplicationPlugins.CreateCommsManager | |||
186 | 186 | ||
187 | m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler()); | 187 | m_httpServer.AddStreamHandler(new OpenSim.SimStatusHandler()); |
188 | m_httpServer.AddStreamHandler(new OpenSim.XSimStatusHandler(m_openSim)); | 188 | m_httpServer.AddStreamHandler(new OpenSim.XSimStatusHandler(m_openSim)); |
189 | if(m_openSim.userStatsURI != String.Empty ) | ||
190 | m_httpServer.AddStreamHandler(new OpenSim.UXSimStatusHandler(m_openSim)); | ||
189 | } | 191 | } |
190 | 192 | ||
191 | protected virtual void InitialiseHGStandaloneServices(LibraryRootFolder libraryRootFolder) | 193 | protected virtual void InitialiseHGStandaloneServices(LibraryRootFolder libraryRootFolder) |
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index a0f536a..4c107c9 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -211,6 +211,8 @@ namespace OpenSim.Framework | |||
211 | public int ProxyOffset = 0; | 211 | public int ProxyOffset = 0; |
212 | public string RegionName = String.Empty; | 212 | public string RegionName = String.Empty; |
213 | public string regionSecret = UUID.Random().ToString(); | 213 | public string regionSecret = UUID.Random().ToString(); |
214 | |||
215 | public string osSecret; | ||
214 | 216 | ||
215 | public UUID lastMapUUID = UUID.Zero; | 217 | public UUID lastMapUUID = UUID.Zero; |
216 | public string lastMapRefresh = "0"; | 218 | public string lastMapRefresh = "0"; |
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 483f8b6..e03713e 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -79,6 +79,11 @@ namespace OpenSim.Framework.Servers | |||
79 | protected string m_version; | 79 | protected string m_version; |
80 | 80 | ||
81 | protected string m_pidFile = String.Empty; | 81 | protected string m_pidFile = String.Empty; |
82 | |||
83 | /// <summary> | ||
84 | /// Random uuid for private data | ||
85 | /// </summary> | ||
86 | protected string m_osSecret = String.Empty; | ||
82 | 87 | ||
83 | protected BaseHttpServer m_httpServer; | 88 | protected BaseHttpServer m_httpServer; |
84 | public BaseHttpServer HttpServer | 89 | public BaseHttpServer HttpServer |
@@ -95,6 +100,9 @@ namespace OpenSim.Framework.Servers | |||
95 | { | 100 | { |
96 | m_startuptime = DateTime.Now; | 101 | m_startuptime = DateTime.Now; |
97 | m_version = VersionInfo.Version; | 102 | m_version = VersionInfo.Version; |
103 | |||
104 | // Random uuid for private data | ||
105 | m_osSecret = UUID.Random().ToString(); | ||
98 | 106 | ||
99 | m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); | 107 | m_periodicDiagnosticsTimer.Elapsed += new ElapsedEventHandler(LogDiagnostics); |
100 | m_periodicDiagnosticsTimer.Enabled = true; | 108 | m_periodicDiagnosticsTimer.Enabled = true; |
@@ -458,12 +466,18 @@ namespace OpenSim.Framework.Servers | |||
458 | { | 466 | { |
459 | } | 467 | } |
460 | } | 468 | } |
469 | |||
470 | public string osSecret { | ||
471 | // Secret uuid for the simulator | ||
472 | get { return m_osSecret; } | ||
473 | |||
474 | } | ||
461 | 475 | ||
462 | public string StatReport(OSHttpRequest httpRequest) | 476 | public string StatReport(OSHttpRequest httpRequest) |
463 | { | 477 | { |
464 | return m_stats.XReport((DateTime.Now - m_startuptime).ToString() , m_version ); | 478 | return m_stats.XReport((DateTime.Now - m_startuptime).ToString() , m_version ); |
465 | } | 479 | } |
466 | 480 | ||
467 | protected void RemovePIDFile() | 481 | protected void RemovePIDFile() |
468 | { | 482 | { |
469 | if (m_pidFile != String.Empty) | 483 | if (m_pidFile != String.Empty) |
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 2203e45..af7b707 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -65,6 +65,8 @@ namespace OpenSim | |||
65 | 65 | ||
66 | protected string proxyUrl; | 66 | protected string proxyUrl; |
67 | protected int proxyOffset = 0; | 67 | protected int proxyOffset = 0; |
68 | |||
69 | public string userStatsURI = String.Empty; | ||
68 | 70 | ||
69 | protected bool m_autoCreateClientStack = true; | 71 | protected bool m_autoCreateClientStack = true; |
70 | 72 | ||
@@ -189,6 +191,9 @@ namespace OpenSim | |||
189 | string pidFile = startupConfig.GetString("PIDFile", String.Empty); | 191 | string pidFile = startupConfig.GetString("PIDFile", String.Empty); |
190 | if (pidFile != String.Empty) | 192 | if (pidFile != String.Empty) |
191 | CreatePIDFile(pidFile); | 193 | CreatePIDFile(pidFile); |
194 | |||
195 | userStatsURI = startupConfig.GetString("Stats_URI", String.Empty); | ||
196 | |||
192 | } | 197 | } |
193 | 198 | ||
194 | base.StartupSpecific(); | 199 | base.StartupSpecific(); |
@@ -508,7 +513,9 @@ namespace OpenSim | |||
508 | // set initial ServerURI | 513 | // set initial ServerURI |
509 | regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.InternalEndPoint.Port; | 514 | regionInfo.ServerURI = "http://" + regionInfo.ExternalHostName + ":" + regionInfo.InternalEndPoint.Port; |
510 | regionInfo.HttpPort = m_httpServerPort; | 515 | regionInfo.HttpPort = m_httpServerPort; |
511 | 516 | ||
517 | regionInfo.osSecret = m_osSecret; | ||
518 | |||
512 | if ((proxyUrl.Length > 0) && (portadd_flag)) | 519 | if ((proxyUrl.Length > 0) && (portadd_flag)) |
513 | { | 520 | { |
514 | // set proxy url to RegionInfo | 521 | // set proxy url to RegionInfo |
@@ -543,7 +550,10 @@ namespace OpenSim | |||
543 | scene.LoadPrimsFromStorage(regionInfo.originRegionID); | 550 | scene.LoadPrimsFromStorage(regionInfo.originRegionID); |
544 | 551 | ||
545 | scene.StartTimer(); | 552 | scene.StartTimer(); |
546 | 553 | ||
554 | // TODO : Try setting resource for region xstats here on scene | ||
555 | scene.CommsManager.HttpServer.AddStreamHandler( new Region.Framework.Scenes.RegionStatsHandler(regionInfo)); | ||
556 | |||
547 | // moved these here as the terrain texture has to be created after the modules are initialized | 557 | // moved these here as the terrain texture has to be created after the modules are initialized |
548 | // and has to happen before the region is registered with the grid. | 558 | // and has to happen before the region is registered with the grid. |
549 | scene.CreateTerrainTexture(false); | 559 | scene.CreateTerrainTexture(false); |
@@ -813,16 +823,18 @@ namespace OpenSim | |||
813 | } | 823 | } |
814 | 824 | ||
815 | /// <summary> | 825 | /// <summary> |
816 | /// Handler to supply the current extended status of this sim | 826 | /// Handler to supply the current extended status of this sim |
827 | /// Sends the statistical data in a json serialization | ||
817 | /// </summary> | 828 | /// </summary> |
818 | /// Sends the statistical data in a json serialization | ||
819 | public class XSimStatusHandler : IStreamedRequestHandler | 829 | public class XSimStatusHandler : IStreamedRequestHandler |
820 | { | 830 | { |
821 | OpenSimBase m_opensim; | 831 | OpenSimBase m_opensim; |
832 | string osXStatsURI = String.Empty; | ||
822 | 833 | ||
823 | public XSimStatusHandler(OpenSimBase sim) | 834 | public XSimStatusHandler(OpenSimBase sim) |
824 | { | 835 | { |
825 | m_opensim = sim; | 836 | m_opensim = sim; |
837 | osXStatsURI = Util.SHA1Hash(sim.osSecret); | ||
826 | } | 838 | } |
827 | 839 | ||
828 | public byte[] Handle(string path, Stream request, | 840 | public byte[] Handle(string path, Stream request, |
@@ -842,11 +854,50 @@ namespace OpenSim | |||
842 | } | 854 | } |
843 | 855 | ||
844 | public string Path | 856 | public string Path |
845 | { | 857 | { |
846 | get { return "/simstatusx/"; } | 858 | // This is for the OpenSim instance and is the osSecret hashed |
859 | get { return "/" + osXStatsURI + "/"; } | ||
847 | } | 860 | } |
848 | } | 861 | } |
849 | 862 | ||
863 | /// <summary> | ||
864 | /// Handler to supply the current extended status of this sim | ||
865 | /// Sends the statistical data in a json serialization | ||
866 | /// </summary> | ||
867 | public class UXSimStatusHandler : IStreamedRequestHandler | ||
868 | { | ||
869 | OpenSimBase m_opensim; | ||
870 | string osUXStatsURI = String.Empty; | ||
871 | |||
872 | public UXSimStatusHandler(OpenSimBase sim) | ||
873 | { | ||
874 | m_opensim = sim; | ||
875 | osUXStatsURI = sim.userStatsURI; | ||
876 | |||
877 | } | ||
878 | |||
879 | public byte[] Handle(string path, Stream request, | ||
880 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
881 | { | ||
882 | return Encoding.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); | ||
883 | } | ||
884 | |||
885 | public string ContentType | ||
886 | { | ||
887 | get { return "text/plain"; } | ||
888 | } | ||
889 | |||
890 | public string HttpMethod | ||
891 | { | ||
892 | get { return "GET"; } | ||
893 | } | ||
894 | |||
895 | public string Path | ||
896 | { | ||
897 | // This is for the OpenSim instance and is the osSecret hashed | ||
898 | get { return "/" + osUXStatsURI + "/"; } | ||
899 | } | ||
900 | } | ||
850 | 901 | ||
851 | #endregion | 902 | #endregion |
852 | 903 | ||
@@ -906,6 +957,7 @@ namespace OpenSim | |||
906 | } | 957 | } |
907 | } | 958 | } |
908 | 959 | ||
960 | |||
909 | public class OpenSimConfigSource | 961 | public class OpenSimConfigSource |
910 | { | 962 | { |
911 | public IConfigSource Source; | 963 | public IConfigSource Source; |
diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs new file mode 100644 index 0000000..f521490 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs | |||
@@ -0,0 +1,115 @@ | |||
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 | using System; | ||
29 | using System.IO; | ||
30 | using System.Net; | ||
31 | using System.Reflection; | ||
32 | using System.Text; | ||
33 | using log4net; | ||
34 | using Nini.Config; | ||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.StructuredData; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Communications; | ||
39 | using OpenSim.Framework.Communications.Services; | ||
40 | using OpenSim.Framework.Communications.Cache; | ||
41 | using OpenSim.Framework.Console; | ||
42 | using OpenSim.Framework.Servers; | ||
43 | using OpenSim.Framework.Servers.Interfaces; | ||
44 | using OpenSim.Framework.Statistics; | ||
45 | using OpenSim.Region.Framework; | ||
46 | using OpenSim.Region.Framework.Interfaces; | ||
47 | using OpenSim.Region.Framework.Scenes; | ||
48 | |||
49 | |||
50 | |||
51 | namespace OpenSim.Region.Framework.Scenes | ||
52 | { | ||
53 | |||
54 | |||
55 | public class RegionStatsHandler : IStreamedRequestHandler | ||
56 | { | ||
57 | |||
58 | private string osRXStatsURI = String.Empty; | ||
59 | private string osXStatsURI = String.Empty; | ||
60 | private string osSecret = String.Empty; | ||
61 | private OpenSim.Framework.RegionInfo regionInfo; | ||
62 | public string localZone = TimeZone.CurrentTimeZone.StandardName; | ||
63 | public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now); | ||
64 | |||
65 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
66 | |||
67 | public RegionStatsHandler(OpenSim.Framework.RegionInfo region_info ) | ||
68 | { | ||
69 | regionInfo = region_info; | ||
70 | osRXStatsURI = Util.SHA1Hash(regionInfo.regionSecret); | ||
71 | osXStatsURI = Util.SHA1Hash(regionInfo.osSecret); | ||
72 | |||
73 | } | ||
74 | |||
75 | public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
76 | { | ||
77 | return Encoding.UTF8.GetBytes(Report()); | ||
78 | } | ||
79 | |||
80 | public string ContentType | ||
81 | { | ||
82 | get { return "text/plain"; } | ||
83 | } | ||
84 | |||
85 | public string HttpMethod | ||
86 | { | ||
87 | get { return "GET"; } | ||
88 | } | ||
89 | |||
90 | public string Path | ||
91 | { | ||
92 | // This is for the region and is the regionSecret hashed | ||
93 | get { return "/" + osRXStatsURI + "/"; } | ||
94 | } | ||
95 | |||
96 | private string Report() | ||
97 | { | ||
98 | |||
99 | OSDMap args = new OSDMap(30); | ||
100 | int time = Util.ToUnixTime( DateTime.Now ); | ||
101 | args["OSStatsURI"] = OSD.FromString("http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "/" + osXStatsURI + "/"); | ||
102 | args["TimeZoneName"] = OSD.FromString(localZone); | ||
103 | args["TimeZoneOffs"] = OSD.FromReal(utcOffset.TotalHours); | ||
104 | args["UxTime"] = OSD.FromInteger(Util.ToUnixTime(DateTime.Now)); | ||
105 | args["Memory"] = OSD.FromReal(Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)); | ||
106 | args["Version"] = OSD.FromString(VersionInfo.Version); | ||
107 | |||
108 | string strBuffer = ""; | ||
109 | strBuffer = OSDParser.SerializeJsonString(args); | ||
110 | |||
111 | return strBuffer; | ||
112 | |||
113 | } | ||
114 | } | ||
115 | } | ||
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 3130bf0..c210a9b 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example | |||
@@ -255,6 +255,10 @@ | |||
255 | 255 | ||
256 | ; enableprejump = true | 256 | ; enableprejump = true |
257 | 257 | ||
258 | ; Simulator Stats URI | ||
259 | ; Enable JSON simulator data by setting a URI name (case sensitive) | ||
260 | ; Stats_URI = "jsonSimStats" | ||
261 | |||
258 | 262 | ||
259 | [SMTP] | 263 | [SMTP] |
260 | enabled=false | 264 | enabled=false |