2015-07-12 21:45:11 +02:00
<div style="border:1px solid #dddddd; margin-top:1px; width:100%; padding:10px">
2016-06-04 01:10:45 +02:00
<?php
2015-10-12 16:48:43 +02:00
if (!$worker_array['proc_accessible']):
?>
<div style="background-color:red !important;color:white;"><b>Warning</b>: MISP cannot access your /proc directory to check the status of the worker processes, which means that dead workers will not be detected by the diagnostic tool. If you would like to regain this functionality, make sure that the open_basedir directive is not set, or that /proc is included in it.</div>
<?php
endif;
2015-07-12 21:45:11 +02:00
foreach ($worker_array as $type => $data):
2015-10-12 16:48:43 +02:00
if ($type == 'proc_accessible') continue;
2015-07-12 21:45:11 +02:00
$queueStatusMessage = "Issues prevent jobs from being processed. Please resolve them below.";
$queueStatus = false;
if ($data['ok']) {
2015-10-12 16:48:43 +02:00
if (!$worker_array['proc_accessible']) {
$queueStatus = 'N/A';
$queueStatusMessage = "Worker started with the correct user, but the current status is unknown.";
} else {
$queueStatus = true;
$queueStatusMessage = "OK";
}
2015-07-12 21:45:11 +02:00
} else if (!empty($data['workers'])) {
foreach ($data['workers'] as $worker) {
if ($worker['alive']) {
$queueStatus = true;
$queueStatusMessage = "There are issues with the worker(s), but at least one healthy worker is monitoring the queue.";
}
}
}
?>
<h3><?php echo 'Worker type: ' . h($type);?></h3>
<?php if ($type !== 'scheduler'): ?>
2016-08-16 00:46:41 +02:00
<span><b>Jobs in the queue: </b>
<?php
echo h($data['jobCount']);
if ($data['jobCount'] > 0) {
echo $this->Form->postLink('<span class="icon-trash useCursorPointer"></span>', $baseurl . '/servers/clearWorkerQueue/' . h($type), array('escape' => false, 'inline' => true, 'style' => 'margin-left:2px;'));
}
?>
</span>
2015-10-12 16:48:43 +02:00
<p><b>Queue status: </b>
2016-06-04 01:10:45 +02:00
<?php
2015-10-12 16:48:43 +02:00
$color = "green";
if ($queueStatus === 'N/A') $color = "orange";
if ($queueStatus === false) $color = "red";
echo '<span class="' . $color . '">' . $queueStatusMessage . '</span>';
?>
</p>
2015-07-12 21:45:11 +02:00
<?php endif; ?>
<table class="table table-hover table-condensed" style="border:1px solid #dddddd; margin-top:1px; width:100%; padding:10px">
<tr>
<th>Worker PID</th>
<th>User</th>
<th>Worker process</th>
<th>Information</th>
<th>Actions</th>
</tr>
2016-06-04 01:10:45 +02:00
<?php
2015-07-12 21:45:11 +02:00
if (empty($data['workers'])):
?>
<tr>
<td class="shortish" style="background-color:red; color:white;">N/A</td>
<td class="short" style="background-color:red; color:white;">N/A</td>
<td style="background-color:red; color:white;">N/A</td>
<td style="background-color:red; color:white;">Worker not running!</td>
<td style="background-color:red; color:white;"> </td>
</tr>
2016-06-04 01:10:45 +02:00
<?php
2014-09-24 15:35:25 +02:00
else:
2015-07-12 21:45:11 +02:00
foreach ($data['workers'] as $worker):
$style = "color:green;";
$process = 'OK';
$message = 'The worker appears to be healthy.';
$icon_modifier = '';
if (!$worker['correct_user']) {
2015-07-17 15:06:38 +02:00
$message = 'The worker was started with a user other than the apache user. MISP cannot check whether the worker is alive or not.';
2015-07-12 21:45:11 +02:00
$style = "color:white;background-color:red;";
$icon_modifier = ' icon-white';
2015-07-17 15:06:38 +02:00
$process = 'Unknown';
2015-10-12 16:48:43 +02:00
} else if ($worker['alive'] === 'N/A') {
$process = 'Unknown';
$message = 'Cannot check whether the worker is alive or dead.';
$style = "color:white;background-color:orange;";
$icon_modifier = ' icon-white';
2015-07-17 15:06:38 +02:00
} else if (!$worker['alive']) {
2015-07-12 21:45:11 +02:00
$process = 'Dead';
$message = 'The Worker appears to be dead.';
$style = "color:white;background-color:red;";
$icon_modifier = ' icon-white';
2016-06-04 01:10:45 +02:00
}
2016-06-04 01:08:16 +02:00
2014-09-24 15:35:25 +02:00
$status = '<span style="color:green;">OK</span>';
2015-07-12 21:45:11 +02:00
?>
<tr>
<td class="shortish" style="<?php echo $style; ?>"><?php echo h($worker['pid']);?></td>
<td class="short" style="<?php echo $style; ?>"><?php echo h($worker['user']); ?></td>
<td class="short" style="<?php echo $style; ?>"><?php echo $process; ?></td>
<td style="<?php echo $style; ?>"><?php echo $message; ?></td>
<td class="actions short" style="<?php echo $style; ?>">
2016-06-04 01:10:45 +02:00
<?php
2015-07-12 21:45:11 +02:00
echo $this->Form->postLink('', '/servers/stopWorker/' . h($worker['pid']), array('class' => 'icon-trash' . $icon_modifier, 'title' => 'Stop (if still running) and remove this worker. This will immediately terminate any jobs that are being executed by it.'));
?>
</td>
</tr>
2016-06-04 01:10:45 +02:00
<?php
2015-07-12 21:45:11 +02:00
endforeach;
endif;
?>
</table>
2016-06-04 01:10:45 +02:00
<?php
2015-07-12 21:45:11 +02:00
echo $this->Form->create('Server', array('url' => '/servers/startWorker/' . h($type)));
echo $this->Form->button('Start a worker', array('class' => 'btn btn-inverse'));
echo $this->Form->end();
endforeach;
?>
2016-06-04 01:08:16 +02:00
2015-07-12 21:45:11 +02:00
</div>
<?php echo $this->Form->create('Server', array('url' => '/servers/restartWorkers'));
echo $this->Form->button('Restart all workers', array('class' => 'btn btn-primary'));
echo $this->Form->end();
2016-08-16 00:46:41 +02:00
?>