diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a8c8db43..0fcceb36e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,13 +6,14 @@ This file documents all notable changes made to ITFlow. ### Upgrading -Update from Maintenance > Update — Queue Update hands the job to cron, which updates the files and applies this release's database change (4.1.8) in the same pass. It adds a table for the problems of instances you manage and two settings for which of them open tickets, and changes nothing that is there. Nothing else is required. +Update from Maintenance > Update — Queue Update hands the job to cron, which updates the files and applies this release's two database changes (4.1.8 and 4.1.9) in the same pass. They add a table for the problems of instances you manage and two settings for which of them open tickets, and a table for each instance's history, and change nothing that is there. Nothing else is required. -If you manage other ITFlow installs, the manager and its instances can be updated in either order. An instance sends its check-ins encoded only once both are on this version, so a web application firewall in front of the manager may need its exclusion for check-ins until then. An instance shows its agents and error categories once it is updated. +If you manage other ITFlow installs, the manager and its instances can be updated in either order. An instance sends its check-ins encoded only once both are on this version, so a web application firewall in front of the manager may need its exclusion for check-ins until then. An instance shows its agents and error categories once it is updated. Each instance's history starts with its first check-in after the manager is updated - there is none from before. ### New Features & Updates - Managed Instances: problems on the instances you manage can open tickets. **Problem Tickets** on Admin > Managed Instances picks which - **Problems**, at High: an instance that has stopped checking in, cron not running, a failed update, a database update not applied, or a security update waiting on one that doesn't update itself; or **Problems and warnings**, which adds backups failing or none for three days and errors being logged, at Medium - and the category they get. A problem opens a ticket once it has lasted ten minutes, so a blip doesn't, on the instance's client or on your own client record when it has none. The ticket says what's wrong, with the instance's address, version and last check-in, what to look at, and a link to its page. The same problem again goes on its ticket while that's open, reopening it if it was resolved, and when it clears the ticket is resolved unless someone has written on it. A suspended instance, or a new one waiting for its cron job, opens none. Each problem under Health on an instance's page links to its ticket. Off until you turn it on. +- Managed Instances: an instance's page has a History card - its agents against its seat limit, its clients, storage, uptime, errors and backups, a day at a time, over 30 days, 90 days or a year. Uptime counts the gaps of more than ten minutes between its check-ins, and lists each with when it started and how long it lasted. Errors list the categories they came under, and backups show as a strip of the days one was made, failed or wasn't. Over a year, errors, uptime and backups go by the week. It's kept for good, from the day you update. - Managed Instances: an instance's page has an Agents card - who holds its seats, with each agent's name, email, role, whether they sign in with MFA and when they last signed in, then the invites waiting and the day each runs out. API accounts are marked. The support user takes no seat and isn't listed. Managed By, on the instance, lists this among what it tells its manager. - Managed Instances: errors logged on an instance now say which categories they were logged under, in its health line and under Errors today, where the count and each category sign you in to it as support on its App Logs, showing just those errors. Only how many there are under each category is sent - never what an error says, which can hold a client's email address or a ticket's subject. @@ -29,6 +30,10 @@ If you manage other ITFlow installs, the manager and its instances can be update - `managedInstanceHealth()` issues are `[tone, text, key]` - the key stays the same while the text changes: `offline`, `waiting`, `cron`, `db_update`, `update_failed`, `update`, `security_update`, `backup`, `errors` and `seats`. - `managerIssueTickets()`, run by `cron/managed_instances.php`, records a key when it is first seen, opens a ticket once the row is `MANAGED_ISSUE_GRACE_MINUTES` (10) old and `managedIssueOpensTicket()` passes it at the level, deletes a row that clears before then, and clears the rest through `managedIssueCleared()`, which resolves the ticket unless `rmmTicketWorked()`. `managedIssueTicket()` puts a key that comes back on its last ticket that isn't closed, reopening it if resolved. A key still there but no longer watched at the level isn't taken as cleared, and the rows of an instance removed or disconnected are cleared without touching their tickets. It does nothing with the level off or ticketing off. `managerTicketsReady()`, `managerTicketLevels()` and `managerTicketSettings()` read the settings. - Tickets it opens have `ticket_source = 'Managed'`, with an icon in `ticketSourceIcon()`, wording on the ticket page and `managed` in `ticketMailNewTicketAddress()`. `managedInstanceIssueTickets($instance_id)` gives an instance's open ones by key for the Health card. The window is `admin/modals/managed_instance/managed_instance_tickets.php`, posting `edit_managed_instance_tickets`. +- Database 4.1.9: `managed_instance_stats` - one row per instance per day, by the manager's date (unique on `managed_stat_instance_id`, `managed_stat_date`): `_agents`, `_invites`, `_seat_limit`, `_clients`, `_uploads_mb`, `_db_mb`, `_errors` (the report's `errors_24h`, which at the day's last check-in is that day's) and `_error_categories` (JSON), `_backup` (`ok`, `failed` or `''`), `_version`, `_checkins`, and `_outages` (JSON, each `from` and `to`). Re-runnable. +- `managedStatsRecord($row, $report)`, from `managerCheckin()` with the row as it was before the check-in, upserts today's row - `_checkins` + 1, and a day's `ok` backup never going back to `failed` or `''` - puts a backup made before midnight but first reported after it on its own day, and appends a gap of more than `MANAGED_OFFLINE_MINUTES` since the last check-in to today's `_outages` (the last 50). `managedStatsReady()` guards it before the update. +- `managedInstanceHistory($row, $days)` reads a period, from the first day there is: each day's figures, its `uptime` and minutes `down` from the gaps overlapping it - one going on now included, while the instance is connected - the gaps newest first, uptime over the period, backups made and failed, errors and their categories most first, and the storage unit (MB, or GB from 2 GB). `admin/managed_instance.php` draws it with `reportChart()` and `js/reports.js`, `?history=30`, `90` or `365`, grouping the bar charts and the backup strip by week over 120 days. The strip is `.itflow-history-strip` in `css/itflow_custom.css`. +- Deleting a managed instance now deletes its `managed_instance_issues` and `managed_instance_stats` rows too. ## [26.12.1] diff --git a/admin/database_updates/4.1.9.php b/admin/database_updates/4.1.9.php new file mode 100644 index 000000000..a3eb6b4f9 --- /dev/null +++ b/admin/database_updates/4.1.9.php @@ -0,0 +1,37 @@ + 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, and what it has been asked and - * how that went; alongside, what this manager sets for it and what it reported about itself. + * 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. @@ -380,6 +382,184 @@ if ($error_count > 0) { + '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 '