You are here: Big Brother Bot ForumGeneral CategoryGeneral DiscussionMaking use of heartbeats...
Pages: [1] 2   Go Down
  Print  
Author Topic: Making use of heartbeats...  (Read 1565 times) Bookmark and Share
Support Hero
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: 2x CoD4, 1x BF3
Posts: 2627
Offline Offline
Owner of Host4B3.com - Over 70 bots hosted!
WWW
« on: December 05, 2010, 09:25:25 AM »

Hey all,
I was wondering if there was a way to modify/create/duplicate the heartbeats function so we could check the online status?
Meaning, the bot sends HB to master server daily, great. What about having it also send the HB to a second server (user configurable) every X (maybe 5) minutes (also user configurable) as well. The second server would have a page - same look and layout if possible - with a green/red dot to show online/offline. In short, a "gametracker.com" for B3...

I know it would be nice to find out if my bot is online without logging into terminal. And yes, I do monitor the bot with monit so it should always be online, but I have had some issues in the past.
Logged

Need B3 Bot hosting? Check out Host4B3.com
Check Twitter.com/Host4B3 for updates if the site it down.

Help will be given to those with a b3.log

System: Python 2.7.1 - B3 Source Code - Locally hosted MySQL & Apache - Win 2k3

Senior Dev.
*
OS: Linux
Type: Home user
Posts: 3483
Offline Offline
WWW
Support Specialty: B3-Core, UrT/SmG/BFBC2 parsers, Plugin development
« Reply #1 on: December 05, 2010, 09:30:32 AM »

The status plugin would probably be more suited to monitor your bot/server as it will create a status file every minute (and optionality upload it on your FTP server)
Logged

XLRstats dev.
Dev. Team
*
OS: Linux
Type: Home user
Gameservers: COD5, COD7, BF3
Posts: 947
Offline Offline
WWW
Support Specialty: XLRstats webfront
« Reply #2 on: December 06, 2010, 12:50:27 AM »

I guess you'd also need a small script on your web server to check the date/time of the status file(s) uploaded.
Logged

Support Hero
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: 2x CoD4, 1x BF3
Posts: 2627
Offline Offline
Owner of Host4B3.com - Over 70 bots hosted!
WWW
« Reply #3 on: December 06, 2010, 04:24:18 AM »

@courgette, ok, that would probably work...
I guess you'd also need a small script on your web server to check the date/time of the status file(s) uploaded.
Have any ideas? Can you code a quick script, something that goes along the times of
-check current time
- check time in status file
-if time is different by more then x, display offline

Or any other ideas you have?
*Via my HTC EvO 4G*
Logged

Need B3 Bot hosting? Check out Host4B3.com
Check Twitter.com/Host4B3 for updates if the site it down.

Help will be given to those with a b3.log

System: Python 2.7.1 - B3 Source Code - Locally hosted MySQL & Apache - Win 2k3
XLRstats dev.
Dev. Team
*
OS: Linux
Type: Home user
Gameservers: COD5, COD7, BF3
Posts: 947
Offline Offline
WWW
Support Specialty: XLRstats webfront
« Reply #4 on: December 06, 2010, 12:49:04 PM »

Here's a simple script that should work:

Code: php
error_reporting(E_ALL);

//Enter path or URL to your status file
$status_file = "http://www.example.com/status.xml";
//Enter allowed time difference between current time and status.xml time in seconds
$interval = "300";

simplexml_load_file($status_file)
or die("Cannot Open Status File!");

$xml=new simpleXMLElement($status_file,NULL,TRUE);
$time = $xml->B3Status;

$status_time = strtotime($xml['Time']);
$now = time();

$time_difference = $now - $status_time;

if($time_difference < $interval)
 echo "Your Server is Online";
else
 echo "Your Server is Offline";
« Last Edit: December 09, 2010, 12:11:27 AM by Freelander » Logged

Support Hero
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: 2x CoD4, 1x BF3
Posts: 2627
Offline Offline
Owner of Host4B3.com - Over 70 bots hosted!
WWW
« Reply #5 on: December 08, 2010, 09:43:51 PM »

I am trying freelander, really I am, but I seem to n00b to get this to work...

Copy/paste the code, add it between the php tags, and nothing. White screen.
Logged

Need B3 Bot hosting? Check out Host4B3.com
Check Twitter.com/Host4B3 for updates if the site it down.

Help will be given to those with a b3.log

System: Python 2.7.1 - B3 Source Code - Locally hosted MySQL & Apache - Win 2k3
XLRstats dev.
Dev. Team
*
OS: Linux
Type: Home user
Gameservers: COD5, COD7, BF3
Posts: 947
Offline Offline
WWW
Support Specialty: XLRstats webfront
« Reply #6 on: December 09, 2010, 12:15:07 AM »

You're probably having some errors and those are saved in an error_log file in your web folder. Please try the modified code above, it should show errors on the screen now.
Logged

Support Hero
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: 2x CoD4, 1x BF3
Posts: 2627
Offline Offline
Owner of Host4B3.com - Over 70 bots hosted!
WWW
« Reply #7 on: March 29, 2011, 10:39:23 AM »

Sorry for taking so long to get back to this project...

The page now works great. However, I have one small issue...

The game server is in the UK.
The bot server is in Texas (i think).
I am in Wisconsin currently.


In the status.xml, the time is currently: Tue Mar 29 22:33:31 2011
On my Clock (on the computer): Tue Mar 29 15:29:31 2011
In the b3.xml time is set to CST.

The problem is that the check looks for the status.xml and always reports as online - even if off. (btw, i modified your code to check every 31 seconds, because my status.xml updates every 30 seconds).

Does it compare it to my current time? Or to the b3.xml time? Or to the bots server time? Or to the webhost time? Where does the php file get the time?

From what I guess it is because the time is 7 hours ahead in the status.xml, thereby making it so the only time it will read as offline is when the bot is off for 7 hours...

Any ideas?
Logged

Need B3 Bot hosting? Check out Host4B3.com
Check Twitter.com/Host4B3 for updates if the site it down.

Help will be given to those with a b3.log

System: Python 2.7.1 - B3 Source Code - Locally hosted MySQL & Apache - Win 2k3
XLRstats dev.
Dev. Team
*
OS: Linux
Type: Home user
Gameservers: COD5, COD7, BF3
Posts: 947
Offline Offline
WWW
Support Specialty: XLRstats webfront
« Reply #8 on: March 29, 2011, 01:07:51 PM »

Current time ($now) in the code is the time of the box the script is running on. Since we are comparing it with the time of status.xml, we have to return the time in the same time zone of status.xml.

I think you should add a line like this at the beginning of your code:

Code: php
date_default_timezone_set('America/Los_Angeles');

and change 'America/Los_Angeles' with the correct time zone. Here's a list of available time zones.
Logged

Support Hero
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: 2x CoD4, 1x BF3
Posts: 2627
Offline Offline
Owner of Host4B3.com - Over 70 bots hosted!
WWW
« Reply #9 on: March 29, 2011, 01:51:11 PM »

Parse error: syntax error, unexpected T_VARIABLE in /home/dausain1/public_html/rvoclan.com/test.php on line 5
Attached php file. (rename from .py
thanks for all your help!

[attachment deleted by maintenance]
Logged

Need B3 Bot hosting? Check out Host4B3.com
Check Twitter.com/Host4B3 for updates if the site it down.

Help will be given to those with a b3.log

System: Python 2.7.1 - B3 Source Code - Locally hosted MySQL & Apache - Win 2k3
XLRstats dev.
Dev. Team
*
OS: Linux
Type: Home user
Gameservers: COD5, COD7, BF3
Posts: 947
Offline Offline
WWW
Support Specialty: XLRstats webfront
« Reply #10 on: March 30, 2011, 06:11:15 AM »

Looks like you missed the semi colon at the end of the line.

I've changed the code a bit. Hope it works. You shoud set the interval at a greater value than the refresh rate of your status.xml.

Also note that, since things are running on different boxes and you are checking the time difference, you have to be synchronizing the time of servers. Although the hours are different, minutes and seconds have to be synced.

Maybe it's easier with monit?  Grin

[attachment deleted by maintenance]
Logged

Support Hero
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: 2x CoD4, 1x BF3
Posts: 2627
Offline Offline
Owner of Host4B3.com - Over 70 bots hosted!
WWW
« Reply #11 on: March 30, 2011, 09:07:43 AM »

Excellent, got it working.

Had to set the timezone to Europe/Samara, but the server and the status are about 40 or seconds apart, so 90 seconds as the timeout works.

More tweaking is needed, but now I can tell within a 45 or seconds..

I do have monit, however, my IP from the bot gets banned every now and then (the GSP has a very aggressive firewall) so I have to switch to my backup for a few days until it auto-releases it. Monit doesn't tell me when that happens, and this does, which makes switching IP's a 2 second thing...
Logged

Need B3 Bot hosting? Check out Host4B3.com
Check Twitter.com/Host4B3 for updates if the site it down.

Help will be given to those with a b3.log

System: Python 2.7.1 - B3 Source Code - Locally hosted MySQL & Apache - Win 2k3
Support Hero
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: 2x CoD4, 1x BF3
Posts: 2627
Offline Offline
Owner of Host4B3.com - Over 70 bots hosted!
WWW
« Reply #12 on: March 30, 2011, 10:24:12 AM »

Ok, got it working down to the second....

Thank you very much.
In case you want to check your handiwork...
http://64.87.60.16/status.php
Logged

Need B3 Bot hosting? Check out Host4B3.com
Check Twitter.com/Host4B3 for updates if the site it down.

Help will be given to those with a b3.log

System: Python 2.7.1 - B3 Source Code - Locally hosted MySQL & Apache - Win 2k3
Support Hero
*
OS: Windows
Type: Gameserver Rental Co.
Gameservers: 2x CoD4, 1x BF3
Posts: 2627
Offline Offline
Owner of Host4B3.com - Over 70 bots hosted!
WWW
« Reply #13 on: March 31, 2011, 01:11:43 PM »

Err, was working fine, but seems like there is a issue with the time settings somehow...

Take a look: http://64.87.60.16/status.php

Error displayed: Notice: Undefined offset: 1 in /var/www/status.php on line 34

Notice: Undefined offset: 2 in /var/www/status.php on line 34

Warning: mktime() expects parameter 5 to be long, string given in /var/www/status.php on line 34
Time on status.xml is: 01-01-1970 04:00:00
Current Server Time is 01-04-2011 01:12:19
B3 is Offline

P.S. b3 is still running...
Logged

Need B3 Bot hosting? Check out Host4B3.com
Check Twitter.com/Host4B3 for updates if the site it down.

Help will be given to those with a b3.log

System: Python 2.7.1 - B3 Source Code - Locally hosted MySQL & Apache - Win 2k3
XLRstats dev.
Dev. Team
*
OS: Linux
Type: Home user
Gameservers: COD5, COD7, BF3
Posts: 947
Offline Offline
WWW
Support Specialty: XLRstats webfront
« Reply #14 on: March 31, 2011, 02:27:40 PM »

Ok, we seem to have surprises  Smiley Here's a new version.

[attachment deleted by maintenance]
Logged

Tags:
Pages: [1] 2   Go Up
  Print  
 
Jump to:  


Rate this page +1 at Google Search


SimplePortal 2.3.1 © 2008-2009, SimplePortal