summaryrefslogtreecommitdiff
path: root/web-scripts
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2018-01-24 16:15:40 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2018-01-24 16:15:40 +0100
commitff768f012bfef1bf264d06214aead70a58c0ff90 (patch)
tree00fae2f78283cf61698b2b8fd2474a1f6a5802c8 /web-scripts
parentd5280828118b27372c5ea9be1c0cd8e55c818ff0 (diff)
parentcb4eedcdca4fc5f58e83abe2aadc9abb59b4918c (diff)
downloadbuilder-ff768f012bfef1bf264d06214aead70a58c0ff90.tar.xz
Merge branch 'master' into opcodes
Diffstat (limited to 'web-scripts')
-rw-r--r--web-scripts/broken-packages.php157
-rw-r--r--web-scripts/build-slaves.php44
-rw-r--r--web-scripts/packages.php20
-rw-r--r--web-scripts/statistics.php179
4 files changed, 400 insertions, 0 deletions
diff --git a/web-scripts/broken-packages.php b/web-scripts/broken-packages.php
new file mode 100644
index 0000000..268e296
--- /dev/null
+++ b/web-scripts/broken-packages.php
@@ -0,0 +1,157 @@
+<html>
+<head>
+<title>List of broken package builds</title>
+<link rel="stylesheet" type="text/css" href="/static/style.css">
+</head>
+<body>
+<a href="build-logs/">build logs</a><br>
+<?php
+
+$mysql = new mysqli("localhost", "webserver", "empty", "buildmaster");
+if ($mysql->connect_error) {
+ die("Connection failed: " . $mysql->connect_error);
+}
+
+$result = $mysql -> query(
+ "SELECT " .
+ "`build_assignments`.`id`," .
+ "`build_assignments`.`is_blocked`," .
+ "`package_sources`.`pkgbase`," .
+ "`package_sources`.`git_revision`," .
+ "`package_sources`.`mod_git_revision`," .
+ "`upstream_repositories`.`name`," .
+ "EXISTS (SELECT * " .
+ "FROM `binary_packages` `broken_bin` " .
+ "JOIN `dependencies` ON `dependencies`.`dependent` = `broken_bin`.`id` " .
+ "JOIN `install_target_providers` ON `install_target_providers`.`install_target` = `dependencies`.`depending_on` " .
+ "JOIN `binary_packages` `to_be_built` ON `to_be_built`.`id` = `install_target_providers`.`package` " .
+ "JOIN `repositories` ON `to_be_built`.`repository` = `repositories`.`id` " .
+ "WHERE `broken_bin`.`build_assignment`=`build_assignments`.`id` ".
+ "AND `repositories`.`name`=\"community-testing\"" .
+ ") AS `dependencies_pending`," .
+ "(SELECT count(*) " .
+ "FROM `build_dependency_loops` " .
+ "WHERE `build_dependency_loops`.`build_assignment`=`build_assignments`.`id`" .
+ ") AS `loops` " .
+ "FROM `build_assignments` " .
+ "JOIN `package_sources` ON `build_assignments`.`package_source` = `package_sources`.`id` " .
+ "JOIN `upstream_repositories` ON `package_sources`.`upstream_package_repository` = `upstream_repositories`.`id` " .
+ "WHERE `build_assignments`.`is_broken` OR `build_assignments`.`is_blocked` IS NOT NULL"
+);
+if ($result -> num_rows > 0) {
+
+ $count = 0;
+
+ while($row = $result->fetch_assoc()) {
+
+foreach ($row as $key => $val)
+
+ $fail_result = $mysql -> query(
+ "SELECT " .
+ "`fail_reasons`.`name`, " .
+ "`failed_builds`.`log_file` " .
+ "FROM `failed_builds` " .
+ "JOIN `build_assignments` ON `failed_builds`.`build_assignment`=`build_assignments`.`id` ".
+ "JOIN `fail_reasons` ON `failed_builds`.`reason`=`fail_reasons`.`id` ".
+ "WHERE `build_assignments`.`id`=".$row["id"]." " .
+ "ORDER BY `failed_builds`.`date`"
+ );
+
+ unset($reasons);
+ unset($last_log);
+ $rows[$count]["trials"] = $fail_result -> num_rows;
+ if ($rows[$count]["trials"] > 0) {
+ while($fail_row = $fail_result->fetch_assoc()) {
+ $reasons[$fail_row["name"]] = $fail_row["name"];
+ $last_log = $fail_row["log_file"];
+ }
+ }
+ if (isset($reasons)) {
+ $to_print="";
+ foreach ($reasons as $reason) {
+ $to_print=$to_print.", ".$reason;
+ }
+ $rows[$count]["fail_reasons"]=substr($to_print,2);
+ } else {
+ $rows[$count]["fail_reasons"]="&nbsp;";
+ }
+
+ $rows[$count]["loops"] = $row["loops"];
+ $rows[$count]["pkgbase"] = $row["pkgbase"];
+ if ($row["dependencies_pending"]=="1")
+ $rows[$count]["pkgbase_print"] = "(" . $rows[$count]["pkgbase"] . ")";
+ else
+ $rows[$count]["pkgbase_print"] = $rows[$count]["pkgbase"];
+ $rows[$count]["git_revision"] = $row["git_revision"];
+ $rows[$count]["mod_git_revision"] = $row["mod_git_revision"];
+ $rows[$count]["name"] = $row["name"];
+ if (isset($last_log))
+ $rows[$count]["print_trials"]="<a href=\"/build-logs/error/".$last_log."\">". $rows[$count]["trials"] ."</a>";
+ else
+ $rows[$count]["print_trials"]=$rows[$count]["trials"];
+ if ($row["is_blocked"]=="") {
+ $rows[$count]["is_blocked"]="&nbsp;";
+ }
+ else {
+ $rows[$count]["is_blocked"] = preg_replace(
+ array (
+ "/FS32#(\\d+)/",
+ "/FS#(\\d+)/"
+ ),
+ array (
+ "<a href=\"https://bugs.archlinux32.org/index.php?do=details&task_id=$1\">$0</a>",
+ "<a href=\"https://bugs.archlinux.org/task/$1\">$0</a>"
+ ),
+ $row["is_blocked"]
+ );
+ }
+ $count++;
+ }
+
+ usort(
+ $rows,
+ function (array $a, array $b) {
+ if ($a["trials"] < $b["trials"])
+ return -1;
+ if ($a["trials"] > $b["trials"])
+ return 1;
+ return strcmp($a["pkgbase"],$b["pkgbase"]);
+ }
+ );
+
+ print "<table>\n";
+ print "<tr>";
+ print "<th>package</th>";
+ print "<th>git revision</th>";
+ print "<th>modification git revision</th>";
+ print "<th>package repository</th>";
+ print "<th>compilations</th>";
+ print "<th>loops</th>";
+// print "<th>dependent</th>";
+ print "<th>build error</th>";
+ print "<th>blocked</th>";
+ print "</tr>\n";
+
+ foreach($rows as $row) {
+
+ print "<tr>";
+
+ print "<td><a href=\"/graphs/".$row["pkgbase"].".png\">".$row["pkgbase_print"]."</a></td>";
+ print "<td><p style=\"font-size:8px\">".$row["git_revision"]."</p></td>";
+ print "<td><p style=\"font-size:8px\">".$row["mod_git_revision"]."</p></td>";
+ print "<td>".$row["name"]."</td>";
+ print "<td>".$row["print_trials"]."</td>";
+ print "<td>".$row["loops"]."</td>";
+// <td>0</td>
+ print "<td>".$row["fail_reasons"]."</td>";
+ print "<td>".$row["is_blocked"]."</td>";
+
+ print "</tr>\n";
+ }
+
+ print "</table>\n";
+}
+
+?>
+</body>
+</html>
diff --git a/web-scripts/build-slaves.php b/web-scripts/build-slaves.php
new file mode 100644
index 0000000..0b8ae6a
--- /dev/null
+++ b/web-scripts/build-slaves.php
@@ -0,0 +1,44 @@
+<html><head><title>list of build slaves</title></head><body>
+<?php
+
+ $conn = new mysqli("localhost","http","http","buildmaster");
+ if ($conn->connect_error) {
+ die("Connection to mysql database failed: " . $conn->connect_error);
+ }
+
+ $result =
+ $conn->query(
+ "SELECT" .
+ " `build_slaves`.`name`," .
+ "`build_slaves`.`operator`," .
+ "`package_sources`.`pkgbase`," .
+ "`build_slaves`.`last_connection`" .
+ " FROM `build_slaves`" .
+ " LEFT JOIN `build_assignments` ON" .
+ " `build_slaves`.`currently_building`=`build_assignments`.`id`" .
+ " LEFT JOIN `package_sources` ON" .
+ " `build_assignments`.`package_source`=`package_sources`.`id`" .
+ " ORDER BY `build_slaves`.`last_connection`"
+ );
+
+ print "<table border=1>\n";
+ if ($result->num_rows > 0) {
+ print "<tr><th>name</th><th>operator</th><th>currently building</th><th>last connection</th></tr>\n";
+ while ($row = $result -> fetch_assoc()) {
+ foreach ($row as $key => $value) {
+ if ($value=="") {
+ $row[$key]="&nbsp;";
+ }
+ }
+ print "<tr>";
+ print "<td>".$row["name"]."</td>";
+ print "<td>".$row["operator"]."</td>";
+ print "<td>".$row["pkgbase"]."</td>";
+ print "<td>".$row["last_connection"]."</td>";
+ print "</tr>\n";
+ }
+ }
+ print "</table>\n";
+
+?>
+</body></html>
diff --git a/web-scripts/packages.php b/web-scripts/packages.php
new file mode 100644
index 0000000..b8b5dda
--- /dev/null
+++ b/web-scripts/packages.php
@@ -0,0 +1,20 @@
+<?php
+
+ $mysql = new mysqli("localhost", "http", "http");
+ if ($mysql->connect_error) {
+ die("Connection to mysql database failed: " . $mysql->connect_error);
+ }
+
+ $result = $mysql -> query("SELECT * FROM buildmaster.binary_packages");
+ if ($result -> num_rows > 0) {
+ while($row = $result->fetch_assoc()) {
+ foreach ($row as $key => $val) {
+ print $key .": ".$val." - ";
+ }
+ print "<br>\n";
+ }
+ }
+
+ print 'OK';
+
+?>
diff --git a/web-scripts/statistics.php b/web-scripts/statistics.php
new file mode 100644
index 0000000..279aa39
--- /dev/null
+++ b/web-scripts/statistics.php
@@ -0,0 +1,179 @@
+<?php
+
+$columns = array(
+ 'stable',
+ 'tasks',
+ 'pending_packages',
+ 'staging',
+ 'testing',
+ 'broken',
+ 'loops',
+ 'looped_packages',
+ 'locked',
+ 'blocked',
+ 'next_pending',
+ 'tested'
+);
+
+$print_columns = array(
+ 'tasks',
+ 'pending_packages',
+ 'staging',
+ 'testing',
+ 'tested',
+ 'broken',
+ 'loops',
+ 'looped_packages',
+ 'locked',
+ 'blocked',
+ 'next_pending'
+);
+
+$t_min = -1;
+$t_max = -1;
+$val_max = -1;
+
+foreach (explode("\n",trim(file_get_contents('/srv/http/statistics'))) as $val) {
+ $val = explode(" ",$val);
+ if (($t_min == -1) || ($t_min > $val[0]))
+ $t_min = $val[0];
+ if (($t_max == -1) || ($t_max < $val[0]))
+ $t_max = $val[0];
+ foreach ($columns as $id => $column) {
+ if (count($val) > $id+1)
+ $values[$column][$val[0]] = $val[$id+1];
+ };
+ foreach ($print_columns as $column) {
+ if (array_key_exists($column,$values))
+ if (($val_max == -1) || ($val_max < $values[$column][$val[0]]))
+ $val_max = $values[$column][$val[0]];
+ }
+};
+
+$max_len = 0;
+foreach ($print_columns as $column) {
+ $len = strlen($values[$column][$t_max])+1;
+ if ($len > $max_len)
+ $max_len = $len;
+}
+
+$width = 1600;
+$height = 600;
+$border = 5;
+$legend_line_length = 10;
+$legend_height = 3 * ImageFontHeight(5) + $legend_line_length;
+
+$im = @ImageCreate ($width + $legend_line_length + $max_len * ImageFontWidth(5), $height + $legend_height)
+ or die ("Cannot create new gd-image-stream");
+
+$background_color = ImageColorAllocate ($im, 255, 255, 255);
+$foreground_color = ImageColorAllocate ($im, 0, 0, 0);
+
+$colors['stable'] = ImageColorAllocate ($im, 0, 0, 0);
+$colors['tasks'] = ImageColorAllocate ($im, 0, 0, 128);
+$colors['pending_packages'] = ImageColorAllocate ($im, 0, 0, 255);
+$colors['staging'] = ImageColorAllocate ($im, 0, 100, 0);
+$colors['testing'] = ImageColorAllocate ($im, 0, 200, 0);
+$colors['tested'] = ImageColorAllocate ($im, 100, 255, 0);
+$colors['broken'] = ImageColorAllocate ($im, 255, 0, 0);
+$colors['loops'] = ImageColorAllocate ($im, 128, 128, 0);
+$colors['looped_packages'] = ImageColorAllocate ($im, 255, 128, 128);
+$colors['locked'] = ImageColorAllocate ($im, 128, 128, 128);
+$colors['blocked'] = ImageColorAllocate ($im, 128, 0, 0);
+$colors['next_pending'] = ImageColorAllocate ($im, 0, 255, 255);
+
+function scale($x, $x_min, $x_max, $scale, $log) {
+ if ($log) {
+ $x = log($x + 10);
+ $x_min = log($x_min + 10);
+ $x_max = log($x_max + 10);
+ };
+ if ($x_max == $x_min)
+ $frac = 0;
+ else
+ $frac = ($x - $x_min)/($x_max - $x_min);
+ if ($scale < 0)
+ return ($frac-1) * $scale;
+ else
+ return $frac * $scale;
+};
+
+function print_graph($data, $color) {
+ global $width, $height, $im, $t_min, $t_max, $val_max, $border, $legend_line_length;
+ ksort($data);
+ $last_t = -1;
+ $last_val = -1;
+ foreach ($data as $t => $val) {
+ if ($last_t != -1)
+ ImageLine(
+ $im,
+ scale($last_t,$t_min,$t_max,$width-2*$border,false)+$border+$legend_line_length,
+ scale($last_val,0,$val_max,-$height+2*$border,isset($_GET["log"]))+$border,
+ scale($t,$t_min,$t_max,$width-2*$border,false)+$border+$legend_line_length,
+ scale($val,0,$val_max,-$height+2*$border,isset($_GET["log"]))+$border,
+ $color
+ );
+ $last_t = $t;
+ $last_val = $val;
+ }
+ ImageString(
+ $im,
+ 5,
+ $width+$legend_line_length,
+ scale($last_val,0,$val_max,-$height+2*$border,isset($_GET["log"]))+$border - ImageFontHeight(5)/2,
+ " ".$data[$t_max],
+ $color
+ );
+};
+
+ImageRectangle($im, $legend_line_length, 0, $width-1+$legend_line_length, $height-1, $foreground_color);
+
+ImageString($im, 5, $legend_line_length, $height + $legend_line_length + 2*ImageFontHeight(5), "( ".trim(shell_exec("uptime | sed 's|^.*\\s\\(load\\)|\\1|'"))." )", $foreground_color);
+
+$xpos = $legend_line_length;
+foreach ($print_columns as $column) {
+ print_graph($values[$column], $colors[$column]);
+ ImageString($im, 5, $xpos, $height + $legend_line_length + ImageFontHeight(5), $column, $colors[$column]);
+ $xpos += (strlen($column) + 1.75) * ImageFontWidth(5);
+}
+
+ImageString($im, 5, $legend_line_length, $height + $legend_line_length, date('Y-m-d H:i', $t_min), $foreground_color);
+$s = date('Y-m-d H:i', $t_max);
+ImageString($im, 5, $width+$legend_line_length - strlen($s)*ImageFontWidth(5), $height + $legend_line_length, $s, $foreground_color);
+
+for ($t=ceil($t_min/24/60/60); $t<=floor($t_max/24/60/60); $t++)
+ ImageLine(
+ $im,
+ scale($t*24*60*60,$t_min,$t_max,$width-2*$border,false)+$border+$legend_line_length,
+ $height,
+ scale($t*24*60*60,$t_min,$t_max,$width-2*$border,false)+$border+$legend_line_length,
+ $height+$legend_line_length,
+ $foreground_color
+ );
+
+for ($val=0; $val<=$val_max;) {
+ ImageLine(
+ $im,
+ 0,
+ scale($val,0,$val_max,-$height+2*$border,isset($_GET["log"]))+$border,
+ $legend_line_length,
+ scale($val,0,$val_max,-$height+2*$border,isset($_GET["log"]))+$border,
+ $foreground_color
+ );
+ if (! isset($_GET["log"]))
+ $val+=pow(10,round(log($val_max)/log(10))-1);
+ elseif ($val==0)
+ $val++;
+ else
+ $val=$val*10;
+}
+
+// ImageString ($im, 1, 5, 5, "Test-String ".rand(), $foreground_color);
+
+header ("Content-type: image/png");
+
+ImagePNG ($im);
+
+// passthru('wc -l /srv/http/statistics');
+
+?>