diff --git a/CHANGELOG.md b/CHANGELOG.md index 0fcceb36e..c1788ca6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,14 +6,15 @@ 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 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. +Update from Maintenance > Update — Queue Update hands the job to cron, which updates the files and applies this release's three database changes (4.1.8 to 4.2.0) 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 with columns for its usage, 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. Each instance's history starts with its first check-in after the manager is updated - there is none from before. +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 - and its usage once the instance is updated too. ### 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: how much each instance is used. Its History card has a Usage part - tickets opened and resolved and those that came in by email, replies and notes by its agents, how many agents signed in each day and over the last 30 days, client portal sign-ins, invoices made and payments recorded, email sent and failed, and API calls with the keys that made the most of them - each day as the instance counts it, by its own date. The list has a Last 30 days column - tickets opened, how many of its agents signed in and when one last did, and API calls - and sorting by it puts the ones hardly used first. Only counts are sent, never what any of them say, and Managed By on the instance says so. - 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. @@ -34,6 +35,9 @@ If you manage other ITFlow installs, the manager and its instances can be update - `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. +- Usage: `managedUsage()` counts the instance's today and yesterday, by its own date, with a `GROUP BY` of the day each - `tickets_opened` and `tickets_email` (`ticket_created_at`, `ticket_source = 'Email'`), `tickets_resolved`, `replies` (`ticket_reply_by > 0` and not `Client`), `invoices` (`invoice_created_at`), `payments` (`payment_created_at`), `agent_signins` (distinct `Login` `Success` log users, not the support user), `portal_signins` (`Client Login` `Success`), `emails_sent` and `emails_failed` (`email_queue` status 3 by `email_sent_at`, 2 by `email_failed_at`), and `api_calls` with `api_keys` - the ten keys' names with most calls, from `api_key_usage` - and `agents_30d`. A count that can't be made is left out. `managedReport()` sends it as `usage` (`days`, `agents_30d`, `measured_at`), counted at most every ten minutes and kept in `config_managed.usage` meanwhile. +- Database 4.2.0: `managed_instance_stats` gets a column for each of `MANAGED_USAGE_FIGURES`, `_api_keys` (JSON) and `_agents_30d`, all NULL for a day nothing was reported. Re-runnable. `managedStatsRecord()` writes each of the instance's days onto the row of the same date, when it is there and within three days, and `_agents_30d` onto today's; `managedUsageReady()` guards it. `managedInstanceHistory()` adds each day's figures, `usage` (their totals, or null), `api_keys` and `agents_30d`, and the weekly view adds the figures up - `agent_signins` taking the week's highest day. +- `admin/managed_instances.php` reads each instance's last 30 days in one query, and sorts by tickets opened in them as `usage_tickets` - a sort key keeps to letters and underscores, as `filter_header.php` strips anything else. The Health column wraps, so the table fits. ## [26.12.1] diff --git a/admin/database_updates/4.2.0.php b/admin/database_updates/4.2.0.php new file mode 100644 index 000000000..772feffb3 --- /dev/null +++ b/admin/database_updates/4.2.0.php @@ -0,0 +1,40 @@ + "int(11) DEFAULT NULL AFTER `managed_stat_outages`", + 'managed_stat_tickets_email' => "int(11) DEFAULT NULL AFTER `managed_stat_tickets_opened`", + 'managed_stat_tickets_resolved' => "int(11) DEFAULT NULL AFTER `managed_stat_tickets_email`", + 'managed_stat_replies' => "int(11) DEFAULT NULL AFTER `managed_stat_tickets_resolved`", + 'managed_stat_invoices' => "int(11) DEFAULT NULL AFTER `managed_stat_replies`", + 'managed_stat_payments' => "int(11) DEFAULT NULL AFTER `managed_stat_invoices`", + 'managed_stat_agent_signins' => "int(11) DEFAULT NULL AFTER `managed_stat_payments`", + 'managed_stat_portal_signins' => "int(11) DEFAULT NULL AFTER `managed_stat_agent_signins`", + 'managed_stat_emails_sent' => "int(11) DEFAULT NULL AFTER `managed_stat_portal_signins`", + 'managed_stat_emails_failed' => "int(11) DEFAULT NULL AFTER `managed_stat_emails_sent`", + 'managed_stat_api_calls' => "int(11) DEFAULT NULL AFTER `managed_stat_emails_failed`", + 'managed_stat_api_keys' => "text DEFAULT NULL AFTER `managed_stat_api_calls`", + 'managed_stat_agents_30d' => "int(11) DEFAULT NULL AFTER `managed_stat_api_keys`", + ]; + foreach ($itflow_usage_columns as $itflow_usage_column => $itflow_usage_definition) { + $itflow_column_exists = mysqli_query($mysqli, "SELECT 1 FROM information_schema.COLUMNS + WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'managed_instance_stats' AND COLUMN_NAME = '$itflow_usage_column' LIMIT 1"); + if (!$itflow_column_exists || mysqli_num_rows($itflow_column_exists) === 0) { + mysqli_query($mysqli, "ALTER TABLE `managed_instance_stats` ADD `$itflow_usage_column` $itflow_usage_definition"); + } + } diff --git a/admin/managed_by.php b/admin/managed_by.php index 7c68530a7..f52e73d53 100644 --- a/admin/managed_by.php +++ b/admin/managed_by.php @@ -112,7 +112,7 @@ $lock = 'What a manager can do