Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
<!-- translations:start -->
[English](README.md) | [简体中文](docs/i18n/zh-CN/README.md) | [हिन्दी](docs/i18n/hi-IN/README.md) | [Español (España)](docs/i18n/es-ES/README.md) | [Español (Latinoamérica)](docs/i18n/es-419/README.md) | [العربية](docs/i18n/ar-SA/README.md)
<!-- translations:end -->

# plugin_cloud

A Cacti 1.2 plugin that brings resources and metrics from public cloud providers into Cacti as ordinary devices, data sources, and graphs. Cloud workloads then sit next to the network that carries them, under Cacti's permissions, and Thold and Maint can alert on and suppress them. One plugin covers every provider, with a driver per provider: DigitalOcean, AWS, Google Cloud, and Azure first.

> **Status: milestone 3 (DigitalOcean and Cacti objects), in review.** The milestone adds the DigitalOcean driver, Cacti templates, a scope device per account with a data query per resource type, the script server input, and a request estimate on New Graphs and the health page. Initial checks against a live DigitalOcean account are recorded in [provider facts](docs/research/provider-facts.md). Do not run it in production.

## Access roles

| Realm | Access |
| --- | --- |
| Cloud View | Existing monitoring pages. |
| Cloud Operator | Monitoring plus the Operations page and personal triage acknowledgments. |
| Cloud Admin | Operator access plus the existing configuration and administrative actions. |

After copying upgrade files, open the Plugins page as an administrator to register
the new realm. Assign the Operator realm explicitly under **Configuration > Users** or user groups.
Upgrades retain the existing View and Admin realm IDs and grants. Admin access
inherits Operator access, and Operator access inherits View access on each request;
this does not add stored grants to users or groups. Plugin settings also require
Cloud Admin access in addition to Cacti's Settings permission.

Cacti device permissions still limit the rows and actions available to each user; unmapped objects require an administrator. Operators can verify the stored credential for an account whose Cacti device they may access.
Credentials, configuration, mapping, deletion and other administrative changes
remain in the administrative pages. Acknowledgments last only in the current
user's session, for at most one hour and only while the same observation remains
fresh. New or changed observations invalidate them. They never mark a failed
measurement healthy or suppress alerts.

## Why

Each cloud provider has its own monitoring console. Run alongside Cacti, they leave three gaps:
Expand Down Expand Up @@ -38,7 +64,7 @@ Out of scope: changing cloud resources, creating or mirroring provider alarms, b

- **A guarded install.** On PHP below 8.2, or without ext-openssl, install and enable are refused with a message, and the rest of Cacti keeps working.
- **Lifecycle.** Install, upgrade, and uninstall through Cacti's Plugins page. Upgrades are ordered and survive interruption. Uninstall keeps the plugin's tables unless you clear *Keep Plugin Tables on Uninstall*.
- **Two realms.** *Cloud Admin* opens **Cloud Accounts**; *Cloud View* opens **Cloud Health**. Both pages are under Management.
- **Separate realms.** *Cloud Admin* opens **Cloud Accounts**; *Cloud View* opens **Cloud Health**. Both pages are under Management.
- **Accounts and credentials.** Add, edit, verify, and delete accounts. A credential is either encrypted in the database with a key file kept outside it (AES-256-GCM), or read from a file on the poller. Credentials are write-only in the UI and are redacted from logs.
- **The collector.** It starts from each poller run, one instance per poller, within a time budget. It takes a lease per account, runs discovery on its own interval, and reads metrics only for the plugin's own active data sources.
- **Health.** Per-account collection, discovery, resource, and freshness state, plus warnings for an unusable vault key, unsafe credential files, and intervals the poller cannot honour.
Expand Down
115 changes: 115 additions & 0 deletions cloud_operator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?php
/*
* SPDX-FileCopyrightText: 2026 Thomas Vincent <thomasvincent@gmail.com>
* SPDX-License-Identifier: GPL-2.0-or-later
*
* This file is part of plugin_cloud, a plugin for Cacti.
* https://github.com/somethingwithproof/plugin_cloud
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*/

use Somethingwithproof\Cloud\OperatorPage;

chdir('../../');
include('./include/auth.php');
include_once('./plugins/cloud/setup.php');

if (!cloud_page_start()) {
exit;
}
require_once('./plugins/cloud/include/operator.php');

$user = (int) ($_SESSION['sess_user_id'] ?? 0);
$allowed = $user > 0 && api_plugin_user_realm_auth('cloud_operator.php');

if (!$allowed) {
http_response_code(403);
exit;
}
$actions = ['verify' => __('Verify stored credential', 'cloud')];
$action = (string) get_nfilter_request_var('action');
$session = $_SESSION['cloud_triage'] ?? [];
$session = is_array($session) ? $session : [];

try {
// Re-read on POST too: stale forms never retain revoked device access.
$rows = cloud_operator_rows();
$now = time();

if ($action !== '' && $action !== 'default') {
$method = $_SERVER['REQUEST_METHOD'] ?? '';
$status = OperatorPage::actionStatus($allowed, $action, $method, $method === 'POST' && csrf_check(false), array_merge(['acknowledge'], array_keys($actions)));

if ($status !== 200) {
http_response_code($status);

if ($status === 405) {
header('Allow: POST');
}
exit;
}
$id = (string) get_nfilter_request_var('id');
$row = null;

foreach ($rows as $candidate) {
if ($candidate['id'] === $id) {
$row = $candidate;

break;
}
}

if ($row === null) {
http_response_code(403);
exit;
}
$fingerprint = (string) get_nfilter_request_var('fingerprint');

if (!hash_equals(OperatorPage::fingerprint($row), $fingerprint)) {
http_response_code(409);
exit;
}

if ($action === 'acknowledge') {
if (!OperatorPage::acknowledge($session, $row, $fingerprint, $user, $now)) {
http_response_code(409);
exit;
}
$_SESSION['cloud_triage'] = $session;
} else {
// Bound repeated requests from a browser without changing collector budgets.
$key = (string) $user;
$last = $_SESSION['cloud_operation'] ?? [];

if (($last['key'] ?? '') === $key && $now - ($last['at'] ?? 0) < 60) {
http_response_code(429);
header('Retry-After: 60');
exit;
}
$_SESSION['cloud_operation'] = ['key' => $key, 'at' => $now];
cloud_operator_verify((int) $row['id'], $user);
}
cacti_log('Operator ' . $action . ' by user ' . $user . ' on object ' . hash('sha256', $id), false, 'CLOUD');
header('Location: cloud_operator.php');
exit;
}
top_header();
print '<p><a href="cloud_health.php">' . html_escape(__('Monitoring view', 'cloud')) . '</a></p>';
OperatorPage::render($rows, $session, $user, $now, $actions);
bottom_footer();
} catch (Throwable $error) {
cacti_log('Operator page failed (' . get_class($error) . ')', false, 'CLOUD');
http_response_code(503);
top_header();
print '<p class="textError">' . html_escape(__('Observations could not be read. Ask an administrator to check the plugin log.', 'cloud')) . '</p>';
bottom_footer();
}
2 changes: 1 addition & 1 deletion docs/PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ Short-lived tokens are cached per collector run. When a provider limits how ofte

| Boundary | Control |
|---|---|
| Browser to Cacti | Cacti session, csrf-magic, two plugin realms (Cloud View, Cloud Admin), device and graph permissions, prepared queries, contextual escaping |
| Browser to Cacti | Cacti session, csrf-magic, three plugin realms (Cloud View, Cloud Operator, Cloud Admin), device and graph permissions, prepared queries, contextual escaping |
| Cacti to stored credentials | Vault encryption with a key file outside the database, file checks on credential and key files, secrets never returned to the browser or logged, redaction of known secrets and `Authorization` values from every error |
| Cacti to provider APIs | Outbound allowlist built from fixed per-provider host tables and validated scope fields; HTTPS with verification; no redirects; size and time limits; operation allowlist ([ADR 0002](decisions/0002-read-only-with-operation-allowlist.md)) |
| Cacti to instance metadata | Reachable only for an account whose credential source is instance identity, only at the provider's documented address, and only for the token path |
Expand Down
Loading
Loading