Core Dump Extracter.

Everything todo with programming goes HERE.
Post Reply
User avatar
Self_Destructo
Round Winner
Posts: 317
Joined: Tue Jun 07, 2005 1:24 am
Location: HillBilly Country
Contact:

Core Dump Extracter.

Post by Self_Destructo »

I'm working on this php script that extracts all the core dumps out of my log files. I figured some of ou guy wanted to get into this fun. And I probably need some help too, since I am not too experienced in programming. Basically, I have got it to where it identifies the core dump line (using ereg - my first to ever write). Pretty much now I just got to somhow figure out how to get the list out. I am not very good with loops yet - but I am trying.

I know I am doing something wrong. Most of this code is just copied log file. I was too lazy I guess to break it down. :|

Code: Select all

$log = '[1] Received login from *** via socket 64.34.162.82:4534.
[1] New user: 1
[1] RPL88 entered the game.
[1] RPL88 created a new team.
[0] Ping charity changed from 100100 to 228.
[0] Time:     17337.6 seconds
Sent:     42636 bytes in 285 packets (2.45916 bytes/s)
Received: 11674 bytes in 282 packets (0.673334 bytes/s)
[0] Timestamp: 2005/09/07 06:45:15
[0] Creating grid...
[0] AI entered the game.
[0] AI renamed to LaTeX.
[0] LaTeX entered the game.
[0] AI entered the game.
[0] AI renamed to Gcc.
[0] Gcc will fight for LaTeX on the next respawn.
[0] Gcc entered the game.
[0] AI entered the game.
[0] AI renamed to Gdb.
[0] Gdb will fight for LaTeX on the next respawn.
[0] Gdb entered the game.
[0] done!
[0] Resetting scores...
[0] New Match
[0] This Server will be down for the weekend so the SpeedeRs can have thier Match Play.
[0] Which you can visit at http://sd.distortgaming.com.
[0] The SpeedeRs are proud sponsors of the Armagetron Competitor\'s Club...
[0] All SpeedeRs should participate in the match play! -- See forums for more details!
[0] Go (round 1 of 10 )!
[0] 3
[0] 2
[0] 1
[0] 0
[0] Gdb core dumped RPL88 for 1 points.
[0] Gdb core dumped a teammate! No points for that!
[0] AI team was awarded 1 points for being last active team.
[0] Winner: AI team
[0] Ping charity changed from 228 to 105.
[0] Deleting objects...
[0] Deleting grid...
[0] www.sp-clan.com
[0] Time:     33.7689 seconds
Sent:     792088 bytes in 5035 packets (23456.2 bytes/s)
Received: 193586 bytes in 4096 packets (5732.67 bytes/s)
[0] Timestamp: 2005/09/07 06:45:49
[0] Creating grid...
[0] done!
[0] This Server will be down for the weekend so the SpeedeRs can have thier Match Play.
[0] Which you can visit at http://sd.distortgaming.com.
[0] The SpeedeRs are proud sponsors of the Armagetron Competitor\'s Club...
[0] All SpeedeRs should participate in the match play! -- See forums for more details!
[0] Go (round 2 of 10 )!
[0] 3
[0] 2
[0] 1
[0] 0
[0] RPL88 core dumped LaTeX for 1 points.
[0] Gcc core dumped RPL88 for 1 points.
[0] AI team was awarded 1 points for being last active team.
[0] Winner: AI team
[0] Ping charity changed from 105 to 109.
[0] Deleting objects...
[0] Deleting grid...
[0] www.sp-clan.com
[0] Time:     40.6648 seconds
Sent:     966888 bytes in 6149 packets (23777 bytes/s)
Received: 238934 bytes in 5049 packets (5875.69 bytes/s)
[0] Timestamp: 2005/09/07 06:46:30
[0] Creating grid...
[0] done!
[0] This Server will be down for the weekend so the SpeedeRs can have thier Match Play.
[0] Which you can visit at http://sd.distortgaming.com.
[0] The SpeedeRs are proud sponsors of the Armagetron Competitor\'s Club...
[0] All SpeedeRs should participate in the match play! -- See forums for more details!
[0] Go (round 3 of 10 )!
[0] 3
[0] 2
[0] 1
[0] 0
[0] LaTeX core dumped RPL88 for 1 points.
[0] AI team was awarded 1 points for being last active team.
[0] Winner: AI team
[0] Gcc core dumped a teammate! No points for that!
[0] Ping charity changed from 109 to 104.
[0] Deleting objects...
[0] Deleting grid...
[0] www.sp-clan.com
[0] Time:     35.3386 seconds
Sent:     834818 bytes in 5257 packets (23623.4 bytes/s)
Received: 208510 bytes in 4447 packets (5900.34 bytes/s)
[0] Timestamp: 2005/09/07 06:47:05
[0] Creating grid...
[0] done!
[0] This Server will be down for the weekend so the SpeedeRs can have thier Match Play.
[0] Which you can visit at http://sd.distortgaming.com.
[0] The SpeedeRs are proud sponsors of the Armagetron Competitor\'s Club...
[0] All SpeedeRs should participate in the match play! -- See forums for more details!
[0] Go (round 4 of 10 )!
[0] 3
[0] 2
[0] 1
[0] 0
[2] Received login from *** via socket 64.34.162.82:4534.
[2] New user: 2
[0] LaTeX core dumped RPL88 for 1 points.
[0] AI team was awarded 1 points for being last active team.
[0] Winner: AI team
[0] Deleting objects...
[0] Deleting grid...
[0] www.sp-clan.com
[0] Time:     24.5203 seconds
Sent:     776678 bytes in 4817 packets (31674.9 bytes/s)
Received: 139528 bytes in 2985 packets (5690.31 bytes/s)
[0] Timestamp: 2005/09/07 06:47:29
[0] Creating grid...
[2] bjornvayner entered the game.
[2] bjornvayner created a new team.
[0] done!
[0] This Server will be down for the weekend so the SpeedeRs can have thier Match Play.
[0] Which you can visit at http://sd.distortgaming.com.
[0] The SpeedeRs are proud sponsors of the Armagetron Competitor\'s Club...
[0] All SpeedeRs should participate in the match play! -- See forums for more details!
[0] Go (round 5 of 10 )!
[0] 3
[0] 2
[0] 1
[0] 0
[0] Gcc core dumped RPL88 for 1 points.
[0] AI team was awarded 1 points for being last active team.
[0] Winner: AI team
[0] Match Winner: AI team
[0] Overall Winner: AI team with 10 points.
[0] Deleting objects...
[0] Deleting grid...
[0] www.sp-clan.com
[0] Time:     29.4645 seconds
Sent:     1163026 bytes in 7141 packets (39472.1 bytes/s)
Received: 176128 bytes in 3782 packets (5977.63 bytes/s)
[0] Timestamp: 2005/09/07 06:47:59
[0] Creating grid...
[0] Gdb left the game.
[0] Gdb leaves AI team.
[0] Gcc left the game.
[0] Gcc leaves AI team.
[0] LaTeX left the game.
[0] done!
[0] Resetting scores...
[0] New Match
[0] This Server will be down for the weekend so the SpeedeRs can have thier Match Play.
[0] Which you can visit at http://sd.distortgaming.com.
[0] The SpeedeRs are proud sponsors of the Armagetron Competitor\'s Club...
[0] All SpeedeRs should participate in the match play! -- See forums for more details!
[0] Go (round 1 of 1000 )!
[0] 3
[0] 2
[0] 1
[0] 0
[1] RPL88: hi
[2] bjornvayner: hi
[0] bjornvayner core dumped RPL88 for 1 points.
[0] Winner: bjornvayner
[1] RPL88:  :-) 
[0] Ping charity changed from 104 to 102.
[0] Deleting objects...
[0] Deleting grid...
[0] www.sp-clan.com
[1] RPL88: !!Nice!!
[0] Time:     43.0335 seconds
Sent:     100548 bytes in 1183 packets (2336.51 bytes/s)
Received: 50118 bytes in 1126 packets (1164.63 bytes/s)
[0] Timestamp: 2005/09/07 06:48:42
[0] Creating grid...
[1] RPL88: Hehe!
[0] 

Timeout! Reason:
[0] User 2 does not know about netobject 39425 ( gCycle nr. 39425 owned by ePlayerNetID nr. 39255, name bjornvayner ).
[0] User 2 does not know about netobject 39424 ( gCycle nr. 39424 owned by ePlayerNetID nr. 38687, name RPL88 ).
[0] 


[0] This Server will be down for the weekend so the SpeedeRs can have thier Match Play.
[0] Which you can visit at http://sd.distortgaming.com.
[0] The SpeedeRs are proud sponsors of the Armagetron Competitor\'s Club...
[0] All SpeedeRs should participate in the match play! -- See forums for more details!
[0] Go (round 2 of 1000 )!
[0] 3
[0] 2
[0] 1
[0] 0
[0] RPL88 core dumped bjornvayner for 1 points.
[0] Winner: RPL88
[0] Ping charity changed from 102 to 101.
[0] Deleting objects...
[0] Deleting grid...
[0] www.sp-clan.com
[0] Time:     30.6443 seconds
Sent:     50750 bytes in 566 packets (1656.1 bytes/s)
Received: 12940 bytes in 297 packets (422.264 bytes/s)
[0] Timestamp: 2005/09/07 06:49:13
[0] Creating grid...
[0] User 2 timed out.
[2] bjornvayner left the game.
[2] Killing user 2, ping 0.5.
[0] done!
[0] This Server will be down for the weekend so the SpeedeRs can have thier Match Play.
[0] Which you can visit at http://sd.distortgaming.com.
[0] The SpeedeRs are proud sponsors of the Armagetron Competitor\'s Club...
[0] All SpeedeRs should participate in the match play! -- See forums for more details!
[0] Go (round 3 of 1000 )!
[0] 3
[0] 2
[0] 1
[0] 0
[0] Ping charity changed from 101 to 105.
[0] Deleting objects...
[0] Deleting grid...
[0] www.sp-clan.com
[0] Time:     19.1061 seconds
Sent:     15254 bytes in 208 packets (798.384 bytes/s)
Received: 7380 bytes in 171 packets (386.264 bytes/s)
[0] Timestamp: 2005/09/07 06:49:32
[0] Creating grid...
[0] AI entered the game.
[0] AI renamed to LaTeX.
[0] LaTeX entered the game.
[0] AI entered the game.
[0] AI renamed to Gcc.
[0] Gcc will fight for LaTeX on the next respawn.
[0] Gcc entered the game.
[0] AI entered the game.
[0] AI renamed to Gdb.
[0] Gdb will fight for LaTeX on the next respawn.
[0] Gdb entered the game.
[0] done!
[0] Resetting scores...
[0] New Match
[0] This Server will be down for the weekend so the SpeedeRs can have thier Match Play.
[0] Which you can visit at http://sd.distortgaming.com.
[0] The SpeedeRs are proud sponsors of the Armagetron Competitor\'s Club...
[0] All SpeedeRs should participate in the match play! -- See forums for more details!
[0] Go (round 1 of 10 )!
[0] 3
[0] 2
[0] 1
[0] 0
[0] Gcc core dumped RPL88 for 1 points.
[0] AI team was awarded 1 points for being last active team.
[0] Winner: AI team
[0] Ping charity changed from 105 to 104.
[0] Deleting objects...
[0] Deleting grid...
[0] www.sp-clan.com
[0] Time:     16.9244 seconds
Sent:     355754 bytes in 2237 packets (21020.1 bytes/s)
Received: 96418 bytes in 2088 packets (5696.97 bytes/s)
[0] Timestamp: 2005/09/07 06:49:49
[0] Creating grid...
[0] done!
[0] This Server will be down for the weekend so the SpeedeRs can have thier Match Play.
[0] Which you can visit at http://sd.distortgaming.com.
[0] The SpeedeRs are proud sponsors of the Armagetron Competitor\'s Club...
[0] All SpeedeRs should participate in the match play! -- See forums for more details!
[0] Go (round 2 of 10 )!
[0] 3
[0] 2
[0] 1
[0] 0
[0] Gdb core dumped a teammate! No points for that!
[0] RPL88 core dumped LaTeX for 1 points.
[0] Gcc core dumped a teammate! No points for that!
[0] RPL88 was awarded 1 points for being last active team.
[0] Winner: RPL88
[0] Ping charity changed from 104 to 102.
[0] Deleting objects...
[0] Deleting grid...
[0] www.sp-clan.com
[0] Time:     38.8621 seconds
Sent:     928570 bytes in 5888 packets (23894 bytes/s)
Received: 227398 bytes in 4811 packets (5851.41 bytes/s)
[0] Timestamp: 2005/09/07 06:50:27
[0] Creating grid...
[0] done!
[0] This Server will be down for the weekend so the SpeedeRs can have thier Match Play.
[0] Which you can visit at http://sd.distortgaming.com.
[0] The SpeedeRs are proud sponsors of the Armagetron Competitor\'s Club...
[0] All SpeedeRs should participate in the match play! -- See forums for more details!
[0] Go (round 3 of 10 )!
[0] 3
[2] Received login from * via socket 64.34.162.82:4534.
[2] New user: 2
[0] 2
[0] 1
[0] 0
[0] LaTeX core dumped RPL88 for 1 points.
[0] AI team was awarded 1 points for being last active team.
[0] Winner: AI team
[0] Ping charity changed from 102 to 104.
[0] Deleting objects...
[0] Deleting grid...
[0] www.sp-clan.com
[0] Time:     24.4193 seconds
Sent:     936860 bytes in 5810 packets (38365.6 bytes/s)
Received: 145432 bytes in 3097 packets (5955.62 bytes/s)
[0] Timestamp: 2005/09/07 06:50:52
[0] Creating grid...
[2] bjornvayner entered the game.
[2] bjornvayner created a new team.
[0] Gdb left the game.
[0] Gdb leaves AI team.
[0] done!
[0] This Server will be down for the weekend so the SpeedeRs can have thier Match Play.
[0] Which you can visit at http://sd.distortgaming.com.
[0] The SpeedeRs are proud sponsors of the Armagetron Competitor\'s Club...
[0] All SpeedeRs should participate in the match play! -- See forums for more details!
[0] Go (round 4 of 10 )!
[0] 3
[0] 2
[0] 1
[0] 0
[1] RPL88: hi
[2] bjornvayner: had a crash
[0] Gcc core dumped bjornvayner for 1 points.
[0] Gcc core dumped RPL88 for 1 points.
[0] AI team was awarded 1 points for being last active team.
[0] Winner: AI team
[0] Ping charity changed from 104 to 105.
[0] Deleting objects...
[0] Deleting grid...
[0] www.sp-clan.com
[0] Time:     28.4587 seconds
Sent:     825304 bytes in 7053 packets (29000.1 bytes/s)
Received: 164596 bytes in 3624 packets (5783.68 bytes/s)
[0] Timestamp: 2005/09/07 06:51:20
[0] Creating grid...
[0] Gcc left the game.
[0] Gcc leaves AI team.
[0] LaTeX left the game.
[0] done!
[2] received logout from 2.
[2] bjornvayner left the game.
[2] Killing user 2, ping 0.5.
[0] Resetting scores...
[0] New Match
[0] This Server will be down for the weekend so the SpeedeRs can have thier Match Play.
[0] Which you can visit at http://sd.distortgaming.com.
[0] The SpeedeRs are proud sponsors of the Armagetron Competitor\'s Club...
[0] All SpeedeRs should participate in the match play! -- See forums for more details!
[0] Go (round 1 of 1000 )!
[0] 3
[0] 2
[0] 1
[0] 0
[0] Ping charity changed from 105 to 106.
[0] Deleting objects...
[0] Deleting grid...
[0] www.sp-clan.com
[0] Time:     54.5867 seconds
Sent:     82900 bytes in 898 packets (1518.69 bytes/s)
Received: 38752 bytes in 831 packets (709.917 bytes/s)
[0] Timestamp: 2005/09/07 06:52:15
[0] Creating grid...
[0] AI entered the game.
[0] AI renamed to LaTeX.
[0] LaTeX entered the game.
[0] AI entered the game.
[0] AI renamed to Gcc.
[0] Gcc will fight for LaTeX on the next respawn.
[0] Gcc entered the game.
[0] AI entered the game.
[0] AI renamed to Gdb.
[0] Gdb will fight for LaTeX on the next respawn.
[0] Gdb entered the game.
[0] done!
[0] Resetting scores...
[0] New Match
[0] This Server will be down for the weekend so the SpeedeRs can have thier Match Play.
[0] Which you can visit at http://sd.distortgaming.com.
[0] The SpeedeRs are proud sponsors of the Armagetron Competitor\'s Club...
[0] All SpeedeRs should participate in the match play! -- See forums for more details!
[0] Go (round 1 of 10 )!
[0] 3
[0] 2
[0] 1
[0] 0
[0] LaTeX core dumped a teammate! No points for that!
[0] RPL88 core dumped LaTeX for 1 points.
[0] Gdb core dumped RPL88 for 1 points.
[0] AI team was awarded 1 points for being last active team.
[0] Winner: AI team
[0] RPL88 core dumped Gdb for 1 points.
[1] received logout from 1.
[1] RPL88 left the game.
[1] Killing user 1, ping 0.5.
[17] Killing user 17, ping 0.5.
[0] Gdb left the game.
[0] Gdb leaves AI team.
[0] LaTeX left the game.
[0] LaTeX leaves AI team.
[0] Gcc left the game.
[0] Armagetron left the game.
[0] Ping charity changed from 106 to 100100.
[0] Closing socket bound to 64.34.162.82:4534
[0] Closing socket bound to *.*.*.*:4535
[0] Bound socket to 64.34.162.82:4534.
[0] Bound socket to *.*.*.*:4535.
[0] Nobody there. Taking a nap...
[0] Timestamp: 2005/09/07 06:52:43
[0] Closing socket bound to 64.34.162.82:4534
[0] Closing socket bound to *.*.*.*:4535
[0] Bound socket to 64.34.162.82:4534.
[0] Bound socket to *.*.*.*:4535.
[1] Received login from *** via socket 64.34.162.82:4534.
[1] New user: 1
[0] Waiting for real players...

[0] Waiting for real players';

$split = split("(\[0\] .* core dumped .* for 1 points\.)", $log);
for($i = 1; $i <= count($split); $i++) {
	$array = $split[$i];
	echo $array;
}
Interesting fact is, it actually parses. Here is what it gives me and I am not sure why?.
received logout from 1. [1] RPL88 left the game. [1] Killing user 1, ping 0.5. [17] Killing user 17, ping 0.5. [0] Gdb left the game. [0] Gdb leaves AI team. [0] LaTeX left the game. [0] LaTeX leaves AI team. [0] Gcc left the game. [0] Armagetron left the game. [0] Ping charity changed from 106 to 100100. [0] Closing socket bound to 64.34.162.82:4534 [0] Closing socket bound to *.*.*.*:4535 [0] Bound socket to 64.34.162.82:4534. [0] Bound socket to *.*.*.*:4535. [0] Nobody there. Taking a nap... [0] Timestamp: 2005/09/07 06:52:43 [0] Closing socket bound to 64.34.162.82:4534 [0] Closing socket bound to *.*.*.*:4535 [0] Bound socket to 64.34.162.82:4534. [0] Bound socket to *.*.*.*:4535. [1] Received login from *** via socket 64.34.162.82:4534. [1] New user: 1 [0] Waiting for real players... [0] Waiting for real players
Notice: Undefined offset: 2 in d:\apache\htdocs\numerics\ereg.php on line 436
User avatar
dlh
Formerly That OS X Guy
Posts: 2035
Joined: Fri Jan 02, 2004 12:05 am
Contact:

Post by dlh »

Its in ruby. Does not parse for the points, just who core dumped who.

Code: Select all

# score_parse.rb -- A parser for Armagetron Advanced score logs
# Author: nemostultae

FILE = "your_log_file.txt"

core_dumps_raw = []
open(FILE,'r') { |file|
  file.each_line do |line|
    core_dumps_raw << line if line =~ /core dump/
  end
}

core_dumps = []
core_dumps_raw.each do |line|
  # only record actual points (no team kills).
  core_dumps << line.split('core dumped') unless line =~ /No points for that!/
end

# core_dumps now looks like this: [["[0] GDB "," RPL88 for 1 points. \n"], [etc...]]
# get rid of the "[0]" and the spaces at the end beginning/end of each element
core_dumps.each do |cored|
  cored.each do |element|
    element.delete! "[0]"
    element[0]  = ""
    element.delete! "for 1 points. \n"
  end
end

# We have everything in our array now, ready for insertion into a database.
# core_dumps[] looks like this (the first element is the one who got points):
# [
#   ["Gdb","RPL88"],
#   ["RPL88","LaTex"],
#   [etc...],
# ]

# make it pretty.
core_dumps.each do |cored|
  puts "#{cored[0]} core dumped #{cored[1]}."
end

puts
puts

# Make it a php array :)
puts "$coredumps = array("
core_dumps.each do |cored|
  puts "array('#{cored[0]}','#{cored[1]}');,"
end
puts ");"
Post Reply