Managed Instances > one instance. At the top, how it is - waiting to connect, * checking in or gone quiet - with what can be done to it: sign in as support, update it, * check for updates, make it read-only or suspend it. Under that, what needs a look from its * last report, the connection code while it's waiting for one, who holds its seats, its history * a day at a time over 30 days, 90 days or a year (managedInstanceHistory()), and what it has * been asked and how that went; alongside, what this manager sets for it and what it reported * about itself. * * A connection code shows once, on the page its making redirects to - only its hash is kept * (managedInstanceNewCode()). The handlers are admin/post/managed_instances.php. */ require_once "includes/inc_all_admin.php"; // Off unless config.php turns it on - the list says how if (!managerEnabled() || !settingsColumnExists($mysqli, 'config_manager_keys')) { redirect('managed_instances.php'); } $instance_id = intval($_GET['id'] ?? 0); $row = managedInstanceRow($instance_id); if (!$row) { ?>
That instance is gone - it may have been deleted. Managed Instances
['tone' => 'secondary', 'icon' => 'fa-unlink'], $state === 'pending' => ['tone' => 'secondary', 'icon' => 'fa-plug'], $state === 'waiting' => ['tone' => 'warning', 'icon' => 'fa-hourglass-half'], $state === 'offline' => ['tone' => 'danger', 'icon' => 'fa-server'], $worst === 'danger' => ['tone' => 'danger', 'icon' => 'fa-server'], $worst === 'warning' => ['tone' => 'warning', 'icon' => 'fa-server'], default => ['tone' => 'success', 'icon' => 'fa-server'], }; // What it has been asked, newest first $commands = []; $sql = mysqli_query($mysqli, "SELECT * FROM managed_instance_commands WHERE managed_command_instance_id = $instance_id ORDER BY managed_command_created_at DESC, managed_command_id DESC LIMIT 15"); while ($command = mysqli_fetch_assoc($sql)) { $commands[] = $command; } $waiting = (bool) array_filter($commands, function ($command) { return in_array($command['managed_command_status'], ['queued', 'sent', 'running'], true); }); $updating = (bool) array_filter($commands, function ($command) { return $command['managed_command'] === 'update_now' && in_array($command['managed_command_status'], ['queued', 'sent', 'running'], true); }); $can_act = !$removed && $connected && $url !== ''; $status_pill = function (string $status) { $tone = ['queued' => 'secondary', 'sent' => 'info', 'running' => 'primary', 'done' => 'success', 'failed' => 'danger', 'cancelled' => 'secondary'][$status] ?? 'secondary'; $words = ['queued' => 'Waiting for its check-in', 'sent' => 'Sent', 'running' => 'Running', 'done' => 'Done', 'failed' => 'Failed', 'cancelled' => 'Cancelled'][$status] ?? $status; return '' . escapeHtml($words) . ''; }; $fact = function (string $label, string $value_html) { return '
  • ' . $label . '' . $value_html . '
  • '; }; $when = function ($datetime, string $never = 'Never') { return $datetime ? '' . escapeHtml(timeAgo($datetime)) . '' : '' . $never . ''; }; $size = function ($mb) { $mb = floatval($mb); return $mb >= 1024 ? round($mb / 1024, 1) . ' GB' : round($mb) . ' MB'; }; // Errors today, and the categories they were logged under - each opening its error log on the // instance, signed in as support. Only once it sends the categories: an older instance would // land on its start page $error_count = intval($report['errors_24h'] ?? 0); $error_log_link = $can_act && array_key_exists('errors_by_category', $report); $error_link = function (string $text_html, string $category = '') use ($instance_id, $csrf, $error_log_link) { if (!$error_log_link) { return $text_html; } $href = "post.php?managed_support_sign_in=$instance_id&to=errors" . ($category !== '' ? '&category=' . rawurlencode($category) : '') . "&csrf_token=$csrf"; return '' . $text_html . ''; }; $errors_html = '0'; if ($error_count > 0) { $errors_html = '' . $error_link((string) $error_count) . ''; foreach (managedInstanceErrorCategories($report) as $category => $logged) { $errors_html .= '
    ' . $error_link(escapeHtml($category !== '' ? $category : 'No category'), $category) . ' · ' . intval($logged) . '
    '; } } ?>
    >

    Removed

    Removed . It lets go at its next check-in - what this manager set comes off it, and its support user is archived. Connected - waiting for its cron job. It checks in from cron every minute, so add the cron job in its hosting control panel: every minute (* * * * *) . It checks in every minute from its own cron - either cron has stopped there, the server is down, or it can't reach this ITFlow. Checked in .

    Updating - it picks the request up at its next check-in and updates in the background. This page refreshes itself.

    It updates itself .

    Sign In as Support Update

    Connect it

    1. On that ITFlow, sign in as an admin and open Admin > Managed By. It needs to be on this version or newer.
    2. Paste the code there and choose Connect. It works once, until .

    Copy it now - it isn't shown again. If it's lost, make a new one.

    Setting up a new install for it?

    Run this in the new install's folder, as the user that owns its files - it sets ITFlow up, connects it with this code and keeps it connected. It asks for the database and anything else it needs.

    When it's done, it shows the password made for the first admin and the cron job to add in the hosting panel. This page says it's waiting for that cron job until it runs. Leave off --manager-required if its admins should be able to disconnect it.

    time()) { ?>

    The code was shown when it was made - only a fingerprint of it is kept here. If it's lost, make a new one; the old one stops working.

    New Connection Code

    There's no code that works - .

    Make a Connection Code

    It checks in with this ITFlow at , so that has to be reachable from where it is. Nothing here ever connects to it - it can be behind a firewall.

    Health

    Reported
    All good - cron is running, it's up to date, backups are recent and nothing has gone wrong today.

    Agents

    0 ? ' of ' . intval($agents['limit']) : '' ?> seats taken
    Who they are shows once it runs a version that sends them - until then, only how many.
    No agents yet.
    Agent Role MFA Last signed in
    Invited API account
    -
    '30 days', 90 => '90 days', 365 => '1 year']; $history_days = intval($_GET['history'] ?? 30); $history_days = isset($history_periods[$history_days]) ? $history_days : 30; $history = managedInstanceHistory($row, $history_days); $history_list = $history['days']; $history_now = []; foreach (array_reverse($history_list) as $history_day) { if ($history_day['agents'] !== null) { $history_now = $history_day; break; } } $history_column = function ($key) use ($history_list) { return array_column($history_list, $key); }; $history_labels = $history_column('label'); // Over a year the bars and the backup strip go by the week, so each stays readable $history_weekly = count($history_list) > 120; $history_bars = $history_list; if ($history_weekly) { $history_bars = []; foreach (array_chunk($history_list, 7) as $week) { $sum = function ($key) use ($week) { $values = array_filter(array_column($week, $key), function ($v) { return $v !== null; }); return $values ? array_sum($values) : null; }; $backups = array_filter(array_column($week, 'backup'), function ($v) { return $v !== null; }); $history_bars[] = [ 'label' => $week[0]['label'], 'title' => $week[0]['label'] . ' - ' . end($week)['label'], 'errors' => $sum('errors'), 'down' => $sum('down'), 'backup' => !$backups ? null : (in_array('failed', $backups, true) ? 'failed' : (in_array('', $backups, true) ? '' : 'ok')), 'made' => count(array_keys($backups, 'ok', true)), 'heard' => count($backups), ]; } } $bar_labels = array_column($history_bars, 'label'); $bar_period = $history_weekly ? ' that week' : ''; $history_block = function ($title, $figure, $body) { return '
    ' . escapeHtml($title) . '
    ' . '
    ' . $figure . '
    ' . $body . '
    '; }; $history_span = function ($seconds) { $minutes = max(1, (int) round($seconds / 60)); if ($minutes < 90) { return $minutes . ' minute' . ($minutes === 1 ? '' : 's'); } $hours = round($minutes / 60, 1); return $hours < 48 ? rtrim(rtrim(number_format($hours, 1), '0'), '.') . ' hours' : round($hours / 24) . ' days'; }; ?>

    History

    $period_label) { ?> >
    Its history needs this install's database update - apply it from Maintenance > Update.
    Its history starts with its next check-in - a line a day of its agents, clients, storage, uptime, errors and backups, kept for good.
    strtotime('-' . ($history_days - 1) . ' days'); ?>
    Its history starts on .
    'Agents', 'data' => $history_column('agents'), 'tone' => 'accent', 'fill' => true]]; if (array_sum(array_map('intval', $history_column('invites'))) > 0) { $series[] = ['label' => 'With invites waiting', 'tone' => 'muted', 'data' => array_map(function ($d) { return $d['agents'] === null ? null : $d['agents'] + $d['invites']; }, $history_list)]; } if (max(array_map('intval', $history_column('limit')) ?: [0]) > 0) { $series[] = ['label' => 'Seat limit', 'data' => array_map(function ($d) { return $d['limit'] ? $d['limit'] : null; }, $history_list), 'tone' => 'faint', 'dashed' => true]; } $figure = $history_now ? intval($history_now['agents']) . ' agent' . (intval($history_now['agents']) === 1 ? '' : 's') . ($history_now['invites'] ? ', ' . intval($history_now['invites']) . ' invited' : '') . ($history_now['limit'] ? ' - ' . intval($history_now['limit']) . ' seats' : '') : ''; echo $history_block('Agents', $figure, reportChart(['type' => 'line', 'labels' => $history_labels, 'series' => $series, 'format' => 'count'], 'sm', 'Agents by day')); // Clients $clients = array_values(array_filter($history_column('clients'), function ($v) { return $v !== null; })); $change = $clients ? end($clients) - $clients[0] : 0; $figure = $clients ? end($clients) . ' client' . (end($clients) === 1 ? '' : 's') . ($change ? ' - ' . ($change > 0 ? '+' : '') . $change . ' in this period' : '') : ''; echo $history_block('Clients', $figure, reportChart(['type' => 'line', 'labels' => $history_labels, 'legend' => false, 'series' => [['label' => 'Clients', 'data' => $history_column('clients'), 'tone' => 'accent', 'fill' => true]], 'format' => 'count'], 'sm', 'Clients by day')); // Storage - uploads and the database, in MB, or GB once it's 2 GB $unit = $history['unit']; $size = function ($mb) use ($unit) { return $mb === null ? null : round($unit === 'GB' ? $mb / 1024 : $mb, 1); }; $figure = $history_now ? $size($history_now['uploads'] + $history_now['db']) . " $unit - " . $size($history_now['uploads']) . " $unit uploads, " . $size($history_now['db']) . " $unit database" : ''; echo $history_block('Storage', $figure, reportChart(['type' => 'line', 'labels' => $history_labels, 'format' => 'number', 'series' => [ ['label' => "Uploads ($unit)", 'data' => array_map($size, $history_column('uploads')), 'tone' => 'accent', 'fill' => true], ['label' => "Database ($unit)", 'data' => array_map($size, $history_column('db')), 'tone' => 'muted'], ]], 'sm', 'Storage by day')); // Uptime - the minutes each day it wasn't checking in, so the days it went quiet stand out $gaps_html = ''; if ($history['gaps']) { $gaps_html .= '
      '; foreach (array_slice($history['gaps'], 0, 5) as $gap) { $same_day = date('Y-m-d', $gap['from']) === date('Y-m-d', $gap['to']); $gaps_html .= '
    • ' . ($gap['ongoing'] ? 'Since ' . date('M j, g:i A', $gap['from']) . ' - not checking in now' : date('M j, g:i A', $gap['from']) . ' - ' . date($same_day ? 'g:i A' : 'M j, g:i A', $gap['to'])) . ' ' . $history_span($gap['to'] - $gap['from']) . '
    • '; } if (count($history['gaps']) > 5) { $gaps_html .= '
    • and ' . (count($history['gaps']) - 5) . ' more
    • '; } $gaps_html .= '
    '; } $quiet = count($history['gaps']); $figure = $history['uptime'] !== null ? rtrim(rtrim(number_format($history['uptime'], 2), '0'), '.') . '% - ' . ($quiet ? 'went quiet ' . ($quiet === 1 ? 'once' : "$quiet times") : 'never went quiet') : ''; echo $history_block('Uptime', $figure, $quiet ? reportChart(['type' => 'bar', 'labels' => $bar_labels, 'format' => 'count', 'legend' => false, 'series' => [['label' => "Minutes not checking in$bar_period", 'data' => array_column($history_bars, 'down'), 'tone' => 'danger']]], 'sm', 'Minutes not checking in') . $gaps_html : '
    Checking in throughout - no gap of more than ' . MANAGED_OFFLINE_MINUTES . ' minutes.
    '); // Errors - each day's, and the categories they came under over the period $categories_html = ''; if ($history['categories']) { $named = []; foreach (array_slice($history['categories'], 0, 5, true) as $category => $logged) { $named[] = escapeHtml($category !== '' ? $category : 'No category') . ' ' . intval($logged) . ''; } $more = count($history['categories']) - count($named); $categories_html = '
    ' . implode(' · ', $named) . ($more > 0 ? " and $more more" : '') . '
    '; } $figure = $history['errors'] . ' error' . ($history['errors'] === 1 ? '' : 's') . ' in this period'; echo $history_block('Errors', $figure, reportChart(['type' => 'bar', 'labels' => $bar_labels, 'format' => 'count', 'legend' => false, 'series' => [['label' => "Errors$bar_period", 'data' => array_column($history_bars, 'errors'), 'tone' => 'accent']]], 'sm', 'Errors') . $categories_html); // Backups - a strip of the days (or weeks): made, failed, none, or nothing heard $backups = $history['backups']; $strip = '
    ' . 'Backed up' . 'Failed' . 'None
    '; $figure = 'Backed up on ' . $backups['ok'] . ' of ' . $backups['days'] . ' day' . ($backups['days'] === 1 ? '' : 's') . ($backups['failed'] ? ' - ' . $backups['failed'] . ' failed' : ''); echo $history_block('Backups', $figure, $strip); ?>

    Requests

    Nothing asked of it yet. Updates you start here, and automatic ones, show here with how they went.
    Request Status Asked Result
    Automatic' : escapeHtml((string) $command['managed_command_requested_by']) ?>

    Set from here

      ' . escapeHtml($row['managed_instance_mode_message']) . '
    ' : '')) ?> 0 ? '' . $seat_limit . ' agent' . ($seat_limit === 1 ? '' : 's') . '' : 'None - its own config decides') ?> Not set from here' : ($key_info ? 'On
    until ' . escapeHtml(date('M j, Y', strtotime((string) $key_info['expires']))) . '
    ' : 'The key has run out')) ?> Automatic
    ' . (intval($row['managed_instance_update_delay_days']) > 0 ? intval($row['managed_instance_update_delay_days']) . ' day' . (intval($row['managed_instance_update_delay_days']) === 1 ? '' : 's') . ' after one comes out' : 'As soon as one comes out') . ' - security fixes straight away
    ' : 'By hand
    From here - its admins can\'t
    ') ?>

    The instance

    Its details show once it has checked in.
    ') ?> ' . escapeHtml((string) $row['managed_instance_last_ip']) . '') ?>

    Notes