* June 18, 2013, 07:12:43 AM
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Come Chat with us live! Learn how HERE!
 
   Home   Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: TremSnaps 2  (Read 3185 times)
Syntac


Turrets: +118/-104
Posts: 841

Void Website Developer


WWW
« on: January 04, 2009, 07:48:21 PM »

Say hello to incarnation #2 of my venerable project, TremSnaps. It takes a snapshot of the entire Tremulous "network" and saves it for future viewing.

Requirements
* A web server running PHP (tested on version 5.2.5)
* A cron job pointed at private/generate.php (for automatic snapshot creation; also, make sure a time limit isn't set)
* Read/write permissions in private/dumps/

Downloads
2.0 (highly defective)
2.1
  2.1.1
« Last Edit: January 09, 2009, 09:50:37 PM by Syntac » Logged

Hendrich


Turrets: +168/-147
Posts: 879

When I visit this forum, I feel old.


WWW
« Reply #1 on: January 04, 2009, 08:07:47 PM »

Good job Syntac, I can use this little App to show my children someday of how active Tremulous used to be before.... Lips Sealed
Logged

------------------------------------------------------------
Made you look.
------------------------------------------------------------
Archangel
Guest
« Reply #2 on: January 04, 2009, 08:58:03 PM »

http://www.aodclan.us/tremsnaps/

Still same 'bug' as last time. I don't see a lot of servers on there, ones that I know exist and are popular.
Logged
David
Spam Killer
*
*
*

Turrets: +249/-273
Posts: 3543

David


« Reply #3 on: January 04, 2009, 09:48:00 PM »

He's truncating each packet to 1024 bytes.
The master sends ~1400 per-packet.
If he's reading more than one packet he's mangling them all too.
Logged

Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.
Undeference
Tremulous Developers
*

Turrets: +122/-45
Posts: 1207


Ingar and carry on.


WWW
« Reply #4 on: January 05, 2009, 02:08:09 AM »

Color handling is wrong.
	
for(
$i 0$i count($sections); $i++) {
	
	
if(
$i 2) {
	
	
	
if(
$addr && $port) {
	
	
	
	
$servers[] = array("addr" => $addr"port" => $port);
	
	
	
}
	
	
} else {
	
	
	
$addr = @inet_ntop(substr($sections[$i], 04));
	
	
	
$port = @unpack("n"substr($sections[$i], 42));
	
	
	
$port $port[1];
	
	
}
	
}
Maybe I'm missing something, but that looks wrong to me. Is that ignoring every other server?

He's truncating each packet to 1024 bytes.
It doesn't look to me like that should be happening, though from what I see at least 750 bytes were received, so maybe it isn't getting anything beyond the first 1024.

Knowing what, if any, errors there are might help Syntac…
« Last Edit: January 05, 2009, 02:10:04 AM by Undeference, Reason: possible answer » Logged

Need help? Ask intelligently. If you find a solution on your own, please share it so others can benefit.

Thats what we need, helpful players, not more powerful admins.
Looking for more Tremulous maps?
Syntac


Turrets: +118/-104
Posts: 841

Void Website Developer


WWW
« Reply #5 on: January 05, 2009, 02:39:20 AM »

Archangel: I don't know what you're talking about. Tell me what the problem is!

Undeference: I need to check up on the loop there; I wrote it a long time ago. Also, what do you mean by the color handling being wrong?

[ed] Ugh, you may be right about skipping every other server...? This is probably what Archangel is going on about. Roll Eyes
[ed2] Holy fuck, you were right. How could I have been so stupid??? (New version coming out by the way, once you tell me about the color thing.)
« Last Edit: January 05, 2009, 02:42:50 AM by Syntac » Logged

Undeference
Tremulous Developers
*

Turrets: +122/-45
Posts: 1207


Ingar and carry on.


WWW
« Reply #6 on: January 05, 2009, 03:03:19 AM »

Code:
#define Q_COLOR_ESCAPE  '^'
#define Q_IsColorString(p)      ( p && *(p) == Q_COLOR_ESCAPE && *((p)+1) && isalnum(*((p)+1)) ) // ^[0-9a-zA-Z]
A caret followed by an alphanumeric character is a valid color code.
Code:
#define ColorIndex(c)   ( ( (c) - '0' ) & 7 )
function ColorIndex ($c) {
	
return 
ord ($c) & 7;
}
Logged

Need help? Ask intelligently. If you find a solution on your own, please share it so others can benefit.

Thats what we need, helpful players, not more powerful admins.
Looking for more Tremulous maps?
Syntac


Turrets: +118/-104
Posts: 841

Void Website Developer


WWW
« Reply #7 on: January 05, 2009, 12:14:18 PM »

Okay, cool. Can do.

[ed] Um, that always returns 0. Duh, I was using the wrong function. Roll Eyes
« Last Edit: January 05, 2009, 12:26:18 PM by Syntac » Logged

David
Spam Killer
*
*
*

Turrets: +249/-273
Posts: 3543

David


« Reply #8 on: January 05, 2009, 06:07:05 PM »

He's truncating each packet to 1024 bytes.
It doesn't look to me like that should be happening, though from what I see at least 750 bytes were received, so maybe it isn't getting anything beyond the first 1024.

I was getting confused between read and recv.  (The latter bins everything that wont fit in the buffer).
Logged

Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.
Archangel
Guest
« Reply #9 on: January 05, 2009, 06:32:44 PM »

actually, recv just keeps it in the 'waiting room' (dumbing this down here)
recv returns the number of bytes ACTUALLY read, so let's say there's 850 bytes in the buffer and you request 1024, recv returns 850
at least this is from my perl knowledge of the function

Code:
       recv SOCKET,SCALAR,LENGTH,FLAGS
               Receives a message on a socket.  Attempts to receive LENGTH characters of data into variable SCALAR from the specified SOCKET filehandle.
               SCALAR will be grown or shrunk to the length actually read.  Takes the same flags as the system call of the same name.  Returns the
               address of the sender if SOCKETâs protocol supports this; returns an empty string otherwise.  If thereâs an error, returns the undefined
               value.  This call is actually implemented in terms of recvfrom(2) system call.  See "UDP: Message Passing" in perlipc for examples.

               Note the characters: depending on the status of the socket, either (8-bit) bytes or characters are received.  By default all sockets oper-
               ate on bytes, but for example if the socket has been changed using binmode() to operate with the ":utf8" I/O layer (see the "open" pragma,
               open), the I/O will operate on UTF-8 encoded Unicode characters, not bytes.  Similarly for the ":encoding" pragma: in that case pretty
               much any characters can be read.
Logged
David
Spam Killer
*
*
*

Turrets: +249/-273
Posts: 3543

David


« Reply #10 on: January 05, 2009, 07:24:47 PM »

From man 2 recv:
All three routines return the length of the message on successful completion.  If a message  is too  long to fit in the supplied buffer, excess bytes may be discarded depending on the type of socket the message is received from.

In my experience, for UDP recv returns one packet per call, and discards any overflow.
Logged

Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.
Syntac


Turrets: +118/-104
Posts: 841

Void Website Developer


WWW
« Reply #11 on: January 05, 2009, 08:17:34 PM »

4096 is large enough, hopefully?
Logged

David
Spam Killer
*
*
*

Turrets: +249/-273
Posts: 3543

David


« Reply #12 on: January 05, 2009, 08:22:27 PM »

1400 is the max the master will send.  1500 to be safe.
Logged

Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.
Syntac


Turrets: +118/-104
Posts: 841

Void Website Developer


WWW
« Reply #13 on: January 05, 2009, 08:41:51 PM »

Okay, here's the current version of the color escape parser.

Code:
function get_color_index($chr)
{
$chr = substr($chr, 0, 1);
return ord($chr) & 7;
}

function parse_color_escapes($str)
{
$num = preg_match_all("/\^[^\n]/", $str, $null);

$replace = array(
0 => "<span style=\"color: #222;\">",
1 => "<span style=\"color: #F00;\">",
2 => "<span style=\"color: #0F0;\">",
3 => "<span style=\"color: #FF0;\">",
4 => "<span style=\"color: #00F;\">",
5 => "<span style=\"color: #0FF;\">",
6 => "<span style=\"color: #F0F;\">",
7 => "<span style=\"color: #FFF;\">"
);

$str = str_replace(array("<", ">"), array("&lt;", "&gt;"), $str);
$str = str_replace(array("^&lt;", "^&gt;"), array("^<", "^>"), $str);

for($i = 0; $i < strlen($str); $i++) {
if($str[$i] == "^" && isset($str[$i+1]) && preg_match("/[^\n]/", $str[$i+1])) {
$c = get_color_index($str[$i+1]);
$str = substr_replace($str, $replace[$c], $i, 2);
}
}

for($i = 0; $i < $num; $i++) {
$str .= "</span>";
}

return trim($str);
}
« Last Edit: January 05, 2009, 08:43:44 PM by Syntac » Logged

Syntac


Turrets: +118/-104
Posts: 841

Void Website Developer


WWW
« Reply #14 on: January 05, 2009, 09:01:17 PM »

O rly?

--> 2.1 released, check the OP.
« Last Edit: January 05, 2009, 09:06:30 PM by Syntac » Logged

Archangel
Guest
« Reply #15 on: January 05, 2009, 09:15:09 PM »

http://www.aodclan.us/tremsnaps/

Still same 'bug' as last time. I don't see a lot of servers on there, ones that I know exist and are popular.

running 2.1
Logged
Syntac


Turrets: +118/-104
Posts: 841

Void Website Developer


WWW
« Reply #16 on: January 05, 2009, 09:42:56 PM »

And...?

--> 2.1.1 released. Fixes a few minor issues.
« Last Edit: January 05, 2009, 09:48:49 PM by Syntac » Logged

Bissig


Turrets: +103/-131
Posts: 1309


« Reply #17 on: January 05, 2009, 11:08:39 PM »

Going to aods tremsnaps url and seeing this for "house of nuts":

----> ouse of uts

Doesn't look quite right.
Logged

Syntac


Turrets: +118/-104
Posts: 841

Void Website Developer


WWW
« Reply #18 on: January 06, 2009, 12:35:54 AM »

I think I fixed that in 2.1.1. The problem was that I was stripping out unprintables before parsing the color escapes, so it ended up as "^House of ^Nuts".
« Last Edit: January 06, 2009, 12:37:53 AM by Syntac, Reason: typo » Logged

Oblivion

*

Turrets: +26/-22
Posts: 379

Oblivion is a mystery, Oblivion is gone. Google It


WWW
« Reply #19 on: January 08, 2009, 11:53:34 PM »

I will be adding this to Gamez-Host as well. 
Good work.
Logged

"When someone tells you it's been a long time, you just say only with a blink of an eye."
Syntac


Turrets: +118/-104
Posts: 841

Void Website Developer


WWW
« Reply #20 on: January 09, 2009, 09:49:15 PM »

Thanks. Smiley

If anyone particularly wants it, I can add a more thorough statistics system.
Logged

Undeference
Tremulous Developers
*

Turrets: +122/-45
Posts: 1207


Ingar and carry on.


WWW
« Reply #21 on: January 11, 2009, 03:43:19 AM »

If anyone particularly wants it, I can add a more thorough statistics system.
I thought that was its purpose initially
Logged

Need help? Ask intelligently. If you find a solution on your own, please share it so others can benefit.

Thats what we need, helpful players, not more powerful admins.
Looking for more Tremulous maps?
Syntac


Turrets: +118/-104
Posts: 841

Void Website Developer


WWW
« Reply #22 on: January 11, 2009, 04:09:13 AM »

The purpose of TremSnaps is to take a snapshot of Tremulous; that is, to archive the state of every server for future retrieval. Perhaps you're thinking of TremStats?
Logged

Undeference
Tremulous Developers
*

Turrets: +122/-45
Posts: 1207


Ingar and carry on.


WWW
« Reply #23 on: January 11, 2009, 07:16:04 AM »

The purpose of TremSnaps is to take a snapshot of Tremulous; that is, to archive the state of every server for future retrieval.
What is the purpose of that without generating statistics based on that data?
Quote
Perhaps you're thinking of TremStats?
No.
Logged

Need help? Ask intelligently. If you find a solution on your own, please share it so others can benefit.

Thats what we need, helpful players, not more powerful admins.
Looking for more Tremulous maps?
Syntac


Turrets: +118/-104
Posts: 841

Void Website Developer


WWW
« Reply #24 on: January 11, 2009, 03:29:14 PM »

You seem to have a completely different idea of the purpose of archival. You're free to fork TremSnaps if you'd like, but until more people want a feature, I'm not adding it. My time is scarce enough as it is.
Logged

David
Spam Killer
*
*
*

Turrets: +249/-273
Posts: 3543

David


« Reply #25 on: January 11, 2009, 07:44:47 PM »

How do you store the data?  I assume mysql or whatever?
Assuming a sane scheme, then people should be able to extract stats without issue.
Logged

Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.
Syntac


Turrets: +118/-104
Posts: 841

Void Website Developer


WWW
« Reply #26 on: January 11, 2009, 11:28:35 PM »

It's stored in a serialized PHP array (private/dumps/<snapshot>, <snapshot> being a Unix timestamp corresponding to when the dump was generated).
« Last Edit: January 11, 2009, 11:31:19 PM by Syntac, Reason: Epic BBCode fail » Logged

David
Spam Killer
*
*
*

Turrets: +249/-273
Posts: 3543

David


« Reply #27 on: January 12, 2009, 12:04:07 AM »

Ah.
How big is a snapshot?  Data-analysis may be "fun" once you have a few tens of thousands of snapshots.
Logged

Any maps not in the MG repo?  Email me or come to irc.freenode.net/#mg.
--
My words are mine and mine alone.  I can't speak for anyone else, and there is no one who can speak for me.  If I ever make a post that gives the opinions or positions of other users or groups, then they will be clearly labeled as such.
I'm disappointed that people's past actions have forced me to state what should be obvious.
I am not a dev.  Nothing I say counts for anything.
Syntac


Turrets: +118/-104
Posts: 841

Void Website Developer


WWW
« Reply #28 on: January 12, 2009, 12:32:30 AM »

Somewhere around 210 KB for 200 servers. Given that most of those are empty, it's a waste of space.

generate.php has a few switches you can set, most notably --getservers-args. "--getservers-args full" will cause the master to only report populated servers. (A snapshot generated with that option is 68 KB.)
« Last Edit: January 12, 2009, 12:34:04 AM by Syntac » Logged

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
TremPlus theme by Ingar, based on AF316 theme by Fedhog
Valid XHTML 1.0! Valid CSS!