Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
091f9dc
feat: PHP 8.2 guard, class layout, autoloader, and logging
somethingwithproof Nov 15, 2026
d29e845
ci: PHP 8.0 lint, Pest, PHPStan, and install matrix
somethingwithproof Nov 15, 2026
cee5c71
feat: plugin lifecycle, realms, settings, and navigation
somethingwithproof Nov 15, 2026
f7fb845
feat: accounts, credential vault, and secret handling
somethingwithproof Nov 15, 2026
c42721f
feat: HTTPS transport, outbound policy, and provider driver contract
somethingwithproof Nov 15, 2026
9cd08e7
fix: refuse encoded path separators and ambiguous operation requests
somethingwithproof Nov 15, 2026
8a902c6
feat: Cloud Accounts page with Verify
somethingwithproof Nov 15, 2026
e60da99
feat: collector, leases, and observation cache with freshness
somethingwithproof Nov 15, 2026
02149b5
feat: Cloud Health page and page permission checks
somethingwithproof Nov 15, 2026
d62994d
fix: escape the account name in the edit page title
somethingwithproof Nov 15, 2026
117896d
test: pin vault row normalization
somethingwithproof Nov 15, 2026
d8b0544
ci: drop the unused readiness loop variable
somethingwithproof Nov 15, 2026
72481ca
fix: address review findings on the M2 foundation
somethingwithproof Nov 15, 2026
2364c82
ci: check core pages load on PHP 8.1 with the plugin enabled
somethingwithproof Nov 15, 2026
bf71e3d
test: search page responses for a credential saved through the form
somethingwithproof Nov 15, 2026
60401ce
test: second collector start and a run killed mid-account
somethingwithproof Nov 15, 2026
fa1dd63
feat: health warnings and admin-only credential state
somethingwithproof Nov 15, 2026
e441744
fix: count a run as due within a small slack of its interval
somethingwithproof Nov 15, 2026
c1f190b
test: hold the collector slot with a process running poller_cloud.php
somethingwithproof Nov 15, 2026
28718c9
docs: say the key file's directory must not be writable by others
somethingwithproof Nov 15, 2026
b49197a
docs: describe what milestone 2 ships and how to install it
somethingwithproof Nov 15, 2026
7ae41fd
fix: address the second review round on the M2 foundation
somethingwithproof Nov 15, 2026
b85eb4d
docs: put the delete docblock back on delete()
somethingwithproof Nov 15, 2026
dcae015
fix: find every redaction span in the original text
somethingwithproof Nov 15, 2026
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
424 changes: 424 additions & 0 deletions .github/workflows/plugin-ci-workflow.yml

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
; 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.

[info]
name = cloud
version = 0.1.0-dev
longname = Cloud
author = "Thomas Vincent (somethingwithproof)"
email = thomasvincent@gmail.com
homepage = https://github.com/somethingwithproof/plugin_cloud
compat = 1.2.31
capabilities = online_view:1, online_mgmt:1, offline_view:0, offline_mgmt:0, remote_collect:1
53 changes: 43 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A proposed 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: proposal.** This repository contains no plugin code yet. It holds the design, its decision records, and the requirements tracked as issues and milestones. Nothing below describes shipped behavior.
> **Status: milestone 2 (foundation).** The plugin installs, stores accounts and credentials, and runs its collector, but no provider driver ships yet, so it collects nothing. DigitalOcean arrives in milestone 3. Do not run it in production.

## Why

Expand All @@ -21,19 +21,48 @@ The plugin reads each provider's monitoring API on a Cacti poller, caches the la
- **Cost before collection.** The plugin reads only metrics that have a Cacti data source, shows the expected request count and list-price cost before graphs are created, and enforces a monthly ceiling. ([ADR 0005](docs/decisions/0005-collect-only-what-is-graphed.md))
- **No plaintext credentials in the database.** Credentials come from an encrypted vault keyed by a file outside the database, from a credential file, or from the provider's instance identity. ([ADR 0007](docs/decisions/0007-credentials-outside-the-database-in-the-clear.md))

## Planned scope
## Scope and status

| Phase | Scope | Milestones |
|---|---|---|
| 0, research | Provider fact confirmation, metric catalogs, cost and rate model, signing test vectors, transport spike | [M1](https://github.com/somethingwithproof/plugin_cloud/milestone/1) |
| 1, core and DigitalOcean | Accounts, credential vault, transport, collector, observation cache, Cacti objects, health page, DigitalOcean Droplets and load balancers | [M2](https://github.com/somethingwithproof/plugin_cloud/milestone/2), [M3](https://github.com/somethingwithproof/plugin_cloud/milestone/3), [M4](https://github.com/somethingwithproof/plugin_cloud/milestone/4) |
| 2, AWS | Signature Version 4, `AssumeRole`, instance roles, CloudWatch `GetMetricData`, regional inventory | [M5](https://github.com/somethingwithproof/plugin_cloud/milestone/5) |
| 3, Google Cloud | Service account JWT, metadata server, Cloud Monitoring `timeSeries.list` | [M6](https://github.com/somethingwithproof/plugin_cloud/milestone/6) |
| 4, Azure | Entra client credentials, managed identity, Resource Graph, `metrics:getBatch` | [M7](https://github.com/somethingwithproof/plugin_cloud/milestone/7) |
| 5, remote collectors | Accounts on Cacti remote data collectors | [M8](https://github.com/somethingwithproof/plugin_cloud/milestone/8) |
| Phase | Scope | Milestones | Status |
|---|---|---|---|
| 0, research | Provider fact confirmation, metric catalogs, cost and rate model, signing test vectors, transport spike | [M1](https://github.com/somethingwithproof/plugin_cloud/milestone/1) | Done, except the checks that need a live provider account |
| 1, core and DigitalOcean | Accounts, credential vault, transport, collector, observation cache, Cacti objects, health page, DigitalOcean Droplets and load balancers | [M2](https://github.com/somethingwithproof/plugin_cloud/milestone/2), [M3](https://github.com/somethingwithproof/plugin_cloud/milestone/3), [M4](https://github.com/somethingwithproof/plugin_cloud/milestone/4) | M2 in review ([#81](https://github.com/somethingwithproof/plugin_cloud/pull/81)); M3 and M4 not started |
| 2, AWS | Signature Version 4, `AssumeRole`, instance roles, CloudWatch `GetMetricData`, regional inventory | [M5](https://github.com/somethingwithproof/plugin_cloud/milestone/5) | Not started |
| 3, Google Cloud | Service account JWT, metadata server, Cloud Monitoring `timeSeries.list` | [M6](https://github.com/somethingwithproof/plugin_cloud/milestone/6) | Not started |
| 4, Azure | Entra client credentials, managed identity, Resource Graph, `metrics:getBatch` | [M7](https://github.com/somethingwithproof/plugin_cloud/milestone/7) | Not started |
| 5, remote collectors | Accounts on Cacti remote data collectors | [M8](https://github.com/somethingwithproof/plugin_cloud/milestone/8) | Not started |

Out of scope: changing cloud resources, creating or mirroring provider alarms, billing reports, logs and traces, and a plugin-owned alerting engine. Further providers (Hetzner Cloud, Akamai Cloud, Oracle Cloud, and others) are research issues.

## What milestone 2 ships

- **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.
- **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.

## Install and configure

These steps install the milestone 2 code for evaluation. They require Cacti 1.2.31 or later on PHP 8.2 or later.

1. Copy the repository to `plugins/cloud` under your Cacti directory. The directory must be named `cloud`.
2. Create the vault key outside the web root. Put it in a directory that only root and the Cacti user can write, and make the file readable only by the user that runs the web server and the poller. The plugin never creates or writes this file:

```sh
sudo install -d -m 0750 -o root -g cacti /etc/cacti
head -c 32 /dev/urandom | sudo tee /etc/cacti/cloud-vault.key > /dev/null
sudo chown cacti:cacti /etc/cacti/cloud-vault.key
sudo chmod 0600 /etc/cacti/cloud-vault.key
```

Replace `cacti` with the user that runs your web server and poller. The file holds 32 raw bytes or 64 hexadecimal characters. Back it up with the database; without it, stored credentials must be entered again.
3. In Cacti, open **Configuration > Plugins**, then install and enable *Cloud*.
4. Under **Configuration > Settings > Cloud**, set *Vault Key File* if you used another path. *Collector Time Budget* (default 240 seconds) must stay below the poller interval.
5. Grant *Cloud Admin* or *Cloud View* to users and groups under **Configuration > Users**. Installing grants both realms to the administrator.
6. Add accounts under **Management > Cloud Accounts**, then check **Management > Cloud Health** for warnings.

## Compatibility targets

| Component | Target |
Expand Down Expand Up @@ -66,6 +95,10 @@ flowchart LR
- **Labels** also carry `area:`, `provider:`, `phase:`, `priority:`, and `status:`. See [CONTRIBUTING.md](CONTRIBUTING.md#labels).
- The [project board](https://github.com/users/somethingwithproof/projects/7) shows all issues across milestones.

## Development

CI lints the entry points on PHP 8.0, runs unit and integration tests and PHPStan level 9, and installs the plugin on PHP 8.2 to 8.5 against Cacti 1.2.31 and the 1.2.x branch. It also checks that PHP 8.1 is refused without breaking Cacti. The tests use Pest from Cacti core's plugin harness. That choice is provisional until [#12](https://github.com/somethingwithproof/plugin_cloud/issues/12) is decided. [.github/workflows/plugin-ci-workflow.yml](.github/workflows/plugin-ci-workflow.yml) lists every step. Run `sh tests/lint-workflows.sh` and `sh locales/build_gettext.sh --check` locally before pushing.

## Contributing

Read [CONTRIBUTING.md](CONTRIBUTING.md). Commits need a DCO sign-off. Design discussion happens on issues; open decisions carry the `type: decision` label.
Expand Down
7 changes: 6 additions & 1 deletion REUSE.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
version = 1

# Files that cannot carry a comment header, or whose format makes one
# awkward: documentation, repository metadata, and GitHub templates.
# awkward: documentation, repository metadata, GitHub templates, test
# configuration, and translation catalogs, which gettext regenerates.
[[annotations]]
path = [
"README.md",
Expand All @@ -12,6 +13,10 @@ path = [
".editorconfig",
".gitattributes",
"REUSE.toml",
"phpunit.xml",
"phpunit-integration.xml",
"locales/po/**",
"locales/LC_MESSAGES/**",
]
precedence = "aggregate"
SPDX-FileCopyrightText = "2026 Thomas Vincent <thomasvincent@gmail.com>"
Expand Down
128 changes: 128 additions & 0 deletions cloud_accounts.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
<?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.
*/

/*
* Cloud Accounts (Cloud Admin realm). This file must parse on PHP 8.0: Cacti
* may include it on an unsupported runtime, and cloud_page_start() refuses
* there before any plugin class loads.
*/

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

if (!cloud_page_start()) {
exit;
}

cloud_require_post('cloud_accounts.php', array('save', 'delete', 'verify'));

$cloud_accounts = cloud_accounts();
$cloud_credentials = cloud_credentials();
$cloud_page = new \Somethingwithproof\Cloud\AccountsPage($cloud_accounts, $cloud_credentials);
$cloud_user = isset($_SESSION['sess_user_id']) && is_numeric($_SESSION['sess_user_id']) ? (int) $_SESSION['sess_user_id'] : 0;
$cloud_action = (string) get_nfilter_request_var('action');

switch ($cloud_action) {
case 'save':
$cloud_id = (int) get_filter_request_var('id');
$cloud_input = array();

foreach (array('provider', 'name', 'poller_id', 'credential_source', 'credential_file', 'collect_interval', 'discover_interval', 'request_share', 'monthly_ceiling', 'enabled', 'scope_account_id', 'scope_regions', 'scope_project', 'scope_tenant', 'scope_subscription') as $cloud_field) {
$cloud_input[$cloud_field] = (string) get_nfilter_request_var($cloud_field);
}

$cloud_existing = $cloud_id > 0 ? $cloud_accounts->find($cloud_id) : null;

if ($cloud_id > 0 && $cloud_existing === null) {
header('Location: cloud_accounts.php');
exit;
}

// An existing account keeps its provider; only new ones choose.
if ($cloud_existing !== null) {
$cloud_input['provider'] = $cloud_existing->provider->value;
}

$cloud_parsed = \Somethingwithproof\Cloud\AccountInput::parse($cloud_input, $cloud_id, \Somethingwithproof\Cloud\Provider::released());
$cloud_errors = $cloud_parsed->errors;

if ($cloud_parsed->account !== null && $cloud_accounts->nameTaken($cloud_parsed->account->name, $cloud_id)) {
$cloud_errors['name'] = __('Name: another account already uses this name.', 'cloud');
}

if ($cloud_errors !== array() || $cloud_parsed->account === null) {
top_header();
$cloud_page->renderEdit($cloud_existing, $cloud_input, $cloud_errors);
bottom_footer();
exit;
}

$cloud_saved = $cloud_accounts->save($cloud_parsed->account, $cloud_user);
$cloud_raw = trim((string) get_nfilter_request_var('credential'));

if ($cloud_saved > 0 && $cloud_raw !== '') {
try {
$cloud_credentials->storeVaultCredential($cloud_saved, new \Somethingwithproof\Cloud\Secret($cloud_raw));
$cloud_accounts->recordCredentialChange($cloud_saved, $cloud_user);
} catch (\Somethingwithproof\Cloud\CredentialError $cloud_error) {
raise_message('cloud_credential', __('The account was saved, but the credential was not stored: %s', $cloud_error->getMessage(), 'cloud'), MESSAGE_LEVEL_ERROR);
}
}

unset($cloud_raw);

if ($cloud_saved > 0) {
raise_message('cloud_saved', __('The account was saved.', 'cloud'), MESSAGE_LEVEL_INFO);
} else {
raise_message('cloud_saved', __('The account could not be saved.', 'cloud'), MESSAGE_LEVEL_ERROR);
}

header('Location: cloud_accounts.php');
exit;
case 'delete':
if ($cloud_accounts->delete((int) get_filter_request_var('id'), $cloud_user)) {
raise_message('cloud_deleted', __('The account and its collected data were deleted. Its Cacti devices and graphs were left in place.', 'cloud'), MESSAGE_LEVEL_INFO);
}

header('Location: cloud_accounts.php');
exit;
case 'verify':
$cloud_account = $cloud_accounts->find((int) get_filter_request_var('id'));

if ($cloud_account !== null) {
$cloud_status = (new \Somethingwithproof\Cloud\Verifier(\Somethingwithproof\Cloud\Drivers::production(), $cloud_credentials, $cloud_accounts))->verify($cloud_account, $cloud_user);

raise_message('cloud_verify', $cloud_status->message(), $cloud_status === \Somethingwithproof\Cloud\VerifyStatus::Ok ? MESSAGE_LEVEL_INFO : MESSAGE_LEVEL_WARN);
}

header('Location: cloud_accounts.php');
exit;
case 'edit':
$cloud_id = (int) get_filter_request_var('id');

top_header();
$cloud_page->renderEdit($cloud_id > 0 ? $cloud_accounts->find($cloud_id) : null);
bottom_footer();
exit;
default:
top_header();
$cloud_page->renderList();
bottom_footer();
}
46 changes: 46 additions & 0 deletions cloud_health.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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.
*/

/*
* Cloud Health (Cloud View realm). Parses on PHP 8.0; cloud_page_start()
* refuses an unsupported runtime before any plugin class loads.
*/

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

if (!cloud_page_start()) {
exit;
}

$cloud_clock = new \Somethingwithproof\Cloud\SystemClock();
$cloud_page = new \Somethingwithproof\Cloud\HealthPage(
cloud_accounts(),
new \Somethingwithproof\Cloud\HealthRepository(false),
new \Somethingwithproof\Cloud\ResourceRepository(false, $cloud_clock),
new \Somethingwithproof\Cloud\ObservationRepository(false),
new \Somethingwithproof\Cloud\FreshnessEvaluator($cloud_clock),
\Somethingwithproof\Cloud\HealthWarnings::production(),
$cloud_clock
);

top_header();
$cloud_page->render(cloud_settings(), api_user_realm_auth('cloud_accounts.php'), (int) read_config_option('poller_interval'));
bottom_footer();
45 changes: 45 additions & 0 deletions include/autoload.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?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.
*/

/*
* Class loader for lib/. Required only by cloud_boot() after the PHP version
* check, so class files may use PHP 8.2 syntax. This file itself stays PHP 8.0
* compatible because it sits on the include path of setup.php.
*/

spl_autoload_register(function ($class) {
$prefix = 'Somethingwithproof\\Cloud\\';

if (strncmp($class, $prefix, strlen($prefix)) !== 0) {
return;
}

$name = substr($class, strlen($prefix));

// One flat directory: a namespace separator in the remainder is never ours.
if (strpos($name, '\\') !== false) {
return;
}

$file = dirname(__DIR__) . '/lib/' . $name . '.php';

if (is_file($file)) {
require_once($file);
}
});
39 changes: 39 additions & 0 deletions include/unbooted-uninstall.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?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.
*/

/*
* Uninstall on a runtime the plugin refuses (PHP below 8.2, or a missing
* extension), where nothing under lib/ may load. Cacti goes on to drop every
* tracked plugin table after plugin_cloud_uninstall() returns, so the keep
* tables setting must be honoured here too, in PHP 8.0 syntax. It mirrors
* Settings::fromRow() and Schema::untrackTables() / forgetVersion(); the
* lifecycle integration tests run both paths.
*/

function cloud_uninstall_unbooted(): void {
$row = db_fetch_row_prepared('SELECT value FROM settings WHERE name = ?', array('cloud_uninstall_keep_tables'));
$keep = !is_array($row) || $row === array() || (isset($row['value']) && $row['value'] === 'on');

if ($keep) {
db_execute_prepared("DELETE FROM plugin_db_changes WHERE plugin = ? AND method = 'create'", array('cloud'));
cacti_log('NOTE: Uninstall kept the plugin tables as configured', false, 'CLOUD');
} else {
db_execute_prepared('DELETE FROM settings WHERE name = ?', array('cloud_schema_version'));
}
}
Loading
Loading