clockwerk-opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 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 OpenSimulator 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.Collections.Generic; |
||
30 | using System.Reflection; |
||
31 | using System.Text; |
||
32 | using System.Text.RegularExpressions; |
||
33 | using log4net; |
||
34 | using Mono.Addins; |
||
35 | using NDesk.Options; |
||
36 | using Nini.Config; |
||
37 | using OpenMetaverse; |
||
38 | using OpenSim.Framework; |
||
39 | using OpenSim.Framework.Console; |
||
40 | using OpenSim.Framework.Monitoring; |
||
41 | using OpenSim.Region.Framework.Interfaces; |
||
42 | using OpenSim.Region.Framework.Scenes; |
||
43 | |||
44 | namespace OpenSim.Region.CoreModules.World.Objects.Commands |
||
45 | { |
||
46 | /// <summary> |
||
47 | /// A module that holds commands for manipulating objects in the scene. |
||
48 | /// </summary> |
||
49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RegionCommandsModule")] |
||
50 | public class RegionCommandsModule : INonSharedRegionModule |
||
51 | { |
||
52 | private Scene m_scene; |
||
53 | private ICommandConsole m_console; |
||
54 | |||
55 | public string Name { get { return "Region Commands Module"; } } |
||
56 | |||
57 | public Type ReplaceableInterface { get { return null; } } |
||
58 | |||
59 | public void Initialise(IConfigSource source) |
||
60 | { |
||
61 | // m_log.DebugFormat("[REGION COMMANDS MODULE]: INITIALIZED MODULE"); |
||
62 | } |
||
63 | |||
64 | public void PostInitialise() |
||
65 | { |
||
66 | // m_log.DebugFormat("[REGION COMMANDS MODULE]: POST INITIALIZED MODULE"); |
||
67 | } |
||
68 | |||
69 | public void Close() |
||
70 | { |
||
71 | // m_log.DebugFormat("[REGION COMMANDS MODULE]: CLOSED MODULE"); |
||
72 | } |
||
73 | |||
74 | public void AddRegion(Scene scene) |
||
75 | { |
||
76 | // m_log.DebugFormat("[REGION COMMANDS MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); |
||
77 | |||
78 | m_scene = scene; |
||
79 | m_console = MainConsole.Instance; |
||
80 | |||
81 | m_console.Commands.AddCommand( |
||
82 | "Regions", false, "show scene", |
||
83 | "show scene", |
||
84 | "Show live information for the currently selected scene (fps, prims, etc.).", HandleShowScene); |
||
85 | |||
86 | m_console.Commands.AddCommand( |
||
87 | "Regions", false, "show region", |
||
88 | "show region", |
||
89 | "Show control information for the currently selected region (host name, max physical prim size, etc).", |
||
90 | HandleShowRegion); |
||
91 | } |
||
92 | |||
93 | public void RemoveRegion(Scene scene) |
||
94 | { |
||
95 | // m_log.DebugFormat("[REGION COMMANDS MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); |
||
96 | } |
||
97 | |||
98 | public void RegionLoaded(Scene scene) |
||
99 | { |
||
100 | // m_log.DebugFormat("[REGION COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); |
||
101 | } |
||
102 | |||
103 | private void HandleShowRegion(string module, string[] cmd) |
||
104 | { |
||
105 | if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene)) |
||
106 | return; |
||
107 | |||
108 | RegionInfo ri = m_scene.RegionInfo; |
||
109 | RegionSettings rs = ri.RegionSettings; |
||
110 | |||
111 | StringBuilder sb = new StringBuilder(); |
||
112 | sb.AppendFormat("Region information for {0}\n", m_scene.Name); |
||
113 | |||
114 | ConsoleDisplayList dispList = new ConsoleDisplayList(); |
||
115 | dispList.AddRow("Region ID", ri.RegionID); |
||
116 | dispList.AddRow("Region handle", ri.RegionHandle); |
||
117 | dispList.AddRow("Region location", string.Format("{0},{1}", ri.RegionLocX, ri.RegionLocY)); |
||
118 | dispList.AddRow("Region size", string.Format("{0}x{1}", ri.RegionSizeX, ri.RegionSizeY)); |
||
119 | //dispList.AddRow("Region type", ri.RegionType); |
||
120 | dispList.AddRow("Maturity", rs.Maturity); |
||
121 | dispList.AddRow("Region address", ri.ServerURI); |
||
122 | dispList.AddRow("From region file", ri.RegionFile); |
||
123 | dispList.AddRow("External endpoint", ri.ExternalEndPoint); |
||
124 | dispList.AddRow("Internal endpoint", ri.InternalEndPoint); |
||
125 | dispList.AddRow("Access level", ri.AccessLevel); |
||
126 | dispList.AddRow("Max agent limit", ri.AgentCapacity); |
||
127 | dispList.AddRow("Current agent limit", rs.AgentLimit); |
||
128 | dispList.AddRow("Linkset capacity", ri.LinksetCapacity <= 0 ? "not set" : ri.LinksetCapacity.ToString()); |
||
129 | dispList.AddRow("Prim capacity", ri.ObjectCapacity); |
||
130 | dispList.AddRow("Prim bonus", rs.ObjectBonus); |
||
131 | dispList.AddRow("Max prims per user", ri.MaxPrimsPerUser < 0 ? "n/a" : ri.MaxPrimsPerUser.ToString()); |
||
132 | dispList.AddRow("Clamp prim size", ri.ClampPrimSize); |
||
133 | dispList.AddRow("Non physical prim min size", ri.NonphysPrimMin <= 0 ? "not set" : string.Format("{0} m", ri.NonphysPrimMin)); |
||
134 | dispList.AddRow("Non physical prim max size", ri.NonphysPrimMax <= 0 ? "not set" : string.Format("{0} m", ri.NonphysPrimMax)); |
||
135 | dispList.AddRow("Physical prim min size", ri.PhysPrimMin <= 0 ? "not set" : string.Format("{0} m", ri.PhysPrimMin)); |
||
136 | dispList.AddRow("Physical prim max size", ri.PhysPrimMax <= 0 ? "not set" : string.Format("{0} m", ri.PhysPrimMax)); |
||
137 | |||
138 | dispList.AddRow("Allow Damage", rs.AllowDamage); |
||
139 | dispList.AddRow("Allow Land join/divide", rs.AllowLandJoinDivide); |
||
140 | dispList.AddRow("Allow land resell", rs.AllowLandResell); |
||
141 | dispList.AddRow("Block fly", rs.BlockFly); |
||
142 | dispList.AddRow("Block show in search", rs.BlockShowInSearch); |
||
143 | dispList.AddRow("Block terraform", rs.BlockTerraform); |
||
144 | dispList.AddRow("Covenant UUID", rs.Covenant); |
||
145 | dispList.AddRow("Convenant change Unix time", rs.CovenantChangedDateTime); |
||
146 | dispList.AddRow("Disable collisions", rs.DisableCollisions); |
||
147 | dispList.AddRow("Disable physics", rs.DisablePhysics); |
||
148 | dispList.AddRow("Disable scripts", rs.DisableScripts); |
||
149 | dispList.AddRow("Restrict pushing", rs.RestrictPushing); |
||
150 | dispList.AddRow("Fixed sun", rs.FixedSun); |
||
151 | dispList.AddRow("Sun position", rs.SunPosition); |
||
152 | dispList.AddRow("Sun vector", rs.SunVector); |
||
153 | dispList.AddRow("Use estate sun", rs.UseEstateSun); |
||
154 | dispList.AddRow("Telehub UUID", rs.TelehubObject); |
||
155 | dispList.AddRow("Terrain lower limit", string.Format("{0} m", rs.TerrainLowerLimit)); |
||
156 | dispList.AddRow("Terrain raise limit", string.Format("{0} m", rs.TerrainRaiseLimit)); |
||
157 | dispList.AddRow("Water height", string.Format("{0} m", rs.WaterHeight)); |
||
158 | |||
159 | dispList.AddRow("Maptile static file", ri.MaptileStaticFile); |
||
160 | dispList.AddRow("Maptile static UUID", ri.MaptileStaticUUID); |
||
161 | dispList.AddRow("Last map refresh", ri.lastMapRefresh); |
||
162 | dispList.AddRow("Last map UUID", ri.lastMapUUID); |
||
163 | |||
164 | dispList.AddToStringBuilder(sb); |
||
165 | |||
166 | MainConsole.Instance.Output(sb.ToString()); |
||
167 | } |
||
168 | |||
169 | private void HandleShowScene(string module, string[] cmd) |
||
170 | { |
||
171 | if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene)) |
||
172 | return; |
||
173 | |||
174 | SimStatsReporter r = m_scene.StatsReporter; |
||
175 | float[] stats = r.LastReportedSimStats; |
||
176 | |||
177 | float timeDilation = stats[0]; |
||
178 | float simFps = stats[1]; |
||
179 | float physicsFps = stats[2]; |
||
180 | float agentUpdates = stats[3]; |
||
181 | float rootAgents = stats[4]; |
||
182 | float childAgents = stats[5]; |
||
183 | float totalPrims = stats[6]; |
||
184 | float activePrims = stats[7]; |
||
185 | float totalFrameTime = stats[8]; |
||
186 | // float netFrameTime = stats.StatsBlock[9].StatValue; // Ignored - not used by OpenSimulator |
||
187 | float physicsFrameTime = stats[10]; |
||
188 | float otherFrameTime = stats[11]; |
||
189 | // float imageFrameTime = stats.StatsBlock[12].StatValue; // Ignored |
||
190 | float inPacketsPerSecond = stats[13]; |
||
191 | float outPacketsPerSecond = stats[14]; |
||
192 | float unackedBytes = stats[15]; |
||
193 | // float agentFrameTime = stats.StatsBlock[16].StatValue; // Not really used |
||
194 | float pendingDownloads = stats[17]; |
||
195 | float pendingUploads = stats[18]; |
||
196 | float activeScripts = stats[19]; |
||
197 | float scriptLinesPerSecond = stats[20]; |
||
198 | |||
199 | StringBuilder sb = new StringBuilder(); |
||
200 | sb.AppendFormat("Scene statistics for {0}\n", m_scene.RegionInfo.RegionName); |
||
201 | |||
202 | ConsoleDisplayList dispList = new ConsoleDisplayList(); |
||
203 | dispList.AddRow("Time Dilation", timeDilation); |
||
204 | dispList.AddRow("Sim FPS", simFps); |
||
205 | dispList.AddRow("Physics FPS", physicsFps); |
||
206 | dispList.AddRow("Avatars", rootAgents); |
||
207 | dispList.AddRow("Child agents", childAgents); |
||
208 | dispList.AddRow("Total prims", totalPrims); |
||
209 | dispList.AddRow("Scripts", activeScripts); |
||
210 | dispList.AddRow("Script lines processed per second", scriptLinesPerSecond); |
||
211 | dispList.AddRow("Physics enabled prims", activePrims); |
||
212 | dispList.AddRow("Total frame time", totalFrameTime); |
||
213 | dispList.AddRow("Physics frame time", physicsFrameTime); |
||
214 | dispList.AddRow("Other frame time", otherFrameTime); |
||
215 | dispList.AddRow("Agent Updates per second", agentUpdates); |
||
216 | dispList.AddRow("Packets processed from clients per second", inPacketsPerSecond); |
||
217 | dispList.AddRow("Packets sent to clients per second", outPacketsPerSecond); |
||
218 | dispList.AddRow("Bytes unacknowledged by clients", unackedBytes); |
||
219 | dispList.AddRow("Pending asset downloads to clients", pendingDownloads); |
||
220 | dispList.AddRow("Pending asset uploads from clients", pendingUploads); |
||
221 | |||
222 | dispList.AddToStringBuilder(sb); |
||
223 | |||
224 | MainConsole.Instance.Output(sb.ToString()); |
||
225 | } |
||
226 | } |
||
227 | } |