View Single Post
  #1  
Unread 3rd March, 2005, 01:30 PM
Rush's Avatar
Rush Rush is offline
Holy Shit!!
 
Join Date: Apr 2003
Location: Texas
Posts: 1,157
Default Automating UTStats Import

Here are a few ways to make it automated @ GNU/Linux:

1) UTServer and UTStats @ the same BOX, using Cron

Let's prepare the import.php first, open it and comment the 6th line, it should look now like:
Code:
// Get key from web browser
//$adminkey = $_GET[key];
Then uncomment the 13th line:
Code:
$adminkey = $argv[1];
* don't forget about setting the $akey in the 3rd line to somewhat like "mypassword"
*php command may require a full path to the binary for example /usr/local/php5/bin/php

You should try running the script manually first to find out if everything is ok.
Code:
cd /your/utstats/main/path
php import.php "mypassword"
Now you should see some crappy html output and import procedure if there were any logs.

Ok, we're on the good way to make it working. In your /home directory create a script "utstatsimport"
Code:
#!/bin/bash
for file in `ls /your/path/ut-server/Logs/Unreal.ngLog*.log 2> /dev/null`; do
mv $file /your/utstats/main/path/logs > /dev/null
done
cd /your/utstats/main/path
php import.php "mypassword" > /dev/null
*CHANGE THE PATHS TO UTSERVER AND UTSTATS!! don't forget about the password !
.. and make it executable
Code:
chmod +x utstatsimport
*php command may require a full path to the binary for example /usr/local/php5/bin/php

Better check this script on few logs now to avoid searching the mistakes in the future.

Now setting the cron. Create a file called "mycrontab" with this content
Code:
SHELL=/bin/bash
HOME=/home/me

# run-parts
* * * * * ./utstatsimport
*change the home to your own !!!

now the last one is to run a little command in your home:
Code:
crontab ./mycrontab
The script should be runned now about every one minute.
---------
2) UTServer and UTStats @ the same BOX, without Cron(stupid admin)

Use the point's 1 hints to the moment you have to create the utstatsimport script, the script itself has to be different:

Code:
#!/bin/bash
while [ 1 ];do
for file in `ls /your/path/ut-server/Logs/Unreal.ngLog*.log 2> /dev/null`; do
mv $file /your/utstats/main/path/logs > /dev/null
done
cd /your/utstats/main/path
php import.php "mypassword" > /dev/null
sleep 1m
done
*CHANGE THE PATHS TO UTSERVER AND UTSTATS!! don't forget about the password !
*php command may require a full path to the binary for example /usr/local/php5/bin/php

Make it executable
Code:
chmod +x ./utstatsimport
and just run it by
Code:
./utstatsimport &
To stop it use the command
Code:
killall -9 utstatsimport
---------
3) UTServer and UTStats on different boxes .. whatever.

I won't describe how to use the ftp stuff in utstats php part here cause I just don't use it, haha. I'll just tell you how to trigger the import.php script.

3a) With cron ....
Create a script in your home, called "utstatsimport" with content:
Code:
#!/bin/bash
lynx -dump "http://utstats.mydomain.com/import.php?key='mypassword'"  > /dev/null
*Change the mypassword to your own !!!
Make it executable with
Code:
chmod +x ./utstatsimport
Now create a file called "mycrontab" also in your home with this content:
Code:
SHELL=/bin/bash
HOME=/home/me

# run-parts
* * * * * ./utstatsimport
*change the home to your own !!!

now the last thing you should do is to run a little command in your home:
Code:
crontab ./mycrontab
3b)If the admin is lame and you cannot use cron ...

Create a script in your home, called "utstatsimport" with content:
Code:
#!/bin/bash
while [ 1 ];do
lynx -dump "http://utstats.mydomain.com/import.php?key='mypassword'"  > /dev/null
sleep 1m
done
*Change the mypassword to your own !!!
Make it executable with
Code:
chmod +x ./utstatsimport
and just run it by
Code:
./utstatsimport &
. To stop it use the command
Code:
killall -9 utstatsimport
__________________
[email address]

Last edited by Rush : 3rd March, 2005 at 01:40 PM.
Reply With Quote