Difference between revisions of "Sim Restart Logger"
Huney Jewell (talk | contribs) (Published renewed script) |
Huney Jewell (talk | contribs) (Script modifications: Truncated log display fixed; log start date added to hovertext) |
||
Line 18: | Line 18: | ||
//******************************************************** | //******************************************************** | ||
// This Script was pulled out for you by YadNi Monde from the SL FORUMS at | // This Script was pulled out for you by YadNi Monde from the SL FORUMS at | ||
// http://forums.secondlife.com/ | // http://forums.secondlife.com/forumdisplay.php?f=15, it is intended to stay FREE by it's author(s) | ||
// and all the comments here in ORANGE must NOT be deleted. They include notes on how to use it | // and all the comments here in ORANGE must NOT be deleted. They include notes on how to use it | ||
// and no help will be provided either by YadNi Monde or it's Author(s). | // and no help will be provided either by YadNi Monde or it's Author(s). | ||
Line 28: | Line 28: | ||
// by: Kyrah Abattoir | // by: Kyrah Abattoir | ||
// Updated by: Huney Jewell | // Updated by: Huney Jewell | ||
// Changed: Achieving more accurate information about | // January 2010: | ||
// CHANGED_REGION_START flag in 'changed' event instead of approximation by checking for poor script performance | // Fixed: Log display truncated if more than 5 entries due to llSetText length restriction | ||
// Added | // Added: Log start date | ||
// Added: Code to easily specify appearance of hovertext | |||
// July 2009: | |||
// Changed: Achieving more accurate information about SIM restarts to log data by checking the newly introduced | |||
// CHANGED_REGION_START flag in 'changed' event instead of approximation by checking for poor script performance | |||
// Added: Last FPS and dilation values to hover text | |||
///////////////////////////////////////// | ///////////////////////////////////////// | ||
// GLOBALS | // GLOBALS | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
// User adjustable settings | // User adjustable settings | ||
float timering = 120; //the polling rate | float timering = 120; // Sets the polling rate. Put the speed you wish, in seconds | ||
vector blue = <0,0,1>; | |||
vector orange = <1,0.5,0>; | |||
vector cyan = <0,1,1>; | |||
vector pink = <1,0.5,0.76>; | |||
vector green = <0,1,0>; | |||
vector red = <1,0,0>; | |||
vector white = <1,1,1>; | |||
vector yellow = <1,1,0.1>; | |||
vector purple = <1,0,1>; | |||
vector black = <0,0,0>; | |||
vector hoverColor = white; // Sets the color the text will show. Use predefined colors or any RGB color vector in float form | |||
float hoverAlpha = 1.0; // Sets the text's transparency, 1.0 being SOLID, while 0 would be clear | |||
// System settings - Do Not Change Anything Below! | // System settings - Do Not Change Anything Below! | ||
string _buffer | string _buffer = ""; | ||
list log | list log = []; | ||
string region_name; | string region_name; | ||
integer span; | integer span; | ||
float fps_avg; | float fps_avg; | ||
float dilation_avg; | float dilation_avg; | ||
integer restarts = 0; | integer restarts = 0; | ||
string date | string startDate; | ||
string date = ""; | |||
//2004-08-27T00:56:21.785886Z | //2004-08-27T00:56:21.785886Z | ||
// FUNCTIONS | // FUNCTIONS | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
string FormatDecimal(float number, integer precision) | string FormatDecimal(float number, integer precision) | ||
Line 71: | Line 90: | ||
string strNumber = (string)rounded; | string strNumber = (string)rounded; | ||
return llGetSubString(strNumber, 0, llSubStringIndex(strNumber, ".") + precision); | return llGetSubString(strNumber, 0, llSubStringIndex(strNumber, ".") + precision); | ||
} | |||
hoverText() | |||
{ | |||
string _date = llGetDate(); | |||
if(date == _date) | |||
span++; | |||
else // daily reset of the average FPS and dilation | |||
{ | |||
span = 1; | |||
date = _date; | |||
fps_avg = 0; | |||
dilation_avg = 0; | |||
} | |||
float fps = llGetRegionFPS(); | |||
fps_avg += fps; | |||
float dilation = llGetRegionTimeDilation(); | |||
dilation_avg += dilation; | |||
string buffer = ""; | |||
buffer += region_name + "\nFPS avg: " + FormatDecimal(fps_avg/span, 0) | |||
+ ", last: " + FormatDecimal(fps, 0); | |||
buffer += "\nDilation avg: " + FormatDecimal(dilation_avg/span, 2) | |||
+ ", last: " + FormatDecimal(dilation, 2); | |||
buffer += "\nSim restarts (since " + startDate + "): " + (string)restarts | |||
+ "\nLast restarts (UTC): \n" + llDumpList2String(log,"\n"); | |||
if(_buffer != buffer) | |||
{ // display changed hovertext | |||
llSetText(buffer, hoverColor, hoverAlpha); | |||
_buffer = buffer; | |||
} | |||
} | } | ||
// CODE ENTRY | // CODE ENTRY | ||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | ||
default | default | ||
Line 81: | Line 131: | ||
state_entry() | state_entry() | ||
{ | { | ||
region_name = llGetRegionName(); | region_name = llGetRegionName(); | ||
startDate = llGetDate(); | |||
hoverText(); // display hover text | |||
llSetTimerEvent(timering); // starting our timer | |||
} | } | ||
Line 101: | Line 151: | ||
log += llList2String(temp,0) + " - " + llList2String(temp,1) + ":" | log += llList2String(temp,0) + " - " + llList2String(temp,1) + ":" | ||
+ llList2String(temp,2) + ":" + llList2String(temp,3); | + llList2String(temp,2) + ":" + llList2String(temp,3); | ||
if(llGetListLength(log) > | if(llGetListLength(log) > 5) // limit log entries to avoid hovertext truncation | ||
log = llDeleteSubList(log,0,0);} | log = llDeleteSubList(log,0,0); | ||
} | |||
} | } | ||
timer() | timer() | ||
{ | { | ||
hoverText(); // display hover text | |||
} | } | ||
} | }</lsl> | ||
</lsl> | |||
--[[User:Huney Jewell|Huney Jewell]] 12:46, 22 July 2009 (UTC) | --[[User:Huney Jewell|Huney Jewell]] 12:46, 22 July 2009 (UTC) | ||
{{LSLC|Library}} | {{LSLC|Library}} |
Revision as of 06:17, 6 January 2010
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Counts region restarts and displays log of last 9 restarts together with region FPS and dilation.
Updated version: Achieves accurate information about Sim restarts by checking the newly introduced CHANGED_REGION_START flag in 'changed' event to log data instead of previous version's method of approximating restarts by checking for poor script performance.
Requirements:
- Place this script into a single prim and decorate to taste.
Operation:
- No special instructions. It operates stand alone once installed.
<lsl> //******************************************************** // This Script was pulled out for you by YadNi Monde from the SL FORUMS at // http://forums.secondlife.com/forumdisplay.php?f=15, it is intended to stay FREE by it's author(s) // and all the comments here in ORANGE must NOT be deleted. They include notes on how to use it // and no help will be provided either by YadNi Monde or it's Author(s). // IF YOU DO NOT AGREE WITH THIS JUST DONT USE!!! //********************************************************
///////////////////////////////////////// // SIM CRASH/REBOOT LOGGER // by: Kyrah Abattoir // Updated by: Huney Jewell // January 2010: // Fixed: Log display truncated if more than 5 entries due to llSetText length restriction // Added: Log start date // Added: Code to easily specify appearance of hovertext // July 2009: // Changed: Achieving more accurate information about SIM restarts to log data by checking the newly introduced // CHANGED_REGION_START flag in 'changed' event instead of approximation by checking for poor script performance // Added: Last FPS and dilation values to hover text /////////////////////////////////////////
// GLOBALS //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// User adjustable settings
float timering = 120; // Sets the polling rate. Put the speed you wish, in seconds vector blue = <0,0,1>; vector orange = <1,0.5,0>; vector cyan = <0,1,1>; vector pink = <1,0.5,0.76>; vector green = <0,1,0>; vector red = <1,0,0>; vector white = <1,1,1>; vector yellow = <1,1,0.1>; vector purple = <1,0,1>; vector black = <0,0,0>;
vector hoverColor = white; // Sets the color the text will show. Use predefined colors or any RGB color vector in float form float hoverAlpha = 1.0; // Sets the text's transparency, 1.0 being SOLID, while 0 would be clear
// System settings - Do Not Change Anything Below!
string _buffer = ""; list log = []; string region_name; integer span; float fps_avg; float dilation_avg; integer restarts = 0; string startDate; string date = ""; //2004-08-27T00:56:21.785886Z
// FUNCTIONS //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
string FormatDecimal(float number, integer precision) {
float roundingValue = llPow(10, -precision)*0.5; float rounded; if (number < 0) rounded = number - roundingValue; else rounded = number + roundingValue;
if (precision < 1) // Rounding integer value { integer intRounding = (integer)llPow(10, -precision); rounded = (integer)rounded/intRounding*intRounding; precision = -1; // Don't truncate integer value }
string strNumber = (string)rounded; return llGetSubString(strNumber, 0, llSubStringIndex(strNumber, ".") + precision);
}
hoverText() {
string _date = llGetDate(); if(date == _date) span++; else // daily reset of the average FPS and dilation { span = 1; date = _date; fps_avg = 0; dilation_avg = 0; }
float fps = llGetRegionFPS(); fps_avg += fps; float dilation = llGetRegionTimeDilation(); dilation_avg += dilation; string buffer = ""; buffer += region_name + "\nFPS avg: " + FormatDecimal(fps_avg/span, 0) + ", last: " + FormatDecimal(fps, 0); buffer += "\nDilation avg: " + FormatDecimal(dilation_avg/span, 2) + ", last: " + FormatDecimal(dilation, 2); buffer += "\nSim restarts (since " + startDate + "): " + (string)restarts + "\nLast restarts (UTC): \n" + llDumpList2String(log,"\n"); if(_buffer != buffer) { // display changed hovertext llSetText(buffer, hoverColor, hoverAlpha); _buffer = buffer; }
}
// CODE ENTRY
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
default {
state_entry() { region_name = llGetRegionName(); startDate = llGetDate(); hoverText(); // display hover text llSetTimerEvent(timering); // starting our timer }
on_rez(integer num) { llResetScript(); }
changed(integer change) { if (change & CHANGED_REGION_START) { // log region restart restarts++; string timestamp = llGetTimestamp(); list temp = llParseString2List(timestamp,["T",":","."],[]); log += llList2String(temp,0) + " - " + llList2String(temp,1) + ":" + llList2String(temp,2) + ":" + llList2String(temp,3); if(llGetListLength(log) > 5) // limit log entries to avoid hovertext truncation log = llDeleteSubList(log,0,0); } }
timer() { hoverText(); // display hover text }
}</lsl>
--Huney Jewell 12:46, 22 July 2009 (UTC)