Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: Simple Sim Beacon

Nyoko Salome
kittytailmeowmeow
Join date: 18 Jul 2005
Posts: 1,378
10-02-2008 10:14
//here's a simple sim beacon that can help you monitor a region's 'uptime'! replace your email address in the llEmail line near the end of the testTime() function. you can change INTminutes and INTsecondsTolerance for benchtesting, but i recommend (based on testing in some very busy locations) that 60 minutes and 30 seconds is very low-impact and all you need to catch any 'simtrips'. :) enjoy! - Nyoko Salome

////////////////////////////////////////////////////////////////////////
///////////// SCRIPT 1 OF 1 SCRIPT 1 OF 1 SCRIPT 1 OF 1 ////////////////
////////////////////////////////////////////////////////////////////////

// -simple sim beacon

// 'very simple' simbeacon that measures time, if est. time is off then sim outage occured...
// :O i can estimate whether it's been a rollback (1hr+), or an update/reset (ideally under 5mins).

integer BLNtesting;//=TRUE;
integer INTminutes=60;//5;
integer INTsecondsTolerance=30;//5;//.033;//5
integer INTtz=-4;

string STRlastTime;
integer INTlastTime;
integer INTseconds;//now calced from mins, only BLNtesting allows shorter seconds worth =60;//5;//60

testMessage(string STRmsg){if(BLNtesting){llOwnerSay(llGetScriptName()+"\ttime: "+(string)llGetTime()+"\tmem: "+(string)llGetFreeMemory()+"\t"+STRmsg+"|";);}}
STRownerSay(string STRmsg){llInstantMessage(llGetOwner(), "PRIVATE MESSAGE: "+STRmsg);}

string STRgetDate(){
string STRtemp=llGetTimestamp();
STRtemp=llDeleteSubString(STRtemp, 10, 26);
STRtemp=llDeleteSubString(STRtemp, 4, 4);
STRtemp=llDeleteSubString(STRtemp, 6, 6);
STRtemp=llDeleteSubString(STRtemp, 0, 1);
return STRtemp;
}
string STRgetTime(integer INTpassTZ){
string STRtemp=llGetTimestamp();
STRtemp=llDeleteSubString(STRtemp, 0, 10);
STRtemp=llDeleteSubString(STRtemp, 8, 15);
string STRrest=llDeleteSubString(STRtemp, 0, 2);
string STRamPm="am";
integer INThrTZ=(integer)llGetSubString(STRtemp, 0, 1);
INThrTZ+=INTpassTZ;
if(INThrTZ<1){
if(INThrTZ<0){STRamPm="pm";}
INThrTZ+=12;
}else if(INThrTZ>11){
STRamPm="pm";
if(INThrTZ>12){INThrTZ-=12;}
}
string STRtest=(string)INThrTZ+":"+STRrest+STRamPm;
return STRtest;
}
testTime(integer BLNpassTest){//false just to reset, true to timertest...
integer INTthisTime=llGetUnixTime();
integer INTdifference=INTthisTime-INTlastTime-INTseconds;
if(BLNpassTest && INTdifference>INTsecondsTolerance){
integer INThrs;
integer INTmins;
integer INTsecs;
if(INTdifference>0){
INThrs=llFloor(INTdifference/60/60);
if(INThrs==0){
INTmins=llFloor(INTdifference/60);
if(INTmins==0){INTsecs=llFloor(INTdifference);
}else{INTsecs=llFloor(INTdifference-(INTmins*60));}
}else{
INTmins=llFloor((INTdifference-(INThrs*60*60))/60);
if(INTmins==0){INTsecs=llFloor(INTdifference-(INThrs*60*60));
}else{INTsecs=llFloor(INTdifference-(INTmins*60)-(INThrs*60*60));}
}
}
string STRmins=(string)INTmins;
if(INTmins<10){STRmins="0"+(string)INTmins;}
string STRsecs=(string)INTsecs;
if(INTsecs<10){STRsecs="0"+(string)INTsecs;}
string STRprognosis="Longer than the usual reset/update; shorter than a rollback...";
if(INThrs>0){STRprognosis="Probably a rollback.";
}else if(INTmins<=5){
if(INTmins<1){STRprognosis="Probably lagout; expand tolerance.";
}else{STRprognosis="Probably a reset/update.";}
}
string STRmsg="Sim outage, est. duration "+(string)INThrs+":"+STRmins+":"+STRsecs+" ("+(string)INTdifference+" seconds) sometime after "+STRlastTime+". "+STRprognosis+" "+STRgetTime(INTtz)+" "+STRgetDate();
if(BLNtesting){STRownerSay(STRmsg);
}else{llEmail("your.email@your.isp", "Sim outage!", STRmsg);}
INTthisTime=llGetUnixTime();//llGetAndResetTime();//need to reset again to make up for email outage
}
INTlastTime=INTthisTime;
STRlastTime=STRgetTime(INTtz)+" "+STRgetDate();
llSetTimerEvent(INTseconds);
}

default{//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
on_rez(integer INT){testMessage("default/on_rez";);llResetScript();}
state_entry(){
testMessage("default/state_entry";);
if(BLNtesting){INTseconds=5;INTsecondsTolerance=0;}else{INTseconds=INTminutes*60;}
testTime(FALSE);
llOwnerSay("simple sim beacon ready! cycle="+(string)INTseconds+" seconds ("+(string)(INTseconds/60)+" minutes); tolerance="+(string)INTsecondsTolerance+" seconds.";);
}
timer(){
if(BLNtesting){llSleep(1.0);}
testTime(TRUE);
}
}
_____________________

Nyoko's Bodyoils @ Nyoko's Wears
http://slurl.com/secondlife/Centaur/126/251/734/
http://home.comcast.net/~nyoko.salome2/nyokosWears/index.html

"i don't spend nearly enough time on the holodeck. i should go there more often and relax." - deanna troi
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Library bump
10-09-2008 07:43
:)
_____________________
i've got nothing. ;)
Nyoko Salome
kittytailmeowmeow
Join date: 18 Jul 2005
Posts: 1,378
:0
10-15-2008 14:11
i forgot to note that the variable 'INTtz' means 'timezone' - you can enter your own offset so that the time-of-occurance feedback'll adjust to your own time... can be much easier to track things that way. enjoy! :) (and please use responsibly ;)
_____________________

Nyoko's Bodyoils @ Nyoko's Wears
http://slurl.com/secondlife/Centaur/126/251/734/
http://home.comcast.net/~nyoko.salome2/nyokosWears/index.html

"i don't spend nearly enough time on the holodeck. i should go there more often and relax." - deanna troi