clockwerk-opensim-stable – Blame information for rev 1

Subversion Repositories:
Rev:
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 scene information for the currently selected region.", HandleShowScene);
85 }
86  
87 public void RemoveRegion(Scene scene)
88 {
89 // m_log.DebugFormat("[REGION COMMANDS MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
90 }
91  
92 public void RegionLoaded(Scene scene)
93 {
94 // m_log.DebugFormat("[REGION COMMANDS MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
95 }
96  
97 private void HandleShowScene(string module, string[] cmd)
98 {
99 if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_scene))
100 return;
101  
102 SimStatsReporter r = m_scene.StatsReporter;
103 float[] stats = r.LastReportedSimStats;
104  
105 float timeDilation = stats[0];
106 float simFps = stats[1];
107 float physicsFps = stats[2];
108 float agentUpdates = stats[3];
109 float rootAgents = stats[4];
110 float childAgents = stats[5];
111 float totalPrims = stats[6];
112 float activePrims = stats[7];
113 float totalFrameTime = stats[8];
114 // float netFrameTime = stats.StatsBlock[9].StatValue; // Ignored - not used by OpenSimulator
115 float physicsFrameTime = stats[10];
116 float otherFrameTime = stats[11];
117 // float imageFrameTime = stats.StatsBlock[12].StatValue; // Ignored
118 float inPacketsPerSecond = stats[13];
119 float outPacketsPerSecond = stats[14];
120 float unackedBytes = stats[15];
121 // float agentFrameTime = stats.StatsBlock[16].StatValue; // Not really used
122 float pendingDownloads = stats[17];
123 float pendingUploads = stats[18];
124 float activeScripts = stats[19];
125 float scriptLinesPerSecond = stats[20];
126  
127 StringBuilder sb = new StringBuilder();
128 sb.AppendFormat("Scene statistics for {0}\n", m_scene.RegionInfo.RegionName);
129  
130 ConsoleDisplayList dispList = new ConsoleDisplayList();
131 dispList.AddRow("Time Dilation", timeDilation);
132 dispList.AddRow("Sim FPS", simFps);
133 dispList.AddRow("Physics FPS", physicsFps);
134 dispList.AddRow("Avatars", rootAgents);
135 dispList.AddRow("Child agents", childAgents);
136 dispList.AddRow("Total prims", totalPrims);
137 dispList.AddRow("Scripts", activeScripts);
138 dispList.AddRow("Script lines processed per second", scriptLinesPerSecond);
139 dispList.AddRow("Physics enabled prims", activePrims);
140 dispList.AddRow("Total frame time", totalFrameTime);
141 dispList.AddRow("Physics frame time", physicsFrameTime);
142 dispList.AddRow("Other frame time", otherFrameTime);
143 dispList.AddRow("Agent Updates per second", agentUpdates);
144 dispList.AddRow("Packets processed from clients per second", inPacketsPerSecond);
145 dispList.AddRow("Packets sent to clients per second", outPacketsPerSecond);
146 dispList.AddRow("Bytes unacknowledged by clients", unackedBytes);
147 dispList.AddRow("Pending asset downloads to clients", pendingDownloads);
148 dispList.AddRow("Pending asset uploads from clients", pendingUploads);
149  
150 dispList.AddToStringBuilder(sb);
151  
152 MainConsole.Instance.Output(sb.ToString());
153 }
154 }
155 }