Skip to content

Commit

Permalink
Basic server with error counting and a report (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariusz Cieslak committed Oct 15, 2013
1 parent 847de28 commit ef6dcd5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var
doc/diagrams/*.png
*.o
*.so
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
all: build test
all: build src/server/var test

build:
make -C src/probes/c

test:
make -C src/probes/c test
make -C src/probes/php test
wget -qO - $$RANDOMTEST_URL

src/server/var:
mkdir src/server/var
# PHP process (typically www-data) acess granted
chmod o+w src/server/var

clean:
make -C src/probes/c clean
Expand Down
35 changes: 31 additions & 4 deletions src/server/randomtest-server.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,37 @@
<?php

header('Content-type: text/plain');
$DATABASE_FILE = "var/randomtest.db";
$db = dba_open($DATABASE_FILE, "c");

echo "OK\n";
echo $_POST['stacktrace'];
if (isset($_POST['stacktrace'])) {
header('Content-type: text/plain');

file_put_contents('/tmp/randomtest.log', $_POST['stacktrace']);
echo "OK\n";
$stacktrace = $_POST['stacktrace'];
echo $stacktrace;

if (dba_exists($stacktrace, $db)) {
$counter = dba_fetch($stacktrace, $db) + 1;
}
else {
$counter = 1;
}
dba_replace($stacktrace, $counter, $db);
}
else {
header('Content-type: text/plain');
echo "RandomTest.net report\n\n";
for($stacktrace = dba_firstkey($db); $stacktrace != false; $stacktrace = dba_nextkey($db)) {
$counter = dba_fetch($stacktrace, $db);
$arr[$stacktrace] = $counter;
}
// sort array by counter, keys=stacktraces left
arsort($arr);
foreach ($arr as $stacktrace => $counter) {
echo "event counter: $counter\n$stacktrace\n";
}
}

dba_close($db);

?>

0 comments on commit ef6dcd5

Please sign in to comment.