Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e538ce2

Browse files
committed
Add simple load numbers to judgedaemon overview page.
Part of #1164
1 parent 164d76b commit e538ce2

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

‎webapp/src/Controller/Jury/JudgehostController.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use App\Entity\Judgehost;
88
use App\Entity\JudgeTask;
99
use App\Entity\Judging;
10+
use App\Entity\JudgingRun;
1011
use App\Form\Type\JudgehostsType;
1112
use App\Service\ConfigurationService;
1213
use App\Service\DOMJudgeService;
@@ -57,6 +58,7 @@ public function indexAction(Request $request): Response
5758
'hostname' => ['title' => 'hostname'],
5859
'enabled' => ['title' => 'enabled'],
5960
'status' => ['title' => 'status'],
61+
'load' => ['title' => 'load (1m/5m/15m/60m)'],
6062
'last_judgingid' => ['title' => 'last judging'],
6163
];
6264

@@ -117,6 +119,44 @@ public function indexAction(Request $request): Response
117119
'value' => 'j' . $lastJobId['jobid'],
118120
];
119121

122+
$now = Utils::now();
123+
$timings = $this->em->createQueryBuilder()
124+
->from(JudgeTask::class, 'jt')
125+
->join(JudgingRun::class, 'jr', 'WITH', 'jr.judgetask = jt')
126+
->join('jr.judging', 'j')
127+
->join('jt.judgehost', 'jh')
128+
->select('jr.endtime, jr.startTime')
129+
->andWhere('jt.judgehost = :judgehost')
130+
->andWhere('jr.startTime IS NOT NULL')
131+
->andWhere('jr.endtime IS NOT NULL')
132+
->andWhere('jr.endtime >= :one_hour_ago')
133+
->setParameter('one_hour_ago', $now - 3600)
134+
->setParameter('judgehost', $judgehost)
135+
->getQuery()
136+
->getResult();
137+
$loads = [0.0, 0.0, 0.0, 0.0];
138+
$loadMinutes = [$now - 60*1, $now - 60*5, $now - 60*15, $now - 60*60];
139+
foreach ($timings as $timing) {
140+
for ($i = 0; $i < 4; $i++) {
141+
$start_time = $timing['startTime'];
142+
$end_time = $timing['endtime'];
143+
$start_time = max($start_time, $loadMinutes[$i]);
144+
if ($start_time < $end_time) {
145+
$loads[$i] += ($end_time - $start_time);
146+
}
147+
}
148+
}
149+
// Normalize to [0,1] range.
150+
$loads[0] = min(1.0, $loads[0] / (60.0 * 1.0));
151+
$loads[1] = min(1.0, $loads[1] / (60.0 * 5.0));
152+
$loads[2] = min(1.0, $loads[2] / (60.0 * 15.0));
153+
$loads[3] = min(1.0, $loads[3] / (60.0 * 60.0));
154+
$judgehostdata['load'] = [
155+
'value' => sprintf('%.2f / %.2f / %.2f / %.2f', $loads[0], $loads[1], $loads[2], $loads[3]),
156+
'title' => 'estimated load (1m/5m/15m/60m)',
157+
'cssclass' => 'text-monospace',
158+
];
159+
120160
$judgehostdata = array_merge($judgehostdata, [
121161
'status' => [
122162
'value' => $status,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /