Permalink
Browse files

Basic server with error counting and a report (#3)

  • Loading branch information...
dcieslak committed Oct 15, 2013
1 parent 847de28 commit ef6dcd56a7c0c83ee07a7d0e790f8a7c49951d44
Showing with 39 additions and 5 deletions.
  1. +1 −0 .gitignore
  2. +7 −1 Makefile
  3. +31 −4 src/server/randomtest-server.php
View
@@ -1,3 +1,4 @@
var
doc/diagrams/*.png
*.o
*.so
View
@@ -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
@@ -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.