Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Presentations SimPerformanceCollector_Web_and_RRD  

SimPerformanceCollector_Web_and_RRD

This is the lsl-script. Rezz a box, texture it like a server and place it elsewhere on the sim. No need to be a simowner, no need to deed this prim.
This script collects the internal grabable informations: FPS, DIL, servername and simname and sends it via HTTP to a PHP-Script on your website. The PHP-script is below. Attention! Watch, that the path to your php-script is correct!

Category: Presentations
By : denise
Created: 2011-03-08 Edited: 2011-03-08
Worlds: Second Life

the Zip file

Download all files for SimPerformanceCollector_Web_and_RRD
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. SimPerformanceCollector_Web_and_RRD_1.lsl
Get file # 2. SimPerformanceCollector_Web_and_RRD_2.lsl
Get file # 3. SimPerformanceCollector_Web_and_RRD_3.lsl
Get file # 4. SimPerformanceCollector_Web_and_RRD_4.lsl
1 integer Count; // counter for averaging FPS
2 integer FPS_Total; // total fps for averaging
3 key SimStatusQuery;
4 string simstatus; //Needed to show Simstatus on Website
5 string RegName = "";
6 string url_inform;
7 string website = "http://www.yourdomainhere.de/php/write_rrd.php";
8 string avg;
9 string fps_condition;
10 string dil_cond;
11 string s_count;
12 string server;
13 float TimeDil;
14
15 send_data(float dil, integer fps)
16 {
17 //fps = fps - 10; //just for testing!
18 //dil = dilationtime;
19 url_inform = llHTTPRequest(website,[HTTP_METHOD,"POST",HTTP_MIMETYPE, "application/x-www-form-urlencoded"],"dil="+(string)dil+"&fps="+(string)fps+"®ion="+RegName+"&server="+server+"&method=set");
20 }
21
22 default
23 {
24
26 {
27 RegName = llGetRegionName();
29 Count = 0;
30 FPS_Total = 0;
31
32 llSetText("Collecting Performance-Data for \n" + llGetSimulatorHostname() + "\n" + RegName + "...",<1,0,0>,1);
33 llSetTimerEvent(60.0);
34 }
35
36 on_rez(integer peram)
37 {
39 }
40
41 timer()
42 {
43 Count += 1;
44 integer RegFPS = llFloor(llGetRegionFPS());
45 FPS_Total += RegFPS;
46 integer avgFPS = FPS_Total / Count;
47 avg = (string)avgFPS;
48 RegName = llGetRegionName();
49 TimeDil = llGetRegionTimeDilation();
50 s_count = (string)Count;
51
52 SimStatusQuery = llRequestSimulatorData(RegName, DATA_SIM_STATUS);
53
54 send_data((float)TimeDil,(integer)RegFPS);
55 //simstatus == "up"/"down"/"starting"/"stopping"/"crashed"/"unknown"
56 }
57
58 http_response(key id, integer status, list meta, string body)
59 {
60 //llSay(0,body);
61 string result;
62 if(id==url_inform)
63 {
64 integer stringpartposition = llSubStringIndex(body,"result = ");
65 if(stringpartposition != 0)
66 {
67 result = llGetSubString(body,stringpartposition + 9,-1);
69
70 if(result == "ERROR occured")
71 {
72 llInstantMessage(llGetOwner(),"An error has occured with the Simperformance-Grapher for sim " + RegName + "! Check the rrd and the PHP-Script!");
73 }
74 }
75 }
76 }
77
78 dataserver(key queryId, string data)
79 {
80 if(queryId == SimStatusQuery) {
81 SimStatusQuery = "";
82 simstatus = (data);
83 }
84 }
85 }

SimPerformanceCollector_Web_and_RRD

On your server lets create the rrd's (Round Robin Databases) --> http://www.mrtg.org/rrdtool/
Here are the commands to create a rrd. Let me first say, that I have very less knowledge on rrd's what I have created is an overview for a day. if somebody is able to make it much much better, PLEASE let me know!
IMPORTANT: The synonym "nameofyoursim" has to be replaced exactly with the simname! The php-script get's the simname and adds only a "_dilfps.rrd" so watch

Category: Presentations
By : denise
Created: 2011-03-08 Edited: 2011-03-08
Worlds: Second Life

1 /usr/bin/rrdtool create nameofyoursim_dilfps.rrd --step 600 DS:dil:GAUGE:600:0:1 DS:fps:GAUGE:600:0:50 \
2 RRA:AVERAGE:0.5:1:5040 RRA:AVERAGE:0.5:12:9600
3
4 The ping-database will be created with:
5
6 /usr/bin/rrdtool create NDL_FeEseGrimLa_ping.rrd --step 300 DS:ping:GAUGE:300:0:1 RRA:AVERAGE:0.5:1:5040 RRA:AVERAGE:0.5:12:9600

SimPerformanceCollector_Web_and_RRD

This is the PHP-script which is called by the lsl-script. It takes the data, pings the server and put all data into the rrd's

Category: Presentations
By : denise
Created: 2011-03-08 Edited: 2011-03-08
Worlds: Second Life

1 <?php
2
3 $method = $_POST['method'];
4 $dil = $_POST['dil'];
5 $fps = $_POST['fps'];
6 $region = $_POST['region'];
7 $server = $_POST['server'];
8 $path = "/home/n/ndlsim.de/php/cms/php/";
9
10
11 if($method=="")
12 {
13 die("result = No Method provided!");
14 }
15
16 if($region=="")
17 {
18 die("result = No region provided!");
19 //alerts script in SL not to send any data any more and to inform the owner about this damn error... :)
20 } else {
21 $region = str_replace(" ","_",$region);
22 $RRDFILE = $path.$region."_dilfps.rrd";
23 $RRDFILE_ping = $path.$region."_ping.rrd";
24 }
25
26 echo ("result = $server");
27 $resultping = shell_exec("/bin/ping $server -c 1");
28 $var1 = strpos($resultping, "time=");
29 $ping = trim((substr($resultping,$var1+5,3)));
30
31
32 if($method=="set")
33 {
34
35 //write data into rrd's
36
37 $ret = exec("/usr/bin/rrdtool update $RRDFILE -t dil:fps N:$dil:$fps");
38 if( $ret1 != 0 )
39 {
40 die ("result = ERROR occurred");
41 }
42 // echo "result = /usr/bin/rrdtool update $RRDFILE -t dil:fps N:$dil:$fps";
43
44 $ret = exec("/usr/bin/rrdtool update $RRDFILE_ping -t ping N:$ping");
45 if( $ret2 != 0 )
46 {
47 die ("result = ERROR occurred");
48 }
49 // echo ("result = /usr/bin/rrdtool update $RRDFILE_ping -t ping N:$ping");
50 //echo ("result = $ping");
51
52 }
53 ?>

SimPerformanceCollector_Web_and_RRD

And last but not least, we have to build the graph from the data. it's a bash-script (Linux) which create the graphs.

Category: Presentations
By : denise
Created: 2011-03-08 Edited: 2011-03-08
Worlds: Second Life

1 #!/bin/bash
2 #
3 RRDFILE=/home/n/ndlsim.de/php/cms/php/yoursimnamehere_dilfps.rrd
4 RRDPING=/home/n/ndlsim.de/php/cms/php/yoursimnamehere_ping.rrd
5
6 GRAPHFILE1=/home/n/ndlsim.de/php/cms/bilder/yoursimname_DIL.png
7 GRAPHFILE2=/home/n/ndlsim.de/php/cms/bilder/yoursimname_FPS.png
8 GRAPHFILE3=/home/n/ndlsim.de/php/cms/bilder/yoursimname_ping.png
9
10 rrdtool graph $GRAPHFILE1 -v "Dilation" \
11 -u 1.1 -l 0 \
12 -t "Dilation Time for yoursim" \
13 DEF:dil=$RRDFILE:dil:AVERAGE LINE2:dil#309030:"Dilation Time" \
14 HRULE:1.0#AAAA00:"Performace best / Performance sehr gut" \
15 HRULE:0.8#0000FF:"Performace ok / Performance gut" \
16 HRULE:0.5#FF0000:"Lagging expected / Lag zu erwarten" \
17 COMMENT:"\\n" \
18 COMMENT:"(Last updated\: $(/bin/date "+%d.%m.%Y %H\:%M\:%S"))\r" \
19 -w 600 -h 200 -a PNG
20
21 rrdtool graph $GRAPHFILE2 -v "FPS" \
22 -u 50.0 -l 0 \
23 -t "Frames Per Second for yoursim" \
24 DEF:fps=$RRDFILE:fps:AVERAGE LINE2:fps#309030:"Frames Per Second" \
25 HRULE:44#AAAA00:"Performace best / Performance sehr gut" \
26 HRULE:35#0000FF:"Performance ok /Performance gut" \
27 HRULE:20#FF0000:"Lagging / Lag" \
28 HRULE:10#FF0000:"Terrible / Katastrophal" \
29 COMMENT:"\\n" \
30 COMMENT:"(Last updated\: $(/bin/date "+%d.%m.%Y %H\:%M\:%S"))\r" \
31 -w 600 -h 200 -a PNG
32
33 rrdtool graph $GRAPHFILE3 -v "PING-Time" \
34 -u 200.0 -l 60 \
35 -t "PING-Time for yoursim" \
36 DEF:ping=$RRDPING:ping:AVERAGE LINE2:ping#309030:"PING in ms" \
37 HRULE:90#AAAA00:"Performace best / Performance sehr gut" \
38 HRULE:140#0000FF:"Performance ok /Performance gut" \
39 HRULE:190#FF0000:"Lagging / Lag" \
40 COMMENT:"\\n" \
41 COMMENT:"(Last updated\: $(/bin/date "+%d.%m.%Y %H\:%M\:%S"))\r" \
42 -w 600 -h 200 -a PNG

Back to the Best Free Tools in Second Life and OpenSim.