Jump to content

[Patch] Save Online Players


Guest Milk13

Recommended Posts

What does this patch do ?

It saves in DB the number of players ingame at a particulary time, each X minutes.

Each save create a new row in Database.

You can use this datas to make graphs.

It use a new table in realmd DB.

It was actually for mangos-0.12, but we can update it for master without difficulty.

The first commit is here : http://github.com/MiLk/mangos/commit/74503f3df92f692f65f91b1ca2816f74016382e8

Branch here : http://github.com/MiLk/mangos/commits/online_players

Thanks for your feedback.

Link to comment
Share on other sites

There's I believe already existing code for this that could be improved, not much people know about it - "uptime" table in "realmd" database. It seems to log the maximum number of players each 10 minutes (default), though the column name might be misleading.

You could modify it to log the "current" number of players instead of "max reached so far". I guess that could even be accepted to master.

Link to comment
Share on other sites

There's I believe already existing code for this that could be improved, not much people know about it - "uptime" table in "realmd" database. It seems to log the maximum number of players each 10 minutes (default), though the column name might be misleading.

You could modify it to log the "current" number of players instead of "max reached so far". I guess that could even be accepted to master.

öhm but it updates the table till server crashs and doesn't insert new rows...

handled in : /game/World.cpp

Link to comment
Share on other sites

The existing field is update each time and we can't have a historic to have graphs like this : http://www.milkshack.net/images/7-1286970935.png

If your server doesn't restart for 2 days, you have one value for 2 days.

With my system you've one value for each 5 minutes ( you can change the interval ).

It doesn't look like a thing that could be still made.

Link to comment
Share on other sites

i think fregah meant that you should make an extra field into the uptime table and could change with config setting if you'll insert all X minutes the current count (max count since last ?) or just update as before....

so you don't need another table and more flexible ...

just one tipp use the [ u r l ][ / u r l ] tags :-)

Link to comment
Share on other sites

i think fregah meant that you should make an extra field into the uptime table and could change with config setting if you'll insert all X minutes the current count (max count since last ?) or just update as before....

so you don't need another table and more flexible ...

just one tipp use the [ u r l ][ / u r l ] tags :-)

We can't use uptime table because, with the actual system, it update the row, and remove the last value.

And insert a new row in uptime table at each time is stupid.

It's not "live" data, it's to have a collection of values to make graphs or tables.

For the url tag, I thought that's automatic, but in fact, no :)

Link to comment
Share on other sites

We can't use uptime table because, with the actual system, it update the row, and remove the last value.

And insert a new row in uptime table at each time is stupid.

It's not "live" data, it's to have a collection of values to make graphs or tables.

jeah i actually know that, but infact you could make a switch, so u can decide if you want just latest /highest data or those of all 5mins

Link to comment
Share on other sites

It's for people that don't know how to work crontab or are on windows.

And less work than with a cron script ( depending of your cronscript ).

If you do a select query each time on your full character table, it can slow down your database and decrease performance.

With this patch, there is less useless query.

But if you have a good cron script, it can be a solution too.

Link to comment
Share on other sites

  • 2 weeks later...

DB:

CREATE TABLE IF NOT EXISTS `online_log` (
 `timestamp` bigint(20) unsigned NOT NULL,
 `online_a` int(10) unsigned NOT NULL default '0',
 `online_h` int(10) unsigned NOT NULL default '0',
 PRIMARY KEY  (`timestamp`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

crontab:

*/15    *    *    *    *    mysql -u user -ppassword -e 'INSERT INTO `realmd`.`online_log` VALUES
(UNIX_TIMESTAMP(),
(SELECT count(`guid`) FROM `characters`.`characters` WHERE `online` = 1 AND `race` IN (1,3,4,7,11)),
(SELECT count(`guid`) FROM `characters`.`characters` WHERE `online` = 1 AND `race` IN (2,4,6,8,10)));'

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use