ASECO plugin: ServerStats with graph output

This forum is dedicated to the Aseco/Rasp 2 server records and control script by Flo and Assembler Maniac. Announcements and issues can be discussed in this forum.

Moderators: Flo, f*ckfish, Assembler Maniac, TM-Patrol

FlyveHest
cyclist
cyclist
Posts: 39
Joined: 27 Apr 2008 20:40
Owned TM-games: TMU

ASECO plugin: ServerStats with graph output

Post by FlyveHest » 03 May 2008 18:02

I have created my first ASECO plugin, and, now that it has reached a working state, I wanted to share it with you all.

Version 0.5 has been released, get it here

http://gaming.gladblad.dk/aseco/serverstats/

Check post below for information about what has changed.
Last edited by FlyveHest on 23 May 2008 07:13, edited 2 times in total.

User avatar
lgrfbs-sweden
smooth traffic navigator
smooth traffic navigator
Posts: 200
Joined: 15 Apr 2007 15:48
Owned TM-games: TMN
Location: Sweden
Contact:

Re: ASECO plugin: ServerStats (Playercount)

Post by lgrfbs-sweden » 03 May 2008 19:18

Good work!
But I allraedy have the diagram, look here. Gray line is my playercont.
But I have not so many players then I write this post :-(
------------------------------------------------------------------------------------------v
Admin On:Image
My server:lgrfbs server / XASECO plugins
Image

FlyveHest
cyclist
cyclist
Posts: 39
Joined: 27 Apr 2008 20:40
Owned TM-games: TMU

Re: ASECO plugin: ServerStats (Playercount)

Post by FlyveHest » 03 May 2008 21:57

Whew, I brewed together a small graph, that at the moment only runs on a standard PHP page, but I will try and merge it with the plugin tomorrow (after cleaning up the code a bit also)

But, here's the live-stats from our [GB] TM server, by way of the ServerStats plugin

Image

(Don't know if phpBB actually caches the pic or not, but time will tell :))

User avatar
lgrfbs-sweden
smooth traffic navigator
smooth traffic navigator
Posts: 200
Joined: 15 Apr 2007 15:48
Owned TM-games: TMN
Location: Sweden
Contact:

Re: ASECO plugin: ServerStats (Playercount)

Post by lgrfbs-sweden » 03 May 2008 23:00

Nice graph you done!
Good work.
Admin On:Image
My server:lgrfbs server / XASECO plugins
Image

cdrw700
happy cruiser
happy cruiser
Posts: 129
Joined: 03 Dec 2006 09:15
Contact:

Re: ASECO plugin: ServerStats (Playercount)

Post by cdrw700 » 04 May 2008 00:24

Wow ! Let us know when you have realized this graph ! I'm very interested !!

User avatar
J-S
happy cruiser
happy cruiser
Posts: 149
Joined: 24 Apr 2008 18:20
Owned TM-games: TMN,TMUF,TMO,TMS
Manialink(s): shark
Location: Grenoble - France
Contact:

Re: ASECO plugin: ServerStats (Playercount)

Post by J-S » 04 May 2008 09:54

Thanks for this plugin, it's very interesting for popular server

FlyveHest
cyclist
cyclist
Posts: 39
Joined: 27 Apr 2008 20:40
Owned TM-games: TMU

Re: ASECO plugin: ServerStats (Playercount)

Post by FlyveHest » 04 May 2008 21:34

I've added a bunch of features, which includes the ability to output a graph to a PNG file.

But its late now, so, I will be releasing the next version tomorrow, monday. :)

cdrw700
happy cruiser
happy cruiser
Posts: 129
Joined: 03 Dec 2006 09:15
Contact:

Re: ASECO plugin: ServerStats (Playercount)

Post by cdrw700 » 04 May 2008 21:39

Great ! I'll try it ASAP!

Kjell T. Ring
sunday driver
sunday driver
Posts: 71
Joined: 03 Aug 2007 09:31
Owned TM-games: TMN, TMS
Location: Norway

Re: ASECO plugin: ServerStats (Playercount)

Post by Kjell T. Ring » 05 May 2008 06:51

Error. Running Win XP SP2 with Xampp, TMNF server and XAseco 0.97.

Code: Select all

# initialize XASECO ############################################################

[XAseco] PHP Version is 5.2.5
[XAseco] Load settings [config.xml]
[XAseco] Load admin/ops lists [adminops.xml]
[XAseco] Load plugin [plugin.localdatabase.php]
[XAseco] Load plugin [plugin.serverstats.php]

Fatal error: Class 'Plugin' not found in C:\TmFServer\xaseco_097_1\plugins\plugi
n.serverstats.php on line 8

User avatar
w1lla
TM-Patrol
TM-Patrol
Posts: 1466
Joined: 23 May 2007 07:20
Owned TM-games: TMU, TMN, TMF
Manialink(s): intr
Location: Venray

Re: ASECO plugin: ServerStats (Playercount)

Post by w1lla » 05 May 2008 08:27

you can only use it on aseco v 2.1.x version so but maybe someone can edit to xaseco.

Code: Select all

tmnforever is nations and united makes it special. tmnforever has united. I need united!

FlyveHest
cyclist
cyclist
Posts: 39
Joined: 27 Apr 2008 20:40
Owned TM-games: TMU

Re: ASECO plugin: ServerStats (Playercount)

Post by FlyveHest » 05 May 2008 10:47

w1lla wrote:you can only use it on aseco v 2.1.x version so but maybe someone can edit to xaseco.
Yes, its only Aseco right now, I haven't used XAseco, so I can't tell if its easy to make an XAseco version or not.

User avatar
w1lla
TM-Patrol
TM-Patrol
Posts: 1466
Joined: 23 May 2007 07:20
Owned TM-games: TMU, TMN, TMF
Manialink(s): intr
Location: Venray

Re: ASECO plugin: ServerStats (Playercount)

Post by w1lla » 05 May 2008 10:52

i tried but i keep to get the same error
playercount doesnt get filled in.

Code: Select all

tmnforever is nations and united makes it special. tmnforever has united. I need united!

User avatar
w1lla
TM-Patrol
TM-Patrol
Posts: 1466
Joined: 23 May 2007 07:20
Owned TM-games: TMU, TMN, TMF
Manialink(s): intr
Location: Venray

Re: ASECO plugin: ServerStats (Playercount)

Post by w1lla » 05 May 2008 11:44

Code: Select all

<?php
/*
	Requires: SimpleXML library
	
	PHP inspired by FufiWidgets and RASP
	*/

Aseco::registerEvent('onStartup', 'initServerStats');	
Aseco::registerEvent('onPlayerConnect', 'logServerStats');
Aseco::registerEvent('onPlayerDisconnect', 'cleanupStats');
  
  // Initializes the plugin
	function initServerStats()
	{
		// Load settings
    print('[ServerStats] Initializing..');
    $Settings = array();
    $settingsXML = simplexml_load_file('serverstats.xml');

    $Settings["EntriesPrHour"] = intval($settingsXML->entriesprhour);
    $Settings["RetentionTime"] = intval($settingsXML->retentiontime);
    $Settings["VerboseLogging"] = intval($settingsXML->verboselogging);

    // Sanitycheck, no values below 0 and no more than 60 entries pr. hour
    if ($Settings["EntriesPrHour"] <= 0) { $Settings["EntriesPrHour"] = 1; }
    if ($Settings["EntriesPrHour"] > 60) { $Settings["EntriesPrHour"] = 60; }    
    
    // Calculate how often we need to log a datapoint
    $Settings["LoggingInterval"] = (round(60 / $Settings["EntriesPrHour"]) * 60);
		if ($Settings["VerboseLogging"] = 1) { print('[ServerStats] Logging every '.$Settings["LoggingInterval"].' seconds');}
		
		// Checks MySQL for existance of our logging table
    if ($Settings["VerboseLogging"] = 1) { print('[ServerStats] Checking MySQL'); }
    $sql = "CREATE TABLE IF NOT EXISTS `serverstats` (
																										  `EntryTime` datetime NOT NULL,
																										  `PlayerCount` smallint(6) NOT NULL default '0',
																										  PRIMARY KEY (`EntryTime`)
																										 ) ENGINE=MyISAM";
    $sqlresult = mysql_query($sql);
    
    // We will force an update the very first time the mainloop is run
    $Settings["LastUpdateTime"] = 1;
	}

  // Logs a new entry in the stats table
	function logServerStats()
	{
	  // Check if its time to update
	  if (($Settings["LastUpdateTime"] + $Settings["LoggingInterval"]) < time())
	  {
	  	// It is time to update the stats
	    if ($Settings["VerboseLogging"] == 1) { print('[ServerStats] Writing datapoint'); }
	    
	    // Perform the logging SQL
	    $sql = "INSERT INTO `serverstats` (`EntryTime`, `PlayerCount`) VALUES (DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:00'), ".count($aseco->server->player->playerlist);
		$sql = "INSERT INTO `serverstats` (`EntryTime`, `PlayerCount`) VALUES (DATE_FORMAT(NOW(), '%Y-%m-%d %H:%i:00'), " & "6" ;
		$sqlresult = mysql_query($sql);
	    
	    // Set the last updated time
	    $Settings["LastUpdateTime"] = time();
	  }
	}
	
	// Cleans up old records in the stats
	function cleanupStats()
	{
			if ($Settings["VerboseLogging"] = 1) { print('[ServerStats] Cleaning out old datapoints'); }
		
	    // Perform the cleanup SQL
	    $sql = "DELETE FROM `serverstats` WHERE EntryTime < DATE_SUB(NOW(), INTERVAL ".$Settings ." HOUR)";;
	    $sqlresult = mysql_query($sql);		
	}
?>
all ready made a start for xaseco.

Code: Select all

tmnforever is nations and united makes it special. tmnforever has united. I need united!

FlyveHest
cyclist
cyclist
Posts: 39
Joined: 27 Apr 2008 20:40
Owned TM-games: TMU

Re: ASECO plugin: ServerStats (Playercount)

Post by FlyveHest » 05 May 2008 14:01

w1lla wrote: all ready made a start for xaseco.
Wait for later today, i'll release 0.5 with a lot of new additions.

User avatar
J-S
happy cruiser
happy cruiser
Posts: 149
Joined: 24 Apr 2008 18:20
Owned TM-games: TMN,TMUF,TMO,TMS
Manialink(s): shark
Location: Grenoble - France
Contact:

Re: ASECO plugin: ServerStats (Playercount)

Post by J-S » 05 May 2008 14:44

Thanks FlyveHest ! Your plugin is very usefull

Post Reply