Remotely manage my server

Post your questions here
Post Reply
Toham
Posts: 7
Joined: Tue Apr 10, 2012 2:13 pm
Team: Privateer

Remotely manage my server

Post by Toham »

Hello every one,

I'm french then excuse me for mistakes !

I'm web developer and I create a web application to manage my MXS Server. My question is : How is manage results of server ? Does the file is modified in real time or is it edited to change each track ?

And an other question ? What is the "normallap" in the result file ? "Times" is the time accrued of each ckeckpoint ? And "normallap" is the number of checkpoints ?

Example :

Code: Select all

dir=testtrack
longname=testtrack
firstlap=19
normallap=19
holeshotindex=1
time=0
laps=5
starttime=1785
date=1334008818
players:
slot=1
uid=XXXX
number=42
bike=yz250f(2009)
name=Toham #42
times:
1 0 2554
1 1 3068
1 2 3626
1 3 3990
1 4 4333
1 5 5034
1 6 5352
1 7 5942
1 8 8336
1 9 8784
1 10 9517
1 11 10187
1 12 12051
1 13 12673
1 14 13072
1 15 13499
1 16 13902
1 17 14197
1 18 14627
1 19 14917
1 20 16452
1 21 17063
1 22 17409
1 23 20125
1 24 20438
1 25 22619
1 26 23282
1 27 25069
1 28 26628
1 29 27378
1 30 28106
1 31 29818
1 32 30690
1 33 31361
1 34 31883
1 35 32263
1 36 33299
1 37 34142
1 38 34498
First lap : 14917 - 1785 = 13132 ms
Second lap : 34498 - 13132 = 21366 ms

Is this the right calculation ?

Thanks
jlv
Site Admin
Posts: 15482
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Remotely manage my server

Post by jlv »

The results file is opened and truncated when the race starts. The times are appended to the file as the server receives them. It's possible for them to show up out of order so your script needs to be prepared for that.

"firstlap" is the number of gates in the first lap (from the starting gate to the finish line). "normallap" is the number of gates for a regular lap (from the first gate after the finish to the finish).

Each line after "times:" is <slot> <gate count from 0> <time in 1/128 second units>.
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
Toham
Posts: 7
Joined: Tue Apr 10, 2012 2:13 pm
Team: Privateer

Re: Remotely manage my server

Post by Toham »

Thanks !
Each line after "times:" is <slot> <gate count from 0> <time in 1/128 second units>.
You have answered at all my questions, thanks a lot
Toham
Posts: 7
Joined: Tue Apr 10, 2012 2:13 pm
Team: Privateer

Re: Remotely manage my server

Post by Toham »

Sorry, i'm not find the function to edit a reply.

How I can save all results ? Because, if the result file is truncated when the race starts, I can't save a backup for the result for the precedent race.

I suppose that the algorythm which calculate results on the official website is not open source ?
Toham
Posts: 7
Joined: Tue Apr 10, 2012 2:13 pm
Team: Privateer

Re: Remotely manage my server

Post by Toham »

I can see a command line: --results-cmd XXXX.pl

if I understand correctly, the end of each race will run the script. So we can collect all the statistics of every race. Would it be possible to have a small example of the script? Should it be mandatory in PEARL or may it be done in PHP ?

Thanks for all
jlv
Site Admin
Posts: 15482
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Remotely manage my server

Post by jlv »

You can use whatever scripting language you like as long as your OS can execute it. Here's the bash script I use for uploading results. All you really need is the curl command.

Code: Select all

#!/bin/bash

name="$1"
results="$2"
password="$3"

if test -z "$name"
then 
        exit 1
fi

if ! test -f "$results"
then
        exit 1
fi

if test -z "$password"
then 
        exit 1
fi


tmpresults=$(mktemp /tmp/results.XXXXXXXX)

cp -- "$results" $tmpresults

(
curl -s -F "name=$name" -F "password=$password" -F 'results=<'$tmpresults http://mxsimulator.com/uploadresults.php
rm $tmpresults
) >/dev/null &
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
Toham
Posts: 7
Joined: Tue Apr 10, 2012 2:13 pm
Team: Privateer

Re: Remotely manage my server

Post by Toham »

Hi,

This topic helped me but I have an another problems on execution of batch file.

Logs :

Code: Select all

sh: test.bat: command not found
serverargs :

Code: Select all

--port 19814
--results-cmd test.bat
--max-clients 5
--greeting "Gaaaaaaaaaaaaaz !"
--results-file results.txt
--track-interval 1
--password XXXXX
--ban-file bans.txt
--laps 1
trackinfo/alcrest.trackinfo
trackinfo/locust.trackinfo
trackinfo/smithtown.trackinfo
trackinfo/glenside.trackinfo
I already installed cUrl on server and I test in putty this command :

Code: Select all

curl -s "http://XX.XX.XX.XX/~username/test.php"
In test.php, I make a backup from results.txt in Php.

I test a simple command:

Code: Select all

cp results.txt ../path_dir/
Didn't work either.

I come to a halt. If you have an idea, i take it with pleasure :)

Again, sorry for my english...
jlv
Site Admin
Posts: 15482
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Remotely manage my server

Post by jlv »

Based on the "sh: test.bat: command not found" error, I assume you're running Linux. The Windows bat files won't work on Linux. Try the shell script I posted.
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
Toham
Posts: 7
Joined: Tue Apr 10, 2012 2:13 pm
Team: Privateer

Re: Remotely manage my server

Post by Toham »

Your shell script didn't work either. Same error. I don't understand why it doesn't work.
jlv
Site Admin
Posts: 15482
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Remotely manage my server

Post by jlv »

I'll assume you saved the script as "uploadresults.sh" in the same directory you run the server from. To execute the script it needs execute permission (use "chmod +x uploadresults.sh") and since the current directory isn't in your path by default you need to explicitly give the current directory in the pathname -

--results-cmd "./uploadresults.sh my.server.address.com results.txt makeupapassword"
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
Toham
Posts: 7
Joined: Tue Apr 10, 2012 2:13 pm
Team: Privateer

Re: Remotely manage my server

Post by Toham »

It's perfect ! Thanks !
kawy949
Posts: 983
Joined: Sat Feb 11, 2012 11:33 pm
Location: UK
Contact:

Re: Remotely manage my server

Post by kawy949 »

JLV, seem to be having a problem with this.. Nothing I have tried will make this script run for some reason :/ Any ideas?
kawy949
Posts: 983
Joined: Sat Feb 11, 2012 11:33 pm
Location: UK
Contact:

Re: Remotely manage my server

Post by kawy949 »

Sorry, should have mentioned it was the Bash Script I was having issues with.

Thanks
jlv
Site Admin
Posts: 15482
Joined: Fri Nov 02, 2007 5:39 am
Team: No Frills Racing
Contact:

Re: Remotely manage my server

Post by jlv »

If you aren't running Linux the bash script isn't for you.
Josh Vanderhoof
Sole Proprietor
jlv@mxsimulator.com
If you email, put "MX Simulator" in the subject to make sure it gets through my spam filter.
kawy949
Posts: 983
Joined: Sat Feb 11, 2012 11:33 pm
Location: UK
Contact:

Re: Remotely manage my server

Post by kawy949 »

I am running linux, both servers are running on ccool4.me, not to worry I managed to fix it though. commented out the /dev/null to output errors and turns out the file it was posting to was 404'ing... So fixed that now.

Thanks
Post Reply