Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Sim crash/reboot detector/logger

Kyrah Abattoir
cruelty delight
Join date: 4 Jun 2004
Posts: 2,786
01-09-2006 01:01
CODE

/////////////////////////////////////////
//SIM CRASH/REBOOT LOGGER
//by: Kyrah Abattoir
/////////////////////////////////////////

integer timering = 10;//the polling rate, put the speed you wish, in seconds

//there we go...
integer UNIX;
string _buffer;
list log;
integer span = 0;
float fps;
float dilation;
integer crash = 0;
//2004-08-27T00:56:21.785886Z

default
{
state_entry()
{
llSetTimerEvent(timering);//starting our timer
}
timer()
{
string timestamp = llGetTimestamp();
list temp = llParseString2List(timestamp,["T",":",":","."],[]);
integer _hour = llList2Integer(temp,1) + 4;
if(_hour > 24) //getting the hours
_hour = _hour - 24 ;

string _date = llList2String(temp,0);
integer _min = llList2Integer(temp,2);
integer _sec = llList2Integer(temp,3);
string buffer;

if(date == _date) //daily reset of the average fps and dilation
span++;
else
{
span = 1;
date = _date;
fps = 0;
dilation = 0;
}

fps += llGetRegionFPS();
dilation += llGetRegionTimeDilation();
integer avg_FPS = (integer)(fps/span);
string avg_dilation= llGetSubString((string)(dilation/span),0,3);

buffer += llGetRegionName();
buffer += "\n FPS:"+(string)avg_FPS;
buffer += " dil. :"+(string)avg_dilation;
//buffer += "\n" + llDumpList2String(log,"\n");

integer _UNIX = _sec + _min * 60 + _hour * 3600;//making our timestamp

if (_UNIX - UNIX > timering + 5 && UNIX != 0)//okay the tdelay has been waaay too olong, it probably crashed or rebooted
{
crash++;
log += (string)_date + " - " + (string)_hour+ ":"+(string)_min+":"+(string)_sec;
if(llGetListLength(log) > 9)
log = llDeleteSubList(log,0,0);
}
buffer += "\n sim crashes: " + (string)crash + "\n last crash: \n" + llDumpList2String(log,"\n");
if(_buffer != buffer); //display
{
llSetText(buffer,<1,1,1>,1.0);
_buffer = buffer;
}
UNIX = _UNIX;
}
}


i am not sure about a few variables, if one is undeclared, jsut declare it as global, it just mean i stripped too much code when writing it here
_____________________

tired of XStreetSL? try those!
apez http://tinyurl.com/yfm9d5b
metalife http://tinyurl.com/yzm3yvw
metaverse exchange http://tinyurl.com/yzh7j4a
slapt http://tinyurl.com/yfqah9u
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Message
01-09-2006 22:17
/15/3a/81552/1.html
_____________________
i've got nothing. ;)
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
01-10-2006 00:35
"date" isn't defined.
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
Kyrah Abattoir
cruelty delight
Join date: 4 Jun 2004
Posts: 2,786
01-12-2006 11:02
thanks ^^ fixed it , i had to remove a few junks from the script and wasnt sure what i might have forgot
_____________________

tired of XStreetSL? try those!
apez http://tinyurl.com/yfm9d5b
metalife http://tinyurl.com/yzm3yvw
metaverse exchange http://tinyurl.com/yzh7j4a
slapt http://tinyurl.com/yfqah9u
Jesrad Seraph
Nonsense
Join date: 11 Dec 2004
Posts: 1,463
01-12-2006 14:04
Thanks, it works great :)
_____________________
Either Man can enjoy universal freedom, or Man cannot. If it is possible then everyone can act freely if they don't stop anyone else from doing same. If it is not possible, then conflict will arise anyway so punch those that try to stop you. In conclusion the only strategy that wins in all cases is that of doing what you want against all adversity, as long as you respect that right in others.
Drew Ogg
Registered User
Join date: 17 May 2006
Posts: 1
08-12-2006 05:18
sorry, where do I apply the "^^" ?
nand Nerd
Flexi Fanatic
Join date: 4 Oct 2005
Posts: 427
08-12-2006 07:11
Drew, I believe the "^^" was an emote and that Kyrah has updated the code at the top of this page.
_____________________
www.nandnerd.info
http://ordinalmalaprop.com/forum - Ordinal Malaprop's Scripting Forum
Dragon Eccleston
Registered User
Join date: 25 Dec 2005
Posts: 42
08-12-2006 20:53
I think I might change it as follows:

From: Kyrah Abattoir
CODE

/////////////////////////////////////////
//SIM CRASH/REBOOT LOGGER
//by: Kyrah Abattoir
/////////////////////////////////////////

integer timering = 10;//the polling rate, put the speed you wish, in seconds

//there we go...
integer UNIX;
string _buffer;
list log;
integer span = 0;
float fps;
float dilation;
integer crash = 0;
string date;
//2004-08-27T00:56:21.785886Z
string region_name; //no need to look this up every time, it's probably stationary.

default
{
state_entry()
{
region_name = llGetRegionName();
UNIX = llGetUnixTime();
llSetTimerEvent(timering);//starting our timer
}
timer()
{
string _date = llGetDate();
string buffer;

if(date == _date) //daily reset of the average fps and dilation
span++;
else
{
span = 1;
date = _date;
fps = 0;
dilation = 0;
}

fps += llGetRegionFPS();
dilation += llGetRegionTimeDilation();
//integer avg_FPS = (integer)(fps/span); lets just move these two down where they're used
//string avg_dilation= llGetSubString((string)(dilation/span),0,3);

buffer += region_name;
buffer += "\n FPS:"+(string)((integer)(fps/span));
buffer += " dil. :"+llGetSubString((string)(dilation/span),0,3);
//buffer += "\n" + llDumpList2String(log,"\n");

integer _UNIX = llGetUnixTime();

if (_UNIX - UNIX > timering + 5)//okay the tdelay has been waaay tooo long, it probably crashed or rebooted
{
integer time = llGetWallclock();
crash++;
log += date + " - " + (string)(time / 3600)+ ":"+(string)(time % 3600 / 60)+":"+(string)(time % 60);
if(llGetListLength(log) > 9)
log = llDeleteSubList(log,0,0);
}
buffer += "\n sim crashes: " + (string)crash + "\n last crash: \n" + llDumpList2String(log,"\n");
if(_buffer != buffer); //display
{
llSetText(buffer,<1,1,1>,1.0);
_buffer = buffer;
}
UNIX = _UNIX;
}
}


No need for nasty list manipulations to do what a simple LSL function does automatically, can do a bit more math during the crash instead of all that math every test mostly needlessly.
Markus Brendel
Registered User
Join date: 16 Oct 2006
Posts: 13
12-14-2007 06:04
I am getting a Error: Name not Defined within scope at (36,8) "if(date == _date)"

Am I doin something wrong here?
Atashi Toshihiko
Frequently Befuddled
Join date: 7 Dec 2006
Posts: 1,423
12-14-2007 08:47
Can someone please help me to understand the theory behind how this script determines if a crash or reboot has taken place?

From what I can see, it's looking at the Unix time every ten seconds, and comparing that against the unix time it captured ten seconds previously.. and if the difference between the current time and the previous time is greater than 15 seconds, it decides a crash or restart has occured?

So if it checks and sees it's 11:42:40 and then next time it checks and sees it's 11:42:50 then it knows that there was no crash. But if the next result is 11:43:17 then that's a 37 second difference, so it flags this as a sim crash/reboot?

Sorry if I'm being a simpleton - I'm not thinking well this morning and just want to make sure I understand how this is supposed to work. Thanks in advance!

-Atashi

p.s. Markus, I think date is uninitialized, at the top where it says:
string date;
change it to:
string date="";
and that should fix it.
_____________________
Visit Atashi's Art and Oddities Store and the Waikiti Motor Works at beautiful Waikiti.
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
12-14-2007 12:54
I think Kyrah's Comment in the code says it all:

"//okay the tdelay has been waaay too long, it probably crashed or rebooted"

So yes, your assessment is correct.
_____________________
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
12-14-2007 15:58
The one we use for the sims at the Isle of Wyrms that feeds this database simply uses a timer and an updated unix timestamp stored in memory to determine if script performance is so poor as to cause the sim to either appear crashed to users, or if it actually did crash. To determine the difference between a hard crash and a lag-out, it checks to see if it is on the same simulator.

Been working for well over a year now, and the data appears very reliable. I also use a sim status monitor which queries the sim states via llRequestSimulatorData and DATA_SIM_STATUS, noting any changes. Between the two systems, I get a pretty detailed picture of our region states over time.