diff --git a/REUSE.toml b/REUSE.toml index 8d208f1..5979ddc 100644 --- a/REUSE.toml +++ b/REUSE.toml @@ -17,6 +17,7 @@ path = [ "phpunit-integration.xml", "locales/po/**", "locales/LC_MESSAGES/**", + "templates/**", ] precedence = "aggregate" SPDX-FileCopyrightText = "2026 Thomas Vincent " diff --git a/docs/PLAN.md b/docs/PLAN.md index 876bdc3..317b761 100644 --- a/docs/PLAN.md +++ b/docs/PLAN.md @@ -220,13 +220,13 @@ The mapping, decided in [ADR 0010](decisions/0010-scope-devices-with-resource-da | Object | Created from | Notes | |---|---|---| -| Scope device | "Cloud Scope" device template; each device created with availability method None (`AVAIL_NONE`, 0) and the account's poller, because a Cacti 1.2 device template has no availability field | One per account and scope: a DigitalOcean team, an AWS account and region, a Google Cloud project, an Azure subscription and region | +| Scope device | A device template per provider, for example "Cloud: DigitalOcean Scope", carrying that provider's data queries; each device created with availability method None (`AVAIL_NONE`, 0) and the account's poller, because a Cacti 1.2 device template has no availability field | One per account and scope: a DigitalOcean team, an AWS account and region, a Google Cloud project, an Azure subscription and region | | Resource data query | Script server data query per resource type, for example "Cloud: DigitalOcean Droplets" | Indexes are provider resource IDs; descriptions are resource names; reindexing follows Cacti's normal behavior | -| Data sources and graphs | Data and graph templates per resource type, generated from the metric catalog | Polled through the script server; reach Thold through `poller_output` | +| Data sources and graphs | A data template and a graph template per catalog graph, generated from the metric catalog | A graph's data source holds only that graph's metrics, so creating a graph collects nothing else ([ADR 0005](decisions/0005-collect-only-what-is-graphed.md)); polled through the script server; reach Thold through `poller_output` | This follows plugin_cloudflare's pattern of one account device with resources as data query indexes. It keeps device counts proportional to accounts, not to resources, and Cacti's reindexing handles resources that come and go. The cost is that Maint suppresses a whole scope, not one resource, and a virtual machine's cloud graphs do not sit on the Cacti device that polls the same machine over SNMP. Mapping resources onto existing devices is a research issue. -Templates ship as Cacti template XML in the plugin and are imported with `import_xml_data()` at install and upgrade, matched by hash so re-imports update rather than duplicate. +Templates ship as Cacti template XML in `templates/`, generated from the catalog by `php tests/bin/generate-templates.php templates`; a unit test fails when the shipped files and the catalog disagree. Install and upgrade import them with `import_xml_data()` when the package changed or an object is missing, matched by fixed hashes so re-imports update rather than duplicate. Each data query definition is copied into `/resource/script_server/`, because Cacti 1.2 refuses a data query file outside `/resource`; uninstall leaves the templates and those files, because devices and graphs may still use them. ## Collection and measurement state diff --git a/lib/DigitalOceanCatalog.php b/lib/DigitalOceanCatalog.php index 1b02c4c..a85c872 100644 --- a/lib/DigitalOceanCatalog.php +++ b/lib/DigitalOceanCatalog.php @@ -84,6 +84,46 @@ final class DigitalOceanCatalog { 'dolb_queue' => [self::LOAD_BALANCER, 'droplets_queue_size', [], 'single', false], ]; + /** + * The data source name of each resource type's collection age, which the + * script server computes from the cache (ADR 0006); no API request reads it. + */ + public const AGE = [self::DROPLET => 'do_age', self::LOAD_BALANCER => 'dolb_age']; + + /** + * Graph templates: key => [type, title, vertical label, upper limit or + * null, data source names]. Each graph gets its own data template, so a + * graph collects only its own metrics (ADR 0005). Every metric and age + * name appears in exactly one graph; a template test checks it. + * + * @var array}> + */ + public const GRAPHS = [ + 'do_cpu' => [self::DROPLET, 'CPU', 'percent', 100, ['do_cpu_pct']], + 'do_bandwidth' => [self::DROPLET, 'Bandwidth', 'bits per second', null, [ + 'do_bw_pub_in', 'do_bw_pub_out', 'do_bw_prv_in', 'do_bw_prv_out', + ]], + 'do_load' => [self::DROPLET, 'Load Average', 'load', null, ['do_load_1', 'do_load_5', 'do_load_15']], + 'do_memory' => [self::DROPLET, 'Memory', 'bytes', null, [ + 'do_mem_total', 'do_mem_avail', 'do_mem_free', 'do_mem_cached', + ]], + 'do_age' => [self::DROPLET, 'Collection Age', 'seconds', null, ['do_age']], + 'dolb_connections' => [self::LOAD_BALANCER, 'Connections', 'connections', null, ['dolb_conn_cur', 'dolb_conn_lim']], + 'dolb_cpu' => [self::LOAD_BALANCER, 'CPU', 'percent', 100, ['dolb_cpu_pct']], + 'dolb_http_rps' => [self::LOAD_BALANCER, 'HTTP Requests', 'requests per second', null, ['dolb_http_rps']], + 'dolb_http_resp' => [self::LOAD_BALANCER, 'HTTP Responses', 'responses', null, ['dolb_http_resp']], + 'dolb_throughput' => [self::LOAD_BALANCER, 'Throughput', 'bytes per second', null, [ + 'dolb_http_Bps', 'dolb_tcp_Bps', 'dolb_udp_Bps', 'dolb_nlbtcp_Bps', 'dolb_nlbudp_Bps', + ]], + 'dolb_health' => [self::LOAD_BALANCER, 'Health Checks', 'status', null, ['dolb_hc_status']], + 'dolb_downtime' => [self::LOAD_BALANCER, 'Downtime', 'status', null, ['dolb_downtime']], + 'dolb_response' => [self::LOAD_BALANCER, 'Response Time', 'seconds', null, ['dolb_resp_avg_s', 'dolb_resp_p95_s']], + 'dolb_backend' => [self::LOAD_BALANCER, 'Droplet Connections', 'connections', null, [ + 'dolb_back_conn', 'dolb_queue', + ]], + 'dolb_age' => [self::LOAD_BALANCER, 'Collection Age', 'seconds', null, ['dolb_age']], + ]; + private const FIELDS = ['type', 'path', 'query', 'convert', 'agent']; /** @@ -93,6 +133,13 @@ public static function metric(string $name): ?array { return isset(self::METRICS[$name]) ? self::named(self::METRICS[$name]) : null; } + /** + * @return list every metric name of the catalog, in catalog order + */ + public static function names(): array { + return array_keys(self::METRICS); + } + /** * Metrics read by default for a resource type: those that need no agent. * diff --git a/lib/TemplateRepository.php b/lib/TemplateRepository.php new file mode 100644 index 0000000..68292df --- /dev/null +++ b/lib/TemplateRepository.php @@ -0,0 +1,142 @@ + + * 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. + */ +namespace Somethingwithproof\Cloud; + +/** + * The database side of the shipped Cacti templates: the import lock, the + * checksum of the last imported package, and the imported objects, found by + * the fixed hashes tests/bin/generate-templates.php gives them (ADR 0010). + */ +final class TemplateRepository { + private const SETTING = 'cloud_templates_sha256'; + private const LOCK = 'plugin_cloud_templates'; + + public function __construct(private readonly \PDO|false $connection) { + } + + /** + * Two processes importing at once would create every object twice. The + * lock is per connection, so it ends with the request at the latest. + */ + public function lock(int $timeout): bool { + $locked = db_fetch_cell_prepared('SELECT GET_LOCK(?, ?)', [self::LOCK, $timeout], '', true, $this->connection); + + return (string) $locked === '1'; + } + + public function unlock(): void { + db_execute_prepared('DO RELEASE_LOCK(?)', [self::LOCK], true, $this->connection); + } + + public function recordedChecksum(): string { + $value = db_fetch_cell_prepared( + 'SELECT value FROM settings WHERE name = ?', + [self::SETTING], + '', + true, + $this->connection + ); + + return is_string($value) ? $value : ''; + } + + public function recordChecksum(string $sha256): void { + db_execute_prepared( + 'REPLACE INTO settings (name, value) VALUES (?, ?)', + [self::SETTING, $sha256], + true, + $this->connection + ); + } + + public function defaultProfile(): int { + $id = db_fetch_cell_prepared( + "SELECT id FROM data_source_profiles WHERE `default` = 'on'", + [], + '', + true, + $this->connection + ); + + return is_numeric($id) ? (int) $id : 0; + } + + /** + * Every object the package defines, as table => keys. A missing one means + * the import failed or an administrator deleted it. + * + * @return array> + */ + public static function objects(): array { + $objects = [ + 'host_template' => ['host_template/digitalocean'], + 'snmp_query' => [], + 'data_template' => [], + 'graph_templates' => [], + 'snmp_query_graph' => [], + ]; + + foreach ([DigitalOceanCatalog::DROPLET, DigitalOceanCatalog::LOAD_BALANCER] as $type) { + $objects['snmp_query'][] = 'data_query/' . $type; + } + + foreach (array_keys(DigitalOceanCatalog::GRAPHS) as $key) { + $objects['data_template'][] = 'data_template/' . $key; + $objects['graph_templates'][] = 'graph_template/' . $key; + $objects['snmp_query_graph'][] = 'data_query_graph/' . $key; + } + + return $objects; + } + + /** + * Cacti identifies template objects by 32 hex digits; a truncated SHA-256 + * of a fixed key gives each object a stable one. Not a security control. + */ + public static function hash(string $key): string { + return substr(hash('sha256', 'plugin_cloud/' . $key), 0, 32); + } + + /** + * @return list the keys of package objects not in the database + */ + public function missing(): array { + $missing = []; + + // The table names come from objects(), never from input. + foreach (self::objects() as $table => $keys) { + $hashes = array_map(self::hash(...), $keys); + $found = db_fetch_assoc_prepared( + 'SELECT hash FROM `' . $table . '` WHERE hash IN (' . implode(', ', array_fill(0, count($hashes), '?')) . ')', + $hashes, + true, + $this->connection + ); + $have = array_column(is_array($found) ? $found : [], 'hash'); + + foreach ($keys as $i => $key) { + if (!in_array($hashes[$i], $have, true)) { + $missing[] = $key; + } + } + } + + return $missing; + } +} diff --git a/lib/Templates.php b/lib/Templates.php new file mode 100644 index 0000000..b1477da --- /dev/null +++ b/lib/Templates.php @@ -0,0 +1,171 @@ + + * 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. + */ +namespace Somethingwithproof\Cloud; + +/** + * Installs the shipped Cacti templates (REQ-OBJ-001, REQ-OBJ-002): copies + * each data query definition into Cacti's resource directory, then imports + * the package when it changed since the last import or an object is + * missing. The package's fixed hashes make a re-import update the objects + * it already created, never duplicate them. + * + * Install and upgrade call this. A failure is logged and returns false; the + * caller does not hold back the install, because retrying a failing import + * on every page would cost more than it could fix. + */ +final class Templates { + public const PACKAGE = 'cloud_digitalocean.xml'; + + /** + * @param string $source the plugin's templates directory + * @param string $resourcePath /resource/script_server + * @param \Closure(string, int): bool $import runs Cacti's importer on the + * package XML with a data source profile, true when every object saved + */ + public function __construct( + private readonly TemplateRepository $repository, + private readonly string $source, + private readonly string $resourcePath, + private readonly \Closure $import, + ) { + } + + /** + * True when the shipped package is the one last imported. Cheap enough + * for the upgrade check: one file read and one settings row. + */ + public function isCurrent(): bool { + $xml = @file_get_contents($this->source . '/' . self::PACKAGE); + + return $xml !== false && $this->repository->recordedChecksum() === hash('sha256', $xml); + } + + public function install(int $lockTimeout = 10): bool { + if (!is_dir($this->resourcePath)) { + Log::error('Templates not installed: the Cacti resource directory is missing'); + + return false; + } + + if (!$this->repository->lock($lockTimeout)) { + Log::warning('Template import deferred: another process holds the template lock'); + + return false; + } + + try { + return $this->installLocked(); + } catch (\Throwable $e) { + Log::error('Template import failed (' . $e::class . ')'); + + return false; + } finally { + $this->repository->unlock(); + } + } + + private function installLocked(): bool { + foreach (glob($this->source . '/resource/*.xml') ?: [] as $file) { + if (!$this->copy($file, $this->resourcePath . '/' . basename($file))) { + return false; + } + } + + $xml = @file_get_contents($this->source . '/' . self::PACKAGE); + + if ($xml === false) { + Log::error('Template import failed: cannot read the package'); + + return false; + } + + $sha = hash('sha256', $xml); + + if ($this->repository->recordedChecksum() === $sha && $this->repository->missing() === []) { + return true; + } + + $profile = $this->repository->defaultProfile(); + + if ($profile === 0) { + Log::error('Template import skipped: no default data source profile'); + + return false; + } + + if (!($this->import)($xml, $profile)) { + Log::error('Template import failed: the importer reported an error'); + + return false; + } + + $missing = $this->repository->missing(); + + if ($missing !== []) { + Log::error('Template import failed: ' . count($missing) . ' objects missing after import'); + + return false; + } + + $this->repository->recordChecksum($sha); + + return true; + } + + /** + * Writes a temporary file beside the target and renames it over it, so + * the poller never reads a half-written definition. Mode 'x' refuses an + * existing name, so a planted link at the temporary path is not followed. + */ + private function copy(string $from, string $to): bool { + $content = @file_get_contents($from); + + if ($content === false) { + Log::error('Template import failed: cannot read ' . basename($from)); + + return false; + } + + if (!is_link($to) && is_file($to) && @file_get_contents($to) === $content) { + return true; + } + + $temp = dirname($to) . '/.' . basename($to) . '.' . bin2hex(random_bytes(8)); + $handle = @fopen($temp, 'xb'); + + if ($handle === false) { + Log::error('Template import failed: cannot write ' . basename($to)); + + return false; + } + + $written = fwrite($handle, $content); + $closed = fclose($handle); + + // fopen() honours the umask, and the poller may run as another user. + if ($written !== strlen($content) || !$closed || !@chmod($temp, 0644) || !@rename($temp, $to)) { + @unlink($temp); + Log::error('Template import failed: cannot write ' . basename($to)); + + return false; + } + + return true; + } +} diff --git a/setup.php b/setup.php index 4dbece9..5160ed4 100644 --- a/setup.php +++ b/setup.php @@ -215,7 +215,12 @@ function plugin_cloud_upgrade(bool $grant = false): bool { $info = plugin_cloud_version(); $schema = new \Somethingwithproof\Cloud\Schema(false); - if ($schema->isCurrent() && $schema->recordedPluginVersion() === $info['version'] && $schema->hooksRegistered()) { + if ( + $schema->isCurrent() + && $schema->recordedPluginVersion() === $info['version'] + && $schema->hooksRegistered() + && cloud_templates()->isCurrent() + ) { return true; } @@ -227,6 +232,9 @@ function plugin_cloud_upgrade(bool $grant = false): bool { cloud_setup_hooks($grant); + // A failed import is logged and does not hold back the version (see Templates). + cloud_setup_templates(); + $schema->recordPluginVersion($info['version'], $info['author'], $info['homepage']); return true; @@ -256,6 +264,74 @@ function cloud_setup_hooks(bool $grant = false): void { } } +/** + * Import the shipped device, data query, data and graph templates. + */ +function cloud_setup_templates(int $lockTimeout = 10): bool { + global $config; + + // templates_import.php loads the same three: import.php calls + // retemplate_graphs() and update_replication_crc() from the other two. + $libraries = array( + 'import_xml_data' => 'import.php', + 'retemplate_graphs' => 'template.php', + 'update_replication_crc' => 'utility.php', + ); + + foreach ($libraries as $function => $file) { + if (!function_exists($function)) { + include_once($config['library_path'] . '/' . $file); + } + } + + return cloud_templates()->install($lockTimeout); +} + +function cloud_templates(): \Somethingwithproof\Cloud\Templates { + global $config; + + return new \Somethingwithproof\Cloud\Templates( + new \Somethingwithproof\Cloud\TemplateRepository(false), + __DIR__ . '/templates', + $config['base_path'] . '/resource/script_server', + function (string $xml, int $profile): bool { + return cloud_import_templates($xml, $profile); + } + ); +} + +/** + * import_xml_data() reports problems three ways, none of them through + * is_error_message(): it returns false or an empty array, it queues + * messages in the global $import_messages, and it marks an object it could + * not save with a result other than 'success'. All three are checked here; + * Templates then checks that every object resolves by hash. + */ +function cloud_import_templates(string $xml, int $profile): bool { + global $import_messages; + + $import_messages = array(); + $results = import_xml_data($xml, false, $profile); + + if (!is_array($results) || $results === array() || count($import_messages) > 0) { + return false; + } + + foreach ($results as $type => $items) { + if ($type === 'files' || !is_array($items)) { + continue; + } + + foreach ($items as $item) { + if (!is_array($item) || !isset($item['result']) || $item['result'] !== 'success') { + return false; + } + } + } + + return true; +} + /** * Uninstall never touches cloud resources or provider accounts. Core drops * the tracked plugin tables afterwards unless the administrator left "Keep diff --git a/templates/cloud_digitalocean.xml b/templates/cloud_digitalocean.xml new file mode 100644 index 0000000..c11d534 --- /dev/null +++ b/templates/cloud_digitalocean.xml @@ -0,0 +1,4948 @@ + + + Cloud: DigitalOcean Scope + application + + hash_040103fd85703889147ba4f87358f27117676d|hash_04010366f452ea62c5c77feecaa64ff3f1e4c6 + + + Cloud: DigitalOcean Droplets - CPU + + + + + |host_description| - |query_resourceName| - CPU + + percent + + 3 + + 200 + + 700 + + 1000 + + on + + + + 2 + + + + + + on + + 100 + + 0 + + + + + + + + + + + + + + + + 0 + + 0 + + 0 + + on + + + + + + 40 + + 0 + + 0 + + + + 4 + hash_0801033c2c5c7bef9af3836c127a740622d809 + 4668E4 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + do_cpu_pct + + 1.00 + + 0 + 1 + + + 9 + hash_0801033c2c5c7bef9af3836c127a740622d809 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 2 + + + 9 + hash_0801033c2c5c7bef9af3836c127a740622d809 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 3 + + + 9 + hash_0801033c2c5c7bef9af3836c127a740622d809 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 4 + + + + + Data Source [do_cpu_pct] + + task_item_id + hash_000103d0b1729673e39a080a29b5e71182d287|hash_0001036d435ed9488886c94d45a8abff1b0788|hash_00010395015d3685e55d67120a9746800c475a|hash_000103d0abbfcf52ff27a0d529bf58e93bf7b9 + + + + + Cloud: DigitalOcean Droplets - Bandwidth + + + + + |host_description| - |query_resourceName| - Bandwidth + + bits per second + + 3 + + 200 + + 700 + + 1000 + + on + + on + + 2 + + + + + + + + 100 + + 0 + + + + + + + + + + + + + + + + 0 + + 0 + + 0 + + on + + + + + + 40 + + 0 + + 0 + + + + 4 + hash_080103749c1c0bff50b3e5efd4de51d04adb69 + 4668E4 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + do_bw_pub_in + + 1.00 + + 0 + 1 + + + 9 + hash_080103749c1c0bff50b3e5efd4de51d04adb69 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 2 + + + 9 + hash_080103749c1c0bff50b3e5efd4de51d04adb69 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 3 + + + 9 + hash_080103749c1c0bff50b3e5efd4de51d04adb69 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 4 + + + 4 + hash_080103bfb1c26e1a42b5e82649936055a62461 + 00CF00 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + do_bw_pub_out + + 1.00 + + 0 + 5 + + + 9 + hash_080103bfb1c26e1a42b5e82649936055a62461 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 6 + + + 9 + hash_080103bfb1c26e1a42b5e82649936055a62461 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 7 + + + 9 + hash_080103bfb1c26e1a42b5e82649936055a62461 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 8 + + + 4 + hash_0801030a8ddbb80268836e955ac18809a9ab8b + EA8F00 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + do_bw_prv_in + + 1.00 + + 0 + 9 + + + 9 + hash_0801030a8ddbb80268836e955ac18809a9ab8b + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 10 + + + 9 + hash_0801030a8ddbb80268836e955ac18809a9ab8b + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 11 + + + 9 + hash_0801030a8ddbb80268836e955ac18809a9ab8b + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 12 + + + 4 + hash_080103330713ba80d37efbf00a3dc9c8ae40cf + F51D30 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + do_bw_prv_out + + 1.00 + + 0 + 13 + + + 9 + hash_080103330713ba80d37efbf00a3dc9c8ae40cf + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 14 + + + 9 + hash_080103330713ba80d37efbf00a3dc9c8ae40cf + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 15 + + + 9 + hash_080103330713ba80d37efbf00a3dc9c8ae40cf + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 16 + + + + + Data Source [do_bw_pub_in] + + task_item_id + hash_000103d13fe07a1431053ece433f0261dd8c64|hash_00010316656169824454602a2b43df97aef9dd|hash_000103a2ce1e51b4a9638b47cd60555f0d9590|hash_000103f25e0d598f0d938c01098858285f5751 + + + Data Source [do_bw_pub_out] + + task_item_id + hash_0001035e648f9c0edcb1f1c7bafb0830fb0334|hash_00010308dfe02120d32fc2dc98aec70c7b0017|hash_000103d2ec98088c5e4e1c075f7598d34e6267|hash_000103f82a9b8e2f3eb15a8717de5635a76c50 + + + Data Source [do_bw_prv_in] + + task_item_id + hash_00010388c596dcd8667596dba58b7991aa5738|hash_000103c1ba8b5f3d615a8204ed975d035d7a42|hash_0001036f8665dccf035931f69a54227a0e6984|hash_000103f4a018038a1961a3469a0d7b4dc2eb97 + + + Data Source [do_bw_prv_out] + + task_item_id + hash_0001032dc2d30bba41b77027f810fed67acf11|hash_000103bdca328cfabf08de0918f9a31f173307|hash_0001030dea1fc290515399a093ec2c2d9606da|hash_0001039a7d260f826862542166fef017281e1e + + + + + Cloud: DigitalOcean Droplets - Load Average + + + + + |host_description| - |query_resourceName| - Load Average + + load + + 3 + + 200 + + 700 + + 1000 + + on + + on + + 2 + + + + + + + + 100 + + 0 + + + + + + + + + + + + + + + + 0 + + 0 + + 0 + + on + + + + + + 40 + + 0 + + 0 + + + + 4 + hash_0801037f5c3372f415b68c01bec323326a96a1 + 4668E4 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + do_load_1 + + 1.00 + + 0 + 1 + + + 9 + hash_0801037f5c3372f415b68c01bec323326a96a1 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 2 + + + 9 + hash_0801037f5c3372f415b68c01bec323326a96a1 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 3 + + + 9 + hash_0801037f5c3372f415b68c01bec323326a96a1 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 4 + + + 4 + hash_080103451b06faafa516ef55eef1a3cecff70b + 00CF00 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + do_load_5 + + 1.00 + + 0 + 5 + + + 9 + hash_080103451b06faafa516ef55eef1a3cecff70b + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 6 + + + 9 + hash_080103451b06faafa516ef55eef1a3cecff70b + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 7 + + + 9 + hash_080103451b06faafa516ef55eef1a3cecff70b + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 8 + + + 4 + hash_0801030182ca5e8103dbf8bedd2f2c3fdb51c3 + EA8F00 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + do_load_15 + + 1.00 + + 0 + 9 + + + 9 + hash_0801030182ca5e8103dbf8bedd2f2c3fdb51c3 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 10 + + + 9 + hash_0801030182ca5e8103dbf8bedd2f2c3fdb51c3 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 11 + + + 9 + hash_0801030182ca5e8103dbf8bedd2f2c3fdb51c3 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 12 + + + + + Data Source [do_load_1] + + task_item_id + hash_0001034285f04f8b78ee2bc23f7f1aac6946f4|hash_00010383244e72c2241ac310d8c8a2d2312c10|hash_000103fe33f2625140df03cee9b83e4c644bc7|hash_00010394b0898dde5ce1e8b3fea1a9f7e59496 + + + Data Source [do_load_5] + + task_item_id + hash_00010364c8eac3d934cc7e95957b74b0b2bafe|hash_0001037ce992973943fdf734c1077f3aedec23|hash_0001031b757dd4be7795d690131e108fecc5db|hash_000103be86fd982ea56b0303ea4ce702cbf9e8 + + + Data Source [do_load_15] + + task_item_id + hash_000103eacb96ae9a7960ad44dff754f781f7bd|hash_0001033a54e2e3f80bda0a392239624104a529|hash_000103b3c8154b8c2cb2a9cbc75691e7141fb0|hash_0001038c1f52eeabdd8892a7a5e0cdfa70354e + + + + + Cloud: DigitalOcean Droplets - Memory + + + + + |host_description| - |query_resourceName| - Memory + + bytes + + 3 + + 200 + + 700 + + 1000 + + on + + on + + 2 + + + + + + + + 100 + + 0 + + + + + + + + + + + + + + + + 0 + + 0 + + 0 + + on + + + + + + 40 + + 0 + + 0 + + + + 4 + hash_0801036df5be35faa0d89df210629887cbd56e + 4668E4 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + do_mem_total + + 1.00 + + 0 + 1 + + + 9 + hash_0801036df5be35faa0d89df210629887cbd56e + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 2 + + + 9 + hash_0801036df5be35faa0d89df210629887cbd56e + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 3 + + + 9 + hash_0801036df5be35faa0d89df210629887cbd56e + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 4 + + + 4 + hash_08010320d1c13571a6bce92070f77bb2b67cd5 + 00CF00 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + do_mem_avail + + 1.00 + + 0 + 5 + + + 9 + hash_08010320d1c13571a6bce92070f77bb2b67cd5 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 6 + + + 9 + hash_08010320d1c13571a6bce92070f77bb2b67cd5 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 7 + + + 9 + hash_08010320d1c13571a6bce92070f77bb2b67cd5 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 8 + + + 4 + hash_0801037da676ae11671af4e15bacf2819ec7b8 + EA8F00 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + do_mem_free + + 1.00 + + 0 + 9 + + + 9 + hash_0801037da676ae11671af4e15bacf2819ec7b8 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 10 + + + 9 + hash_0801037da676ae11671af4e15bacf2819ec7b8 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 11 + + + 9 + hash_0801037da676ae11671af4e15bacf2819ec7b8 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 12 + + + 4 + hash_080103f57286dad5daa773dcc475fe191e5b34 + F51D30 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + do_mem_cached + + 1.00 + + 0 + 13 + + + 9 + hash_080103f57286dad5daa773dcc475fe191e5b34 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 14 + + + 9 + hash_080103f57286dad5daa773dcc475fe191e5b34 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 15 + + + 9 + hash_080103f57286dad5daa773dcc475fe191e5b34 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 16 + + + + + Data Source [do_mem_total] + + task_item_id + hash_00010331b67dc9a2c3a3f2e870c49d92d582a8|hash_00010396f5445081bf2e6ef007a8ff9d127812|hash_00010308eb797e80daaa60e8b111a5d0683626|hash_000103f2c8face43ed8eac63e3c17b4466c391 + + + Data Source [do_mem_avail] + + task_item_id + hash_0001033f5de24dced9f2594a21f9aa2002264b|hash_000103abe58cc99fbbb4d8f9045f160e69057d|hash_0001036538489493e28e32a9320c31e405b022|hash_000103302e2c36afaa03a19c301f16219db278 + + + Data Source [do_mem_free] + + task_item_id + hash_0001036010244a30d29e6ce891d487305e4f1a|hash_000103fcc9a47a8dfd69ecf97c9ef26c44131d|hash_000103b62f61e9f9d39de0d15dabdd611b3157|hash_0001036220e5ac28ee7bcc8387e0d5edc68eae + + + Data Source [do_mem_cached] + + task_item_id + hash_000103b940d1da5855f842987f256f9cfd4ebf|hash_0001030b58202b5a8c0ccc49781315e3fb206c|hash_000103a9c111d6c62b836bcd734380971d97cc|hash_000103395db9fc5f87581b9ca654379588b57f + + + + + Cloud: DigitalOcean Droplets - Collection Age + + + + + |host_description| - |query_resourceName| - Collection Age + + seconds + + 3 + + 200 + + 700 + + 1000 + + on + + on + + 2 + + + + + + + + 100 + + 0 + + + + + + + + + + + + + + + + 0 + + 0 + + 0 + + on + + + + + + 40 + + 0 + + 0 + + + + 4 + hash_0801031a276645bb64ecf3200afd99ab80de7e + 4668E4 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + do_age + + 1.00 + + 0 + 1 + + + 9 + hash_0801031a276645bb64ecf3200afd99ab80de7e + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 2 + + + 9 + hash_0801031a276645bb64ecf3200afd99ab80de7e + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 3 + + + 9 + hash_0801031a276645bb64ecf3200afd99ab80de7e + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 4 + + + + + Data Source [do_age] + + task_item_id + hash_000103a47f40650d6e7eebe66ba13408fad7c6|hash_0001034f14eb8929d9f379e3fa20a9a0da74e4|hash_000103f5f9f1c98ea892dd217eb9d407b9aac4|hash_00010375f56330d16931b28a335068e0a12726 + + + + + Cloud: DigitalOcean Load Balancers - Connections + + + + + |host_description| - |query_resourceName| - Connections + + connections + + 3 + + 200 + + 700 + + 1000 + + on + + on + + 2 + + + + + + + + 100 + + 0 + + + + + + + + + + + + + + + + 0 + + 0 + + 0 + + on + + + + + + 40 + + 0 + + 0 + + + + 4 + hash_08010356c4730492f7625f7fef993b58dd67a6 + 4668E4 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_conn_cur + + 1.00 + + 0 + 1 + + + 9 + hash_08010356c4730492f7625f7fef993b58dd67a6 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 2 + + + 9 + hash_08010356c4730492f7625f7fef993b58dd67a6 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 3 + + + 9 + hash_08010356c4730492f7625f7fef993b58dd67a6 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 4 + + + 4 + hash_080103cd4ed9243937fc1da5cf3b24db9e8c4f + 00CF00 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_conn_lim + + 1.00 + + 0 + 5 + + + 9 + hash_080103cd4ed9243937fc1da5cf3b24db9e8c4f + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 6 + + + 9 + hash_080103cd4ed9243937fc1da5cf3b24db9e8c4f + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 7 + + + 9 + hash_080103cd4ed9243937fc1da5cf3b24db9e8c4f + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 8 + + + + + Data Source [dolb_conn_cur] + + task_item_id + hash_0001030b894313e812e739acbca2392883f4b8|hash_00010316cf5f2f19706c1c23cb02e3f4aaab04|hash_0001031edaac3a9bab03ffca303b080f363929|hash_000103133410ddfd6e6eeff831cf51a8bf24ff + + + Data Source [dolb_conn_lim] + + task_item_id + hash_00010344dc9fb1d62542a63405446cb2e1d63e|hash_000103e687b8e254ddf17114815b97203fe403|hash_00010348c79f9c6f6075ce91c3b109ccd39406|hash_000103e05a36634b607b1155b102d52e0640ca + + + + + Cloud: DigitalOcean Load Balancers - CPU + + + + + |host_description| - |query_resourceName| - CPU + + percent + + 3 + + 200 + + 700 + + 1000 + + on + + + + 2 + + + + + + on + + 100 + + 0 + + + + + + + + + + + + + + + + 0 + + 0 + + 0 + + on + + + + + + 40 + + 0 + + 0 + + + + 4 + hash_080103b1297692bf7855828cc680acf8a0fe17 + 4668E4 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_cpu_pct + + 1.00 + + 0 + 1 + + + 9 + hash_080103b1297692bf7855828cc680acf8a0fe17 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 2 + + + 9 + hash_080103b1297692bf7855828cc680acf8a0fe17 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 3 + + + 9 + hash_080103b1297692bf7855828cc680acf8a0fe17 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 4 + + + + + Data Source [dolb_cpu_pct] + + task_item_id + hash_000103c4b7c3577e821e6136194ee53606e68a|hash_000103a34b31544a6cac88ad4742bcb01aa3fb|hash_00010302d565855b9c9edd40cad52288116fe7|hash_00010372ae471db17d910d98462d67cc33bab8 + + + + + Cloud: DigitalOcean Load Balancers - HTTP Requests + + + + + |host_description| - |query_resourceName| - HTTP Requests + + requests per second + + 3 + + 200 + + 700 + + 1000 + + on + + on + + 2 + + + + + + + + 100 + + 0 + + + + + + + + + + + + + + + + 0 + + 0 + + 0 + + on + + + + + + 40 + + 0 + + 0 + + + + 4 + hash_0801034c8470f6ff72c7f3aedb5be0c0382280 + 4668E4 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_http_rps + + 1.00 + + 0 + 1 + + + 9 + hash_0801034c8470f6ff72c7f3aedb5be0c0382280 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 2 + + + 9 + hash_0801034c8470f6ff72c7f3aedb5be0c0382280 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 3 + + + 9 + hash_0801034c8470f6ff72c7f3aedb5be0c0382280 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 4 + + + + + Data Source [dolb_http_rps] + + task_item_id + hash_000103389369f3e4b2cd8fb7317fc17a80e5e4|hash_00010313a78911e159e546460d7d99a4db108b|hash_0001038daea89de4fcd3eb88daa74a94a715fb|hash_0001037feae740e040af050a6cb4adeed9ca33 + + + + + Cloud: DigitalOcean Load Balancers - HTTP Responses + + + + + |host_description| - |query_resourceName| - HTTP Responses + + responses + + 3 + + 200 + + 700 + + 1000 + + on + + on + + 2 + + + + + + + + 100 + + 0 + + + + + + + + + + + + + + + + 0 + + 0 + + 0 + + on + + + + + + 40 + + 0 + + 0 + + + + 4 + hash_080103e0db6738c617410a308f0b61966e4e85 + 4668E4 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_http_resp + + 1.00 + + 0 + 1 + + + 9 + hash_080103e0db6738c617410a308f0b61966e4e85 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 2 + + + 9 + hash_080103e0db6738c617410a308f0b61966e4e85 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 3 + + + 9 + hash_080103e0db6738c617410a308f0b61966e4e85 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 4 + + + + + Data Source [dolb_http_resp] + + task_item_id + hash_000103b0ab162d78accdb1c5f335adc84a21ff|hash_00010347962903301ec892f183c12817fe822d|hash_0001031b89ef0210a44fd3b188ae1786b92601|hash_0001036b0ef11238fc77c4dfe528ef16030a5c + + + + + Cloud: DigitalOcean Load Balancers - Throughput + + + + + |host_description| - |query_resourceName| - Throughput + + bytes per second + + 3 + + 200 + + 700 + + 1000 + + on + + on + + 2 + + + + + + + + 100 + + 0 + + + + + + + + + + + + + + + + 0 + + 0 + + 0 + + on + + + + + + 40 + + 0 + + 0 + + + + 4 + hash_0801034b416d31b14a410b0d9fc267d6c673ea + 4668E4 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_http_Bps + + 1.00 + + 0 + 1 + + + 9 + hash_0801034b416d31b14a410b0d9fc267d6c673ea + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 2 + + + 9 + hash_0801034b416d31b14a410b0d9fc267d6c673ea + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 3 + + + 9 + hash_0801034b416d31b14a410b0d9fc267d6c673ea + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 4 + + + 4 + hash_08010373ab165625ccf2e9c839f2547dd03751 + 00CF00 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_tcp_Bps + + 1.00 + + 0 + 5 + + + 9 + hash_08010373ab165625ccf2e9c839f2547dd03751 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 6 + + + 9 + hash_08010373ab165625ccf2e9c839f2547dd03751 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 7 + + + 9 + hash_08010373ab165625ccf2e9c839f2547dd03751 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 8 + + + 4 + hash_0801032937d61b18729675c0df26e68b8f3250 + EA8F00 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_udp_Bps + + 1.00 + + 0 + 9 + + + 9 + hash_0801032937d61b18729675c0df26e68b8f3250 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 10 + + + 9 + hash_0801032937d61b18729675c0df26e68b8f3250 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 11 + + + 9 + hash_0801032937d61b18729675c0df26e68b8f3250 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 12 + + + 4 + hash_0801039966c69c86b3a7f60497a61e978d93fa + F51D30 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_nlbtcp_Bps + + 1.00 + + 0 + 13 + + + 9 + hash_0801039966c69c86b3a7f60497a61e978d93fa + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 14 + + + 9 + hash_0801039966c69c86b3a7f60497a61e978d93fa + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 15 + + + 9 + hash_0801039966c69c86b3a7f60497a61e978d93fa + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 16 + + + 4 + hash_080103f83f7ed56ef9cb28643ecdeb13cf410a + 8D00BA + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_nlbudp_Bps + + 1.00 + + 0 + 17 + + + 9 + hash_080103f83f7ed56ef9cb28643ecdeb13cf410a + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 18 + + + 9 + hash_080103f83f7ed56ef9cb28643ecdeb13cf410a + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 19 + + + 9 + hash_080103f83f7ed56ef9cb28643ecdeb13cf410a + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 20 + + + + + Data Source [dolb_http_Bps] + + task_item_id + hash_0001031d0206be6d7f681bcc719bfde619d83c|hash_00010307b20e5660baf8c85f10f312d15e6acd|hash_000103707093778a76afe65c009b057623bbb8|hash_0001038e5b3ebc0869b3b5415ec57196758678 + + + Data Source [dolb_tcp_Bps] + + task_item_id + hash_000103f08452429634d52cbc8e1bf8f819a8b2|hash_000103dfefe2acad2ef40d8e0d7f85681780d8|hash_000103a94dc26fc471aca71863384fe22e4c71|hash_000103d73571dbee4efc2b4c3df57376b86ee2 + + + Data Source [dolb_udp_Bps] + + task_item_id + hash_000103dfbc240f028856bb200412229aaa3ab0|hash_0001031cea7d310130cc05757459e3e99307e3|hash_00010340e635e7597982ac677b427605e22ac2|hash_000103af44824776a0cb71381f59840263bf42 + + + Data Source [dolb_nlbtcp_Bps] + + task_item_id + hash_000103adc6dcf10e0389a1f3ee05701503fed7|hash_0001038e89ee202231faa86a9b71edcecca77d|hash_00010342fc331044d666fd5c70d727baf018e3|hash_000103dd1279f34cd0e9bf09209831bd020f72 + + + Data Source [dolb_nlbudp_Bps] + + task_item_id + hash_0001033b557124d4caaf3b9a99f484482b6da9|hash_000103105c294efdfcd62b36065f6e2ea6c337|hash_000103a6aee71ce81743e0d840a3b64ecc22dc|hash_000103f02068e6751d92b0dbb379ebb6600c35 + + + + + Cloud: DigitalOcean Load Balancers - Health Checks + + + + + |host_description| - |query_resourceName| - Health Checks + + status + + 3 + + 200 + + 700 + + 1000 + + on + + on + + 2 + + + + + + + + 100 + + 0 + + + + + + + + + + + + + + + + 0 + + 0 + + 0 + + on + + + + + + 40 + + 0 + + 0 + + + + 4 + hash_0801039d3647952c70565cd8979e05bb534b32 + 4668E4 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_hc_status + + 1.00 + + 0 + 1 + + + 9 + hash_0801039d3647952c70565cd8979e05bb534b32 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 2 + + + 9 + hash_0801039d3647952c70565cd8979e05bb534b32 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 3 + + + 9 + hash_0801039d3647952c70565cd8979e05bb534b32 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 4 + + + + + Data Source [dolb_hc_status] + + task_item_id + hash_0001037aeb2320460df51c6a7ebf41e98e1910|hash_000103ddae12b000fa1f08339c7978c0260b7f|hash_0001036d668edbd19f97e9348600f78a9e0f79|hash_0001036e4650eb87eb6e323a292dcd079f9616 + + + + + Cloud: DigitalOcean Load Balancers - Downtime + + + + + |host_description| - |query_resourceName| - Downtime + + status + + 3 + + 200 + + 700 + + 1000 + + on + + on + + 2 + + + + + + + + 100 + + 0 + + + + + + + + + + + + + + + + 0 + + 0 + + 0 + + on + + + + + + 40 + + 0 + + 0 + + + + 4 + hash_080103f46a542535d4633d92b8ad6afc00ac6f + 4668E4 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_downtime + + 1.00 + + 0 + 1 + + + 9 + hash_080103f46a542535d4633d92b8ad6afc00ac6f + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 2 + + + 9 + hash_080103f46a542535d4633d92b8ad6afc00ac6f + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 3 + + + 9 + hash_080103f46a542535d4633d92b8ad6afc00ac6f + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 4 + + + + + Data Source [dolb_downtime] + + task_item_id + hash_00010353587a018b7b3e1cee560da63360a0b5|hash_000103ebc393caa830dd457ff6e2f19678db8b|hash_0001038cff89255552e8c2f7a3bb0502f746b1|hash_0001036a5d9c55b1d794a96023ad6dcab88ff4 + + + + + Cloud: DigitalOcean Load Balancers - Response Time + + + + + |host_description| - |query_resourceName| - Response Time + + seconds + + 3 + + 200 + + 700 + + 1000 + + on + + on + + 2 + + + + + + + + 100 + + 0 + + + + + + + + + + + + + + + + 0 + + 0 + + 0 + + on + + + + + + 40 + + 0 + + 0 + + + + 4 + hash_080103e11379b894f9694d84cd2deb70643af5 + 4668E4 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_resp_avg_s + + 1.00 + + 0 + 1 + + + 9 + hash_080103e11379b894f9694d84cd2deb70643af5 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 2 + + + 9 + hash_080103e11379b894f9694d84cd2deb70643af5 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 3 + + + 9 + hash_080103e11379b894f9694d84cd2deb70643af5 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 4 + + + 4 + hash_0801031fd6548138c2c4f26a2c1f3edb22fff6 + 00CF00 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_resp_p95_s + + 1.00 + + 0 + 5 + + + 9 + hash_0801031fd6548138c2c4f26a2c1f3edb22fff6 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 6 + + + 9 + hash_0801031fd6548138c2c4f26a2c1f3edb22fff6 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 7 + + + 9 + hash_0801031fd6548138c2c4f26a2c1f3edb22fff6 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 8 + + + + + Data Source [dolb_resp_avg_s] + + task_item_id + hash_0001035f6a3cc74b5126d4950dce9033680d2a|hash_0001035cd52efdee2f7db4547781544c21f99c|hash_000103c25748197edbdeb6c413ad588d390a72|hash_00010387cc504050f210d6f68e8ebe5026b829 + + + Data Source [dolb_resp_p95_s] + + task_item_id + hash_000103177a518e908f29668666708f14f5d960|hash_000103b0813ed7173476ed6a638e430d4fa862|hash_000103719ccd390903e7a81348bbfbb5f19205|hash_00010341cc1488efd558979cbc94c6c2a6362a + + + + + Cloud: DigitalOcean Load Balancers - Droplet Connections + + + + + |host_description| - |query_resourceName| - Droplet Connections + + connections + + 3 + + 200 + + 700 + + 1000 + + on + + on + + 2 + + + + + + + + 100 + + 0 + + + + + + + + + + + + + + + + 0 + + 0 + + 0 + + on + + + + + + 40 + + 0 + + 0 + + + + 4 + hash_080103544c1e62c9ec4d933b5c0b80d48adfd6 + 4668E4 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_back_conn + + 1.00 + + 0 + 1 + + + 9 + hash_080103544c1e62c9ec4d933b5c0b80d48adfd6 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 2 + + + 9 + hash_080103544c1e62c9ec4d933b5c0b80d48adfd6 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 3 + + + 9 + hash_080103544c1e62c9ec4d933b5c0b80d48adfd6 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 4 + + + 4 + hash_080103bd0a12aeba3deda34eaed14aa48cd3b3 + 00CF00 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_queue + + 1.00 + + 0 + 5 + + + 9 + hash_080103bd0a12aeba3deda34eaed14aa48cd3b3 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 6 + + + 9 + hash_080103bd0a12aeba3deda34eaed14aa48cd3b3 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 7 + + + 9 + hash_080103bd0a12aeba3deda34eaed14aa48cd3b3 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 8 + + + + + Data Source [dolb_back_conn] + + task_item_id + hash_00010368259178c89dac6fe8f123b06c0f32f4|hash_0001030b947f9b45098d7b03d8ef2713601c94|hash_000103829b2074daf28d86a26c98318f9874e8|hash_000103c598951a50e372962d15878dc4ab9a32 + + + Data Source [dolb_queue] + + task_item_id + hash_0001037c146d22614712fc9ceb3ce31da720d1|hash_0001032f1dd16484fb9072ee8f463c090763f5|hash_000103281562a812698ff1bc175a74c1d307f0|hash_000103f08f36c2b392d717be1079e54005f31c + + + + + Cloud: DigitalOcean Load Balancers - Collection Age + + + + + |host_description| - |query_resourceName| - Collection Age + + seconds + + 3 + + 200 + + 700 + + 1000 + + on + + on + + 2 + + + + + + + + 100 + + 0 + + + + + + + + + + + + + + + + 0 + + 0 + + 0 + + on + + + + + + 40 + + 0 + + 0 + + + + 4 + hash_080103408442758bfcd410cc839470f94da413 + 4668E4 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + dolb_age + + 1.00 + + 0 + 1 + + + 9 + hash_080103408442758bfcd410cc839470f94da413 + 0 + FF + 4 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Cur: + + 0.00 + + 0 + 2 + + + 9 + hash_080103408442758bfcd410cc839470f94da413 + 0 + FF + 1 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Avg: + + 0.00 + + 0 + 3 + + + 9 + hash_080103408442758bfcd410cc839470f94da413 + 0 + FF + 3 + 0 + 0 + + + hash_060103e9c43831e54eca8069317a2ce8c6f751 + + Max: + on + 0.00 + + 0 + 4 + + + + + Data Source [dolb_age] + + task_item_id + hash_000103e08fe167f296acbc1db7266241d53a34|hash_0001035f83603316374f4bd4434ccd31bae8d8|hash_000103d199d070900084ef69e0e7e7b328857e|hash_0001034d0d1fd0e0cd44cf6a5274b989bb9f68 + + + + + Cloud: DigitalOcean Droplets - CPU + + + |host_description| - CPU + + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + hash_200103d62c52891f4f9688729a5bc9fad91b18 + + 300 + + on + + + + + do_cpu_pct + + 0 + + 100 + + 1 + + 600 + + 0 + + + + + hash_070103172b4b0eacee4948c6479f587b62e512 + on + + + + hash_07010330fb5d5bcf3d66bb5abe88596f357c26 + on + + + + hash_07010331112c85ae4ff821d3b288336288818c + on + + + + + + Cloud: DigitalOcean Droplets - Bandwidth + + + |host_description| - Bandwidth + + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + hash_200103d62c52891f4f9688729a5bc9fad91b18 + + 300 + + on + + + + + do_bw_pub_in + + 0 + + U + + 1 + + 600 + + 0 + + + + do_bw_pub_out + + 0 + + U + + 1 + + 600 + + 0 + + + + do_bw_prv_in + + 0 + + U + + 1 + + 600 + + 0 + + + + do_bw_prv_out + + 0 + + U + + 1 + + 600 + + 0 + + + + + hash_070103172b4b0eacee4948c6479f587b62e512 + on + + + + hash_07010330fb5d5bcf3d66bb5abe88596f357c26 + on + + + + hash_07010331112c85ae4ff821d3b288336288818c + on + + + + + + Cloud: DigitalOcean Droplets - Load Average + + + |host_description| - Load Average + + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + hash_200103d62c52891f4f9688729a5bc9fad91b18 + + 300 + + on + + + + + do_load_1 + + 0 + + U + + 1 + + 600 + + 0 + + + + do_load_5 + + 0 + + U + + 1 + + 600 + + 0 + + + + do_load_15 + + 0 + + U + + 1 + + 600 + + 0 + + + + + hash_070103172b4b0eacee4948c6479f587b62e512 + on + + + + hash_07010330fb5d5bcf3d66bb5abe88596f357c26 + on + + + + hash_07010331112c85ae4ff821d3b288336288818c + on + + + + + + Cloud: DigitalOcean Droplets - Memory + + + |host_description| - Memory + + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + hash_200103d62c52891f4f9688729a5bc9fad91b18 + + 300 + + on + + + + + do_mem_total + + 0 + + U + + 1 + + 600 + + 0 + + + + do_mem_avail + + 0 + + U + + 1 + + 600 + + 0 + + + + do_mem_free + + 0 + + U + + 1 + + 600 + + 0 + + + + do_mem_cached + + 0 + + U + + 1 + + 600 + + 0 + + + + + hash_070103172b4b0eacee4948c6479f587b62e512 + on + + + + hash_07010330fb5d5bcf3d66bb5abe88596f357c26 + on + + + + hash_07010331112c85ae4ff821d3b288336288818c + on + + + + + + Cloud: DigitalOcean Droplets - Collection Age + + + |host_description| - Collection Age + + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + hash_200103d62c52891f4f9688729a5bc9fad91b18 + + 300 + + on + + + + + do_age + + 0 + + U + + 1 + + 600 + + 0 + + + + + hash_070103172b4b0eacee4948c6479f587b62e512 + on + + + + hash_07010330fb5d5bcf3d66bb5abe88596f357c26 + on + + + + hash_07010331112c85ae4ff821d3b288336288818c + on + + + + + + Cloud: DigitalOcean Load Balancers - Connections + + + |host_description| - Connections + + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + hash_200103d62c52891f4f9688729a5bc9fad91b18 + + 300 + + on + + + + + dolb_conn_cur + + 0 + + U + + 1 + + 600 + + 0 + + + + dolb_conn_lim + + 0 + + U + + 1 + + 600 + + 0 + + + + + hash_070103172b4b0eacee4948c6479f587b62e512 + on + + + + hash_07010330fb5d5bcf3d66bb5abe88596f357c26 + on + + + + hash_07010331112c85ae4ff821d3b288336288818c + on + + + + + + Cloud: DigitalOcean Load Balancers - CPU + + + |host_description| - CPU + + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + hash_200103d62c52891f4f9688729a5bc9fad91b18 + + 300 + + on + + + + + dolb_cpu_pct + + 0 + + 100 + + 1 + + 600 + + 0 + + + + + hash_070103172b4b0eacee4948c6479f587b62e512 + on + + + + hash_07010330fb5d5bcf3d66bb5abe88596f357c26 + on + + + + hash_07010331112c85ae4ff821d3b288336288818c + on + + + + + + Cloud: DigitalOcean Load Balancers - HTTP Requests + + + |host_description| - HTTP Requests + + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + hash_200103d62c52891f4f9688729a5bc9fad91b18 + + 300 + + on + + + + + dolb_http_rps + + 0 + + U + + 1 + + 600 + + 0 + + + + + hash_070103172b4b0eacee4948c6479f587b62e512 + on + + + + hash_07010330fb5d5bcf3d66bb5abe88596f357c26 + on + + + + hash_07010331112c85ae4ff821d3b288336288818c + on + + + + + + Cloud: DigitalOcean Load Balancers - HTTP Responses + + + |host_description| - HTTP Responses + + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + hash_200103d62c52891f4f9688729a5bc9fad91b18 + + 300 + + on + + + + + dolb_http_resp + + 0 + + U + + 1 + + 600 + + 0 + + + + + hash_070103172b4b0eacee4948c6479f587b62e512 + on + + + + hash_07010330fb5d5bcf3d66bb5abe88596f357c26 + on + + + + hash_07010331112c85ae4ff821d3b288336288818c + on + + + + + + Cloud: DigitalOcean Load Balancers - Throughput + + + |host_description| - Throughput + + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + hash_200103d62c52891f4f9688729a5bc9fad91b18 + + 300 + + on + + + + + dolb_http_Bps + + 0 + + U + + 1 + + 600 + + 0 + + + + dolb_tcp_Bps + + 0 + + U + + 1 + + 600 + + 0 + + + + dolb_udp_Bps + + 0 + + U + + 1 + + 600 + + 0 + + + + dolb_nlbtcp_Bps + + 0 + + U + + 1 + + 600 + + 0 + + + + dolb_nlbudp_Bps + + 0 + + U + + 1 + + 600 + + 0 + + + + + hash_070103172b4b0eacee4948c6479f587b62e512 + on + + + + hash_07010330fb5d5bcf3d66bb5abe88596f357c26 + on + + + + hash_07010331112c85ae4ff821d3b288336288818c + on + + + + + + Cloud: DigitalOcean Load Balancers - Health Checks + + + |host_description| - Health Checks + + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + hash_200103d62c52891f4f9688729a5bc9fad91b18 + + 300 + + on + + + + + dolb_hc_status + + 0 + + U + + 1 + + 600 + + 0 + + + + + hash_070103172b4b0eacee4948c6479f587b62e512 + on + + + + hash_07010330fb5d5bcf3d66bb5abe88596f357c26 + on + + + + hash_07010331112c85ae4ff821d3b288336288818c + on + + + + + + Cloud: DigitalOcean Load Balancers - Downtime + + + |host_description| - Downtime + + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + hash_200103d62c52891f4f9688729a5bc9fad91b18 + + 300 + + on + + + + + dolb_downtime + + 0 + + U + + 1 + + 600 + + 0 + + + + + hash_070103172b4b0eacee4948c6479f587b62e512 + on + + + + hash_07010330fb5d5bcf3d66bb5abe88596f357c26 + on + + + + hash_07010331112c85ae4ff821d3b288336288818c + on + + + + + + Cloud: DigitalOcean Load Balancers - Response Time + + + |host_description| - Response Time + + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + hash_200103d62c52891f4f9688729a5bc9fad91b18 + + 300 + + on + + + + + dolb_resp_avg_s + + 0 + + U + + 1 + + 600 + + 0 + + + + dolb_resp_p95_s + + 0 + + U + + 1 + + 600 + + 0 + + + + + hash_070103172b4b0eacee4948c6479f587b62e512 + on + + + + hash_07010330fb5d5bcf3d66bb5abe88596f357c26 + on + + + + hash_07010331112c85ae4ff821d3b288336288818c + on + + + + + + Cloud: DigitalOcean Load Balancers - Droplet Connections + + + |host_description| - Droplet Connections + + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + hash_200103d62c52891f4f9688729a5bc9fad91b18 + + 300 + + on + + + + + dolb_back_conn + + 0 + + U + + 1 + + 600 + + 0 + + + + dolb_queue + + 0 + + U + + 1 + + 600 + + 0 + + + + + hash_070103172b4b0eacee4948c6479f587b62e512 + on + + + + hash_07010330fb5d5bcf3d66bb5abe88596f357c26 + on + + + + hash_07010331112c85ae4ff821d3b288336288818c + on + + + + + + Cloud: DigitalOcean Load Balancers - Collection Age + + + |host_description| - Collection Age + + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + hash_200103d62c52891f4f9688729a5bc9fad91b18 + + 300 + + on + + + + + dolb_age + + 0 + + U + + 1 + + 600 + + 0 + + + + + hash_070103172b4b0eacee4948c6479f587b62e512 + on + + + + hash_07010330fb5d5bcf3d66bb5abe88596f357c26 + on + + + + hash_07010331112c85ae4ff821d3b288336288818c + on + + + + + + Normal + %8.2lf %s + + + Cloud: DigitalOcean Droplets + Cloud: DigitalOcean Droplets of the scope, read from the plugin cache. + <path_cacti>/resource/script_server/cloud_do_droplet.xml + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + + hash_000103306c148ee387a19ae392fe1f65674f03 + CPU + + + do_cpu_pct + hash_010103c91a85e3d15fe678dd76a9bf8ea22414 + hash_0801033c2c5c7bef9af3836c127a740622d809 + + + + + title + 1 + |host_description| - |query_resourceName| - CPU + + + + + name + hash_010103c91a85e3d15fe678dd76a9bf8ea22414 + 1 + |host_description| - |query_resourceName| - CPU + + + + + hash_0001032e6af03d878c26242f9cd77fd481f807 + Bandwidth + + + do_bw_pub_in + hash_010103bac7d8011b5bf6be49a5e978b447ef38 + hash_080103749c1c0bff50b3e5efd4de51d04adb69 + + + do_bw_pub_out + hash_010103bac7d8011b5bf6be49a5e978b447ef38 + hash_080103bfb1c26e1a42b5e82649936055a62461 + + + do_bw_prv_in + hash_010103bac7d8011b5bf6be49a5e978b447ef38 + hash_0801030a8ddbb80268836e955ac18809a9ab8b + + + do_bw_prv_out + hash_010103bac7d8011b5bf6be49a5e978b447ef38 + hash_080103330713ba80d37efbf00a3dc9c8ae40cf + + + + + title + 1 + |host_description| - |query_resourceName| - Bandwidth + + + + + name + hash_010103bac7d8011b5bf6be49a5e978b447ef38 + 1 + |host_description| - |query_resourceName| - Bandwidth + + + + + hash_000103d5a304d041270440ed530cffb79a7833 + Load Average + + + do_load_1 + hash_01010320fe3279ac49df7bb6c3f470ed42a808 + hash_0801037f5c3372f415b68c01bec323326a96a1 + + + do_load_5 + hash_01010320fe3279ac49df7bb6c3f470ed42a808 + hash_080103451b06faafa516ef55eef1a3cecff70b + + + do_load_15 + hash_01010320fe3279ac49df7bb6c3f470ed42a808 + hash_0801030182ca5e8103dbf8bedd2f2c3fdb51c3 + + + + + title + 1 + |host_description| - |query_resourceName| - Load Average + + + + + name + hash_01010320fe3279ac49df7bb6c3f470ed42a808 + 1 + |host_description| - |query_resourceName| - Load Average + + + + + hash_000103e3102d7839b70470e9511ca553b7b916 + Memory + + + do_mem_total + hash_010103d0056196c9513b70ca4e848a1adb0167 + hash_0801036df5be35faa0d89df210629887cbd56e + + + do_mem_avail + hash_010103d0056196c9513b70ca4e848a1adb0167 + hash_08010320d1c13571a6bce92070f77bb2b67cd5 + + + do_mem_free + hash_010103d0056196c9513b70ca4e848a1adb0167 + hash_0801037da676ae11671af4e15bacf2819ec7b8 + + + do_mem_cached + hash_010103d0056196c9513b70ca4e848a1adb0167 + hash_080103f57286dad5daa773dcc475fe191e5b34 + + + + + title + 1 + |host_description| - |query_resourceName| - Memory + + + + + name + hash_010103d0056196c9513b70ca4e848a1adb0167 + 1 + |host_description| - |query_resourceName| - Memory + + + + + hash_0001030cdd100a69ba4232cb3b297e58c1f6a1 + Collection Age + + + do_age + hash_0101035689a2530ca2704b91324459a055c002 + hash_0801031a276645bb64ecf3200afd99ab80de7e + + + + + title + 1 + |host_description| - |query_resourceName| - Collection Age + + + + + name + hash_0101035689a2530ca2704b91324459a055c002 + 1 + |host_description| - |query_resourceName| - Collection Age + + + + + + + Cloud: DigitalOcean Load Balancers + Cloud: DigitalOcean Load Balancers of the scope, read from the plugin cache. + <path_cacti>/resource/script_server/cloud_do_load_balancer.xml + hash_030103332111d8b54ac8ce939af87a7eac0c06 + + + hash_00010397d3c3deca863c0db08b29fc04e61f0e + Connections + + + dolb_conn_cur + hash_010103959594fc216f97420e18f8aad6df7b35 + hash_08010356c4730492f7625f7fef993b58dd67a6 + + + dolb_conn_lim + hash_010103959594fc216f97420e18f8aad6df7b35 + hash_080103cd4ed9243937fc1da5cf3b24db9e8c4f + + + + + title + 1 + |host_description| - |query_resourceName| - Connections + + + + + name + hash_010103959594fc216f97420e18f8aad6df7b35 + 1 + |host_description| - |query_resourceName| - Connections + + + + + hash_000103a5e59e0c8c793f9fb0c976dda08635e3 + CPU + + + dolb_cpu_pct + hash_01010302cb4e5b180f6c5684f7f7bcb449ca38 + hash_080103b1297692bf7855828cc680acf8a0fe17 + + + + + title + 1 + |host_description| - |query_resourceName| - CPU + + + + + name + hash_01010302cb4e5b180f6c5684f7f7bcb449ca38 + 1 + |host_description| - |query_resourceName| - CPU + + + + + hash_0001035a59ca8ac5baec59fe3437f6d15f5651 + HTTP Requests + + + dolb_http_rps + hash_0101034e42f56aab563216960faa997071d587 + hash_0801034c8470f6ff72c7f3aedb5be0c0382280 + + + + + title + 1 + |host_description| - |query_resourceName| - HTTP Requests + + + + + name + hash_0101034e42f56aab563216960faa997071d587 + 1 + |host_description| - |query_resourceName| - HTTP Requests + + + + + hash_0001034805350075badb0f941a4c123a5a3764 + HTTP Responses + + + dolb_http_resp + hash_0101037cada803cd7f42b6121ef99aded8ed7a + hash_080103e0db6738c617410a308f0b61966e4e85 + + + + + title + 1 + |host_description| - |query_resourceName| - HTTP Responses + + + + + name + hash_0101037cada803cd7f42b6121ef99aded8ed7a + 1 + |host_description| - |query_resourceName| - HTTP Responses + + + + + hash_0001032f7b7718c9938f7b148c91a747e48e38 + Throughput + + + dolb_http_Bps + hash_010103cdaaaf87a7a9d6962362d53427dd6459 + hash_0801034b416d31b14a410b0d9fc267d6c673ea + + + dolb_tcp_Bps + hash_010103cdaaaf87a7a9d6962362d53427dd6459 + hash_08010373ab165625ccf2e9c839f2547dd03751 + + + dolb_udp_Bps + hash_010103cdaaaf87a7a9d6962362d53427dd6459 + hash_0801032937d61b18729675c0df26e68b8f3250 + + + dolb_nlbtcp_Bps + hash_010103cdaaaf87a7a9d6962362d53427dd6459 + hash_0801039966c69c86b3a7f60497a61e978d93fa + + + dolb_nlbudp_Bps + hash_010103cdaaaf87a7a9d6962362d53427dd6459 + hash_080103f83f7ed56ef9cb28643ecdeb13cf410a + + + + + title + 1 + |host_description| - |query_resourceName| - Throughput + + + + + name + hash_010103cdaaaf87a7a9d6962362d53427dd6459 + 1 + |host_description| - |query_resourceName| - Throughput + + + + + hash_000103804329b0ffccafd02ae9f4eee64fd6f3 + Health Checks + + + dolb_hc_status + hash_0101034a1e87e7359d2ecd9e6a3ad46aabb4e8 + hash_0801039d3647952c70565cd8979e05bb534b32 + + + + + title + 1 + |host_description| - |query_resourceName| - Health Checks + + + + + name + hash_0101034a1e87e7359d2ecd9e6a3ad46aabb4e8 + 1 + |host_description| - |query_resourceName| - Health Checks + + + + + hash_000103ced15a134aadffbcbd0602986c74c93b + Downtime + + + dolb_downtime + hash_010103debef6ed19ede934046c5e500da3c8fa + hash_080103f46a542535d4633d92b8ad6afc00ac6f + + + + + title + 1 + |host_description| - |query_resourceName| - Downtime + + + + + name + hash_010103debef6ed19ede934046c5e500da3c8fa + 1 + |host_description| - |query_resourceName| - Downtime + + + + + hash_000103d74d4e6fe03b3a15453cd1409e3c5130 + Response Time + + + dolb_resp_avg_s + hash_010103b007d1c4647ead357cdd8dd2c8c94a94 + hash_080103e11379b894f9694d84cd2deb70643af5 + + + dolb_resp_p95_s + hash_010103b007d1c4647ead357cdd8dd2c8c94a94 + hash_0801031fd6548138c2c4f26a2c1f3edb22fff6 + + + + + title + 1 + |host_description| - |query_resourceName| - Response Time + + + + + name + hash_010103b007d1c4647ead357cdd8dd2c8c94a94 + 1 + |host_description| - |query_resourceName| - Response Time + + + + + hash_0001035e99a47ebc655f6f4256fe5611c965bb + Droplet Connections + + + dolb_back_conn + hash_010103190300176cadde43773ffe5ab3790cb9 + hash_080103544c1e62c9ec4d933b5c0b80d48adfd6 + + + dolb_queue + hash_010103190300176cadde43773ffe5ab3790cb9 + hash_080103bd0a12aeba3deda34eaed14aa48cd3b3 + + + + + title + 1 + |host_description| - |query_resourceName| - Droplet Connections + + + + + name + hash_010103190300176cadde43773ffe5ab3790cb9 + 1 + |host_description| - |query_resourceName| - Droplet Connections + + + + + hash_000103b5a858b0599afda7f5b64f7bdb12c71c + Collection Age + + + dolb_age + hash_010103324cea8009cee203f60b85b7e5055a9e + hash_080103408442758bfcd410cc839470f94da413 + + + + + title + 1 + |host_description| - |query_resourceName| - Collection Age + + + + + name + hash_010103324cea8009cee203f60b85b7e5055a9e + 1 + |host_description| - |query_resourceName| - Collection Age + + + + + + diff --git a/templates/resource/cloud_do_droplet.xml b/templates/resource/cloud_do_droplet.xml new file mode 100644 index 0000000..f5de7b9 --- /dev/null +++ b/templates/resource/cloud_do_droplet.xml @@ -0,0 +1,92 @@ + + Get Cloud: DigitalOcean Droplets + |path_cacti|/plugins/cloud/ss_cloud.php + ss_cloud + php + |host_id| droplet + index + query + get + num_indexes + ! + resourceId + alphabetic + |chosen_order_field| + + + Resource ID + input + resourceId + + + Resource Name + input + resourceName + + + CPU: do_cpu_pct + output + do_cpu_pct + + + Bandwidth: do_bw_pub_in + output + do_bw_pub_in + + + Bandwidth: do_bw_pub_out + output + do_bw_pub_out + + + Bandwidth: do_bw_prv_in + output + do_bw_prv_in + + + Bandwidth: do_bw_prv_out + output + do_bw_prv_out + + + Load Average: do_load_1 + output + do_load_1 + + + Load Average: do_load_5 + output + do_load_5 + + + Load Average: do_load_15 + output + do_load_15 + + + Memory: do_mem_total + output + do_mem_total + + + Memory: do_mem_avail + output + do_mem_avail + + + Memory: do_mem_free + output + do_mem_free + + + Memory: do_mem_cached + output + do_mem_cached + + + Collection Age: do_age + output + do_age + + + diff --git a/templates/resource/cloud_do_load_balancer.xml b/templates/resource/cloud_do_load_balancer.xml new file mode 100644 index 0000000..1faf5ec --- /dev/null +++ b/templates/resource/cloud_do_load_balancer.xml @@ -0,0 +1,112 @@ + + Get Cloud: DigitalOcean Load Balancers + |path_cacti|/plugins/cloud/ss_cloud.php + ss_cloud + php + |host_id| load_balancer + index + query + get + num_indexes + ! + resourceId + alphabetic + |chosen_order_field| + + + Resource ID + input + resourceId + + + Resource Name + input + resourceName + + + Connections: dolb_conn_cur + output + dolb_conn_cur + + + Connections: dolb_conn_lim + output + dolb_conn_lim + + + CPU: dolb_cpu_pct + output + dolb_cpu_pct + + + HTTP Requests: dolb_http_rps + output + dolb_http_rps + + + HTTP Responses: dolb_http_resp + output + dolb_http_resp + + + Throughput: dolb_http_Bps + output + dolb_http_Bps + + + Throughput: dolb_tcp_Bps + output + dolb_tcp_Bps + + + Throughput: dolb_udp_Bps + output + dolb_udp_Bps + + + Throughput: dolb_nlbtcp_Bps + output + dolb_nlbtcp_Bps + + + Throughput: dolb_nlbudp_Bps + output + dolb_nlbudp_Bps + + + Health Checks: dolb_hc_status + output + dolb_hc_status + + + Downtime: dolb_downtime + output + dolb_downtime + + + Response Time: dolb_resp_avg_s + output + dolb_resp_avg_s + + + Response Time: dolb_resp_p95_s + output + dolb_resp_p95_s + + + Droplet Connections: dolb_back_conn + output + dolb_back_conn + + + Droplet Connections: dolb_queue + output + dolb_queue + + + Collection Age: dolb_age + output + dolb_age + + + diff --git a/tests/Integration/TemplatesTest.php b/tests/Integration/TemplatesTest.php new file mode 100644 index 0000000..02e517d --- /dev/null +++ b/tests/Integration/TemplatesTest.php @@ -0,0 +1,85 @@ + + * 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. + */ + + +/* + * The shipped templates against a real Cacti (REQ-OBJ-002, #42). Template + * objects live in Cacti's tables, so they survive the lifecycle reset; each + * test states what it expects regardless of what an earlier one imported. + */ + +beforeEach(function () { + lifecycle('reset'); +}); + +afterAll(function () { + lifecycle('reset'); +}); + +it('imports every template on install and copies the data query definitions', function () { + $state = lifecycle('install'); + + expect($state['templates_sha'])->toBe(hash_file('sha256', dirname(__DIR__, 2) . '/templates/cloud_digitalocean.xml')) + ->and($state['resource_files'])->toBe(['cloud_do_droplet.xml', 'cloud_do_load_balancer.xml']) + ->and($state['template_names'])->toHaveCount(15) + ->and($state['template_names'])->toContain('Cloud: DigitalOcean Droplets - CPU') + ->and($state['template_names'])->toContain('Cloud: DigitalOcean Load Balancers - Collection Age'); +}); + +it('re-imports without adding a single template row', function () { + $first = lifecycle('install'); + + // The reset forgets the recorded checksum, so this install imports again. + lifecycle('reset'); + $second = lifecycle('install'); + + expect($second['templates_sha'])->toBe($first['templates_sha']) + ->and($second['template_rows'])->toBe($first['template_rows']); +}); + +it('skips the import when the package is unchanged and every object is present', function () { + $installed = lifecycle('install'); + $again = lifecycle('templates'); + + expect($again['result'])->toBeTrue() + ->and($again['template_rows'])->toBe($installed['template_rows']); +}); + +it('restores a shipped graph template an administrator deleted', function () { + $installed = lifecycle('install'); + + $deleted = lifecycle('delete_graph_template', 'do_cpu'); + expect($deleted['template_names'])->not->toContain('Cloud: DigitalOcean Droplets - CPU'); + + $restored = lifecycle('templates'); + expect($restored['result'])->toBeTrue() + ->and($restored['template_names'])->toContain('Cloud: DigitalOcean Droplets - CPU') + ->and($restored['template_rows'])->toBe($installed['template_rows']); +}); + +it('imports a changed package on the next upgrade check', function () { + lifecycle('install'); + lifecycle('set_setting', 'cloud_templates_sha256=stale'); + + $upgraded = lifecycle('upgrade'); + + expect($upgraded['result'])->toBeTrue() + ->and($upgraded['templates_sha']) + ->toBe(hash_file('sha256', dirname(__DIR__, 2) . '/templates/cloud_digitalocean.xml')); +}); diff --git a/tests/Unit/TemplateInstallTest.php b/tests/Unit/TemplateInstallTest.php new file mode 100644 index 0000000..041f103 --- /dev/null +++ b/tests/Unit/TemplateInstallTest.php @@ -0,0 +1,198 @@ + + * 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\TemplateRepository; +use Somethingwithproof\Cloud\Templates; + +/* + * Templates' decisions against the database stubs: when it imports, what it + * records, and that it never records a package it could not fully import. + * The import itself runs against a real Cacti in tests/Integration. + */ + +function cloud_tpl_test_dir(): string { + $dir = sys_get_temp_dir() . '/cloud-templates-' . bin2hex(random_bytes(6)); + mkdir($dir . '/source/resource', 0700, true); + mkdir($dir . '/resource', 0700); + file_put_contents($dir . '/source/' . Templates::PACKAGE, ''); + file_put_contents($dir . '/source/resource/cloud_do_droplet.xml', ''); + + return $dir; +} + +/** + * @return array{0: Templates, 1: \ArrayObject} + */ +function cloud_tpl_installer(string $dir, bool $imports = true, ?string $resource = null): array { + $calls = new \ArrayObject(); + + return [ + new Templates( + new TemplateRepository(false), + $dir . '/source', + $resource ?? $dir . '/resource', + function (string $xml, int $profile) use ($calls, $imports): bool { + $calls[] = [$xml, $profile]; + + return $imports; + } + ), + $calls, + ]; +} + +/** + * @return list every object hash, as the lookup returns them + */ +function cloud_tpl_all_present(): array { + $rows = []; + + foreach (TemplateRepository::objects() as $keys) { + foreach ($keys as $key) { + $rows[] = ['hash' => TemplateRepository::hash($key)]; + } + } + + return $rows; +} + +function cloud_tpl_recorded(): array { + return array_values(array_filter( + $GLOBALS['__cloud_db_exec'], + fn (array $s): bool => str_contains($s['sql'], 'REPLACE INTO settings') + )); +} + +beforeEach(function () { + $GLOBALS['__cloud_db_exec'] = []; + $GLOBALS['__cloud_log'] = []; + $GLOBALS['__cloud_db_rows'] = [ + 'GET_LOCK' => [['1']], + 'data_source_profiles' => [['1']], + ]; +}); + +it('imports a new package with the default profile and records its checksum', function () { + $dir = cloud_tpl_test_dir(); + [$templates, $calls] = cloud_tpl_installer($dir); + + $GLOBALS['__cloud_db_rows']['SELECT hash FROM'] = cloud_tpl_all_present(); + + expect($templates->install())->toBeTrue() + ->and($calls->getArrayCopy())->toBe([['', 1]]) + ->and(cloud_tpl_recorded()[0]['params'])->toBe(['cloud_templates_sha256', hash('sha256', '')]) + ->and(file_get_contents($dir . '/resource/cloud_do_droplet.xml'))->toBe('') + ->and(fileperms($dir . '/resource/cloud_do_droplet.xml') & 0777)->toBe(0644) + ->and(glob($dir . '/resource/.*.xml.*'))->toBe([]); +}); + +it('skips the import when the recorded checksum matches and every object is present', function () { + $dir = cloud_tpl_test_dir(); + [$templates, $calls] = cloud_tpl_installer($dir); + + $GLOBALS['__cloud_db_rows']['SELECT value FROM settings'] = [[hash('sha256', '')]]; + $GLOBALS['__cloud_db_rows']['SELECT hash FROM'] = cloud_tpl_all_present(); + + expect($templates->install())->toBeTrue() + ->and($templates->isCurrent())->toBeTrue() + ->and(count($calls))->toBe(0) + ->and(cloud_tpl_recorded())->toBe([]); +}); + +it('imports again when the checksum matches but an object was deleted', function () { + $dir = cloud_tpl_test_dir(); + [$templates, $calls] = cloud_tpl_installer($dir); + $present = cloud_tpl_all_present(); + array_shift($present); + + $GLOBALS['__cloud_db_rows']['SELECT value FROM settings'] = [[hash('sha256', '')]]; + $GLOBALS['__cloud_db_rows']['SELECT hash FROM'] = $present; + + // The stub answers every lookup the same way, so the object stays missing + // after the import too, and nothing is recorded. + expect($templates->install())->toBeFalse() + ->and(count($calls))->toBe(1) + ->and(cloud_tpl_recorded())->toBe([]); +}); + +it('records nothing when the importer reports an error', function () { + [$templates, $calls] = cloud_tpl_installer(cloud_tpl_test_dir(), false); + + $GLOBALS['__cloud_db_rows']['SELECT hash FROM'] = cloud_tpl_all_present(); + + expect($templates->install())->toBeFalse() + ->and(count($calls))->toBe(1) + ->and(cloud_tpl_recorded())->toBe([]); +}); + +it('does not import without a default data source profile', function () { + [$templates, $calls] = cloud_tpl_installer(cloud_tpl_test_dir()); + + $GLOBALS['__cloud_db_rows']['data_source_profiles'] = []; + + expect($templates->install())->toBeFalse() + ->and(count($calls))->toBe(0); +}); + +it('defers to a process holding the lock and leaves the files alone', function () { + $dir = cloud_tpl_test_dir(); + [$templates, $calls] = cloud_tpl_installer($dir); + + $GLOBALS['__cloud_db_rows']['GET_LOCK'] = [['0']]; + + expect($templates->install())->toBeFalse() + ->and(count($calls))->toBe(0) + ->and(file_exists($dir . '/resource/cloud_do_droplet.xml'))->toBeFalse() + ->and(array_column($GLOBALS['__cloud_log'], 'message')) + ->toContain('WARNING: Template import deferred: another process holds the template lock'); +}); + +it('releases the lock after an import, whatever its outcome', function () { + foreach ([true, false] as $imports) { + $GLOBALS['__cloud_db_exec'] = []; + [$templates] = cloud_tpl_installer(cloud_tpl_test_dir(), $imports); + + $templates->install(); + + expect(array_column($GLOBALS['__cloud_db_exec'], 'sql'))->toContain('DO RELEASE_LOCK(?)'); + } +}); + +it('refuses when the Cacti resource directory is missing', function () { + $dir = cloud_tpl_test_dir(); + [$templates, $calls] = cloud_tpl_installer($dir, true, $dir . '/no-such-dir'); + + expect($templates->install())->toBeFalse() + ->and(count($calls))->toBe(0); +}); + +it('replaces a link at the target instead of writing through it', function () { + $dir = cloud_tpl_test_dir(); + [$templates] = cloud_tpl_installer($dir); + file_put_contents($dir . '/elsewhere.xml', 'kept'); + symlink($dir . '/elsewhere.xml', $dir . '/resource/cloud_do_droplet.xml'); + + $GLOBALS['__cloud_db_rows']['SELECT hash FROM'] = cloud_tpl_all_present(); + $templates->install(); + + expect(is_link($dir . '/resource/cloud_do_droplet.xml'))->toBeFalse() + ->and(file_get_contents($dir . '/resource/cloud_do_droplet.xml'))->toBe('') + ->and(file_get_contents($dir . '/elsewhere.xml'))->toBe('kept'); +}); diff --git a/tests/Unit/TemplatesTest.php b/tests/Unit/TemplatesTest.php new file mode 100644 index 0000000..548777a --- /dev/null +++ b/tests/Unit/TemplatesTest.php @@ -0,0 +1,121 @@ + + * 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\DigitalOceanCatalog; +use Somethingwithproof\Cloud\TemplateRepository; + +require_once dirname(__DIR__) . '/bin/generate-templates.php'; + +/* + * The shipped template XML against the catalog it is generated from + * (REQ-OBJ-001, REQ-OBJ-003). Regenerate with: + * php tests/bin/generate-templates.php templates + */ + +it('ships exactly the templates the catalog generates', function () { + $root = dirname(__DIR__, 2) . '/templates/'; + + foreach (cloud_tpl_files() as $name => $contents) { + expect(file_get_contents($root . $name))->toBe($contents, $name . ' is out of date; regenerate it'); + } + + $shipped = array_map( + fn (string $path): string => substr($path, strlen($root)), + array_merge(glob($root . '*.xml') ?: [], glob($root . 'resource/*.xml') ?: []) + ); + sort($shipped); + $generated = array_keys(cloud_tpl_files()); + sort($generated); + + expect($shipped)->toBe($generated); +}); + +it('places every catalog metric and age in exactly one graph of its resource type', function () { + $placed = []; + + foreach (cloud_tpl_graphs() as $graph) { + $placed = array_merge($placed, $graph[4]); + } + + $expected = array_merge(DigitalOceanCatalog::names(), array_values(DigitalOceanCatalog::AGE)); + sort($placed); + sort($expected); + + expect($placed)->toBe($expected); +}); + +it('gives every object the package defines the hash the repository looks up', function () { + $xml = cloud_tpl_package(); + + foreach (TemplateRepository::objects() as $keys) { + foreach ($keys as $key) { + expect(str_contains($xml, '0103' . TemplateRepository::hash($key) . '>'))->toBeTrue($key); + } + } +}); + +it('generates well-formed XML with no object hash defined twice', function () { + foreach (cloud_tpl_files() as $name => $contents) { + expect(simplexml_load_string($contents))->not->toBeFalse($name); + } + + preg_match_all('/^\t+<(hash_\d{6}[0-9a-f]{32})>$/m', cloud_tpl_package(), $defined); + + expect(count($defined[1]))->toBe(count(array_unique($defined[1]))); +}); + +it('maps each data query output field to a data source its graphs use', function () { + foreach ([DigitalOceanCatalog::DROPLET, DigitalOceanCatalog::LOAD_BALANCER] as $type) { + $resource = simplexml_load_string(cloud_tpl_resource($type)); + $outputs = []; + + foreach ($resource->fields->children() as $name => $field) { + if ((string) $field->direction === 'output') { + $outputs[] = $name; + } + } + + $expected = []; + + foreach (DigitalOceanCatalog::GRAPHS as $graph) { + if ($graph[0] === $type) { + $expected = array_merge($expected, $graph[4]); + } + } + + expect($outputs)->toBe($expected) + ->and((string) $resource->arg_prepend)->toBe('|host_id| ' . $type); + } +}); + +it('collects only a graph\'s own metrics, through one data template per graph', function () { + $package = simplexml_load_string(cloud_tpl_package()); + + foreach (DigitalOceanCatalog::GRAPHS as $key => $graph) { + $template = $package->{cloud_tpl_own('data_template', 'data_template/' . $key)}; + $names = []; + + foreach ($template->items->children() as $item) { + $names[] = (string) $item->data_source_name; + } + + expect($names)->toBe($graph[4], $key); + } +}); diff --git a/tests/bin/generate-templates.php b/tests/bin/generate-templates.php new file mode 100644 index 0000000..bf3d8a0 --- /dev/null +++ b/tests/bin/generate-templates.php @@ -0,0 +1,526 @@ + + * 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. + */ + +/* + * Writes the shipped Cacti templates from the DigitalOcean metric catalog: + * + * php tests/bin/generate-templates.php + * + * /cloud_digitalocean.xml is the package: one device template per + * provider scope, a script server data query per resource type, and a data + * template and graph template per catalog graph (ADR 0010). Each + * /resource/*.xml is the data query definition, which the plugin + * copies into /resource/script_server at import. + * + * The layout follows Cacti's own export (lib/export.php), field for field, + * so the importer reads it as it reads any shipped package. Output is + * reproducible: every hash comes from TemplateRepository::hash() over a fixed key. + * The template unit test runs these functions and compares their output + * with the shipped files. + * + * Kept parseable by PHP 8.0, like the other scripts here. + */ + +require_once dirname(__DIR__, 2) . '/include/autoload.php'; + +use Somethingwithproof\Cloud\DigitalOceanCatalog; + +/* include/global_arrays.php in 1.2.31 and 1.2.x. */ +const CLOUD_TPL_VERSION = '0103'; + +const CLOUD_TPL_TYPES = array( + 'graph_template' => '00', + 'data_template' => '01', + 'host_template' => '02', + 'data_input_method' => '03', + 'data_query' => '04', + 'gprint_preset' => '06', + 'data_input_field' => '07', + 'data_template_item' => '08', + 'graph_template_input' => '09', + 'graph_template_item' => '10', + 'data_query_graph' => '11', + 'data_query_sv_graph' => '12', + 'data_query_sv_data_source' => '13', + 'data_source_profile' => '20', +); + +/* Stock objects from cacti.sql: "Get Script Server Data (Indexed)" with its + * index_type, index_value and output_type fields, "5 Minute Collection", + * and the "Normal" GPRINT preset. */ +const CLOUD_TPL_SCRIPT_SERVER_INDEXED = '332111d8b54ac8ce939af87a7eac0c06'; +const CLOUD_TPL_INDEX_FIELDS = array( + '172b4b0eacee4948c6479f587b62e512', + '30fb5d5bcf3d66bb5abe88596f357c26', + '31112c85ae4ff821d3b288336288818c', +); +const CLOUD_TPL_PROFILE_5MIN = 'd62c52891f4f9688729a5bc9fad91b18'; +const CLOUD_TPL_GPRINT_NORMAL = 'e9c43831e54eca8069317a2ce8c6f751'; + +/* data_source_types, graph_item_types and consolidation_functions. */ +const CLOUD_TPL_DS_GAUGE = '1'; +const CLOUD_TPL_ITEM_LINE1 = '4'; +const CLOUD_TPL_ITEM_GPRINT = '9'; +const CLOUD_TPL_CF_AVERAGE = '1'; +const CLOUD_TPL_CF_MAX = '3'; +const CLOUD_TPL_CF_LAST = '4'; + +/* Stock entries of the colors table, in the order a graph's lines use them. */ +const CLOUD_TPL_COLORS = array('4668E4', '00CF00', 'EA8F00', 'F51D30', '8D00BA'); + +/* Per resource type: data query name, resource file, and the script + * server's type argument. */ +const CLOUD_TPL_QUERIES = array( + DigitalOceanCatalog::DROPLET => array('Cloud: DigitalOcean Droplets', 'cloud_do_droplet.xml', 'Droplet'), + DigitalOceanCatalog::LOAD_BALANCER => array( + 'Cloud: DigitalOcean Load Balancers', + 'cloud_do_load_balancer.xml', + 'Load Balancer', + ), +); + +/** + * The XML element name or reference for one object, as get_hash_version() + * builds it. + */ +function cloud_tpl_ref(string $type, string $id): string { + return 'hash_' . CLOUD_TPL_TYPES[$type] . CLOUD_TPL_VERSION . $id; +} + +function cloud_tpl_own(string $type, string $key): string { + return cloud_tpl_ref($type, \Somethingwithproof\Cloud\TemplateRepository::hash($key)); +} + +/** + * Renders nested arrays as Cacti's exporter does: one element per line, + * tab indents, values escaped like xml_character_encode(). + * + * @param array $nodes + */ +function cloud_tpl_render(array $nodes, int $depth): string { + $text = ''; + $indent = str_repeat("\t", $depth); + + foreach ($nodes as $name => $value) { + if (is_array($value)) { + $text .= $indent . '<' . $name . ">\n" . cloud_tpl_render($value, $depth + 1) . $indent . '\n"; + } else { + $text .= $indent . '<' . $name . '>' . htmlspecialchars((string) $value, ENT_QUOTES | ENT_XML1, 'UTF-8') + . '\n"; + } + } + + return $text; +} + +/** + * The catalog graphs, after checking that every metric and age name is in + * exactly one graph of its own resource type. + * + * @return array}> + */ +function cloud_tpl_graphs(): array { + $graphs = DigitalOceanCatalog::GRAPHS; + $placed = array(); + + foreach ($graphs as $key => $graph) { + foreach ($graph[4] as $ds) { + $metric = DigitalOceanCatalog::metric($ds); + $type = $metric === null ? array_search($ds, DigitalOceanCatalog::AGE, true) : $metric['type']; + + if ($type !== $graph[0]) { + throw new RuntimeException($ds . ' in graph ' . $key . ' is not a ' . $graph[0] . ' metric'); + } + + if (isset($placed[$ds])) { + throw new RuntimeException($ds . ' is in more than one graph'); + } + + if (count($graph[4]) > count(CLOUD_TPL_COLORS)) { + throw new RuntimeException('graph ' . $key . ' has more lines than colors'); + } + + $placed[$ds] = true; + } + } + + $names = array_merge(DigitalOceanCatalog::names(), array_values(DigitalOceanCatalog::AGE)); + $found = array_keys($placed); + + sort($names); + sort($found); + + if ($names !== $found) { + throw new RuntimeException('every catalog metric and age must appear in a graph'); + } + + return $graphs; +} + +/** + * @param array{0: string, 1: string, 2: string, 3: int|null, 4: list} $graph + * @return array + */ +function cloud_tpl_data_template(string $key, array $graph): array { + $items = array(); + + foreach ($graph[4] as $ds) { + $items[cloud_tpl_own('data_template_item', 'data_template_item/' . $ds)] = array( + 't_data_source_name' => '', + 'data_source_name' => $ds, + 't_rrd_minimum' => '', + 'rrd_minimum' => '0', + 't_rrd_maximum' => '', + 'rrd_maximum' => $graph[3] === null ? 'U' : (string) $graph[3], + 't_data_source_type_id' => '', + 'data_source_type_id' => CLOUD_TPL_DS_GAUGE, + 't_rrd_heartbeat' => '', + 'rrd_heartbeat' => '600', + 't_data_input_field_id' => '', + 'data_input_field_id' => '0', + ); + } + + $data = array(); + + foreach (CLOUD_TPL_INDEX_FIELDS as $i => $field) { + $data[sprintf('item_%03d', $i)] = array( + 'data_input_field_id' => cloud_tpl_ref('data_input_field', $field), + 't_value' => 'on', + 'value' => '', + ); + } + + return array( + 'name' => CLOUD_TPL_QUERIES[$graph[0]][0] . ' - ' . $graph[1], + 'ds' => array( + 't_name' => '', + 'name' => '|host_description| - ' . $graph[1], + 'data_source_path' => '', + 'data_input_id' => cloud_tpl_ref('data_input_method', CLOUD_TPL_SCRIPT_SERVER_INDEXED), + 't_data_source_profile_id' => '', + 'data_source_profile_id' => cloud_tpl_ref('data_source_profile', CLOUD_TPL_PROFILE_5MIN), + 't_rrd_step' => '', + 'rrd_step' => '300', + 't_active' => '', + 'active' => 'on', + ), + 'items' => $items, + 'data' => $data, + ); +} + +/** + * @param array $overrides + * @return array + */ +function cloud_tpl_graph_fields(string $title, string $label, array $overrides): array { + $values = array_merge(array( + 'title' => $title, + 'vertical_label' => $label, + 'image_format_id' => '3', + 'height' => '200', + 'width' => '700', + 'base_value' => '1000', + 'slope_mode' => 'on', + 'auto_scale' => 'on', + 'auto_scale_opts' => '2', + 'auto_scale_log' => '', + 'scale_log_units' => '', + 'auto_scale_rigid' => '', + 'upper_limit' => '100', + 'lower_limit' => '0', + 'unit_value' => '', + 'unit_exponent_value' => '', + 'unit_length' => '', + 'no_gridfit' => '', + 'alt_y_grid' => '', + 'right_axis' => '', + 'right_axis_label' => '', + 'right_axis_format' => '0', + 'right_axis_formatter' => '0', + 'left_axis_formatter' => '0', + 'auto_padding' => 'on', + 'dynamic_labels' => '', + 'force_rules_legend' => '', + 'tab_width' => '40', + 'legend_position' => '0', + 'legend_direction' => '0', + ), $overrides); + + $fields = array(); + + foreach ($values as $name => $value) { + $fields['t_' . $name] = ''; + $fields[$name] = $value; + } + + return $fields; +} + +/** + * @param array{0: string, 1: string, 2: string, 3: string, 4: bool} $row + * graph item type, color, consolidation function, text, line break + * @return array + */ +function cloud_tpl_graph_item(string $task, array $row, int $sequence): array { + return array( + 'graph_type_id' => $row[0], + 'task_item_id' => $task, + 'color_id' => $row[1], + 'alpha' => 'FF', + 'consolidation_function_id' => $row[2], + 'cdef_id' => '0', + 'vdef_id' => '0', + 'shift' => '', + 'value' => '', + 'gprint_id' => cloud_tpl_ref('gprint_preset', CLOUD_TPL_GPRINT_NORMAL), + 'textalign' => '', + 'text_format' => $row[3], + 'hard_return' => $row[4] ? 'on' : '', + 'line_width' => $row[0] === CLOUD_TPL_ITEM_LINE1 ? '1.00' : '0.00', + 'dashes' => '', + 'dash_offset' => '0', + 'sequence' => (string) $sequence, + ); +} + +function cloud_tpl_title(array $graph): string { + return '|host_description| - |query_resourceName| - ' . $graph[1]; +} + +/** + * @param array{0: string, 1: string, 2: string, 3: int|null, 4: list} $graph + * @return array + */ +function cloud_tpl_graph_template(string $key, array $graph): array { + $items = array(); + $inputs = array(); + $sequence = 0; + + foreach ($graph[4] as $i => $ds) { + $task = cloud_tpl_own('data_template_item', 'data_template_item/' . $ds); + $rows = array( + array(CLOUD_TPL_ITEM_LINE1, CLOUD_TPL_COLORS[$i], CLOUD_TPL_CF_AVERAGE, $ds, false), + array(CLOUD_TPL_ITEM_GPRINT, '0', CLOUD_TPL_CF_LAST, 'Cur:', false), + array(CLOUD_TPL_ITEM_GPRINT, '0', CLOUD_TPL_CF_AVERAGE, 'Avg:', false), + array(CLOUD_TPL_ITEM_GPRINT, '0', CLOUD_TPL_CF_MAX, 'Max:', true), + ); + $used = array(); + + foreach ($rows as $row) { + $sequence++; + + $item = 'graph_template_item/' . $key . '/' . $sequence; + + $items[cloud_tpl_own('graph_template_item', $item)] = cloud_tpl_graph_item($task, $row, $sequence); + + /* The exporter writes input items with the graph template type + * code, and the importer reads only the 32-digit id, so an export of the + * imported template matches this file. */ + $used[] = cloud_tpl_own('graph_template', $item); + } + + $inputs[cloud_tpl_own('graph_template_input', 'graph_template_input/' . $key . '/' . $ds)] = array( + 'name' => 'Data Source [' . $ds . ']', + 'description' => '', + 'column_name' => 'task_item_id', + 'items' => implode('|', $used), + ); + } + + $overrides = $graph[3] === null + ? array('upper_limit' => '100') + : array('auto_scale' => '', 'auto_scale_rigid' => 'on', 'upper_limit' => (string) $graph[3]); + + return array( + 'name' => CLOUD_TPL_QUERIES[$graph[0]][0] . ' - ' . $graph[1], + 'multiple' => '', + 'test_source' => '', + 'graph' => cloud_tpl_graph_fields(cloud_tpl_title($graph), $graph[2], $overrides), + 'items' => $items, + 'inputs' => $inputs, + ); +} + +/** + * @param array}> $graphs + * @return array + */ +function cloud_tpl_data_query(string $type, array $graphs): array { + $out = array(); + + foreach ($graphs as $key => $graph) { + if ($graph[0] !== $type) { + continue; + } + + $template = cloud_tpl_own('data_template', 'data_template/' . $key); + $rrd = array(); + + foreach ($graph[4] as $i => $ds) { + $rrd[sprintf('item_%03d', $i)] = array( + 'snmp_field_name' => $ds, + 'data_template_id' => $template, + 'data_template_rrd_id' => cloud_tpl_own('data_template_item', 'data_template_item/' . $ds), + ); + } + + $out[cloud_tpl_own('data_query_graph', 'data_query_graph/' . $key)] = array( + 'graph_template_id' => cloud_tpl_own('graph_template', 'graph_template/' . $key), + 'name' => $graph[1], + 'rrd' => $rrd, + 'sv_graph' => array( + cloud_tpl_own('data_query_sv_graph', 'data_query_sv_graph/' . $key . '/title') => array( + 'field_name' => 'title', + 'sequence' => '1', + 'text' => cloud_tpl_title($graph), + ), + ), + 'sv_data_source' => array( + cloud_tpl_own('data_query_sv_data_source', 'data_query_sv_data_source/' . $key . '/name') => array( + 'field_name' => 'name', + 'data_template_id' => $template, + 'sequence' => '1', + 'text' => '|host_description| - |query_resourceName| - ' . $graph[1], + ), + ), + ); + } + + return array( + 'name' => CLOUD_TPL_QUERIES[$type][0], + 'description' => CLOUD_TPL_QUERIES[$type][0] . ' of the scope, read from the plugin cache.', + 'xml_path' => '/resource/script_server/' . CLOUD_TPL_QUERIES[$type][1], + 'data_input_id' => cloud_tpl_ref('data_input_method', CLOUD_TPL_SCRIPT_SERVER_INDEXED), + 'graphs' => $out, + ); +} + +function cloud_tpl_package(): string { + $graphs = cloud_tpl_graphs(); + $queries = array(); + + foreach (array_keys(CLOUD_TPL_QUERIES) as $type) { + $queries[] = cloud_tpl_own('data_query', 'data_query/' . $type); + } + + $objects = array( + cloud_tpl_own('host_template', 'host_template/digitalocean') => array( + 'name' => 'Cloud: DigitalOcean Scope', + 'class' => 'application', + 'graph_templates' => '', + 'data_queries' => implode('|', $queries), + ), + ); + + foreach ($graphs as $key => $graph) { + $objects[cloud_tpl_own('graph_template', 'graph_template/' . $key)] = cloud_tpl_graph_template($key, $graph); + } + + foreach ($graphs as $key => $graph) { + $objects[cloud_tpl_own('data_template', 'data_template/' . $key)] = cloud_tpl_data_template($key, $graph); + } + + /* Packages carry the GPRINT presets they use; an install may have + * deleted "Normal", and the importer would then store 0. */ + $objects[cloud_tpl_ref('gprint_preset', CLOUD_TPL_GPRINT_NORMAL)] = array( + 'name' => 'Normal', + 'gprint_text' => '%8.2lf %s', + ); + + foreach (array_keys(CLOUD_TPL_QUERIES) as $type) { + $objects[cloud_tpl_own('data_query', 'data_query/' . $type)] = cloud_tpl_data_query($type, $graphs); + } + + return cloud_tpl_render(array('cacti' => $objects), 0); +} + +/** + * The data query definition for one resource type, laid out like + * resource/script_server/host_cpu.xml. Field names equal their query_name, + * which is what the script server function receives. + */ +function cloud_tpl_resource(string $type): string { + $fields = array( + 'resourceId' => array('name' => 'Resource ID', 'direction' => 'input', 'query_name' => 'resourceId'), + 'resourceName' => array('name' => 'Resource Name', 'direction' => 'input', 'query_name' => 'resourceName'), + ); + + foreach (DigitalOceanCatalog::GRAPHS as $graph) { + if ($graph[0] !== $type) { + continue; + } + + foreach ($graph[4] as $ds) { + $fields[$ds] = array('name' => $graph[1] . ': ' . $ds, 'direction' => 'output', 'query_name' => $ds); + } + } + + return cloud_tpl_render(array('interface' => array( + 'name' => 'Get ' . CLOUD_TPL_QUERIES[$type][0], + 'script_path' => '|path_cacti|/plugins/cloud/ss_cloud.php', + 'script_function' => 'ss_cloud', + 'script_server' => 'php', + 'arg_prepend' => '|host_id| ' . $type, + 'arg_index' => 'index', + 'arg_query' => 'query', + 'arg_get' => 'get', + 'arg_num_indexes' => 'num_indexes', + 'output_delimiter' => '!', + 'index_order' => 'resourceId', + 'index_order_type' => 'alphabetic', + 'index_title_format' => '|chosen_order_field|', + 'fields' => $fields, + )), 0); +} + +/** + * @return array path relative to the templates directory => contents + */ +function cloud_tpl_files(): array { + $files = array('cloud_digitalocean.xml' => cloud_tpl_package()); + + foreach (CLOUD_TPL_QUERIES as $type => $query) { + $files['resource/' . $query[1]] = cloud_tpl_resource($type); + } + + return $files; +} + +if (PHP_SAPI === 'cli' && isset($argv[0]) && realpath($argv[0]) === __FILE__) { + if (!isset($argv[1]) || $argv[1] === '') { + fwrite(STDERR, "usage: php tests/bin/generate-templates.php \n"); + exit(2); + } + + foreach (cloud_tpl_files() as $name => $contents) { + $path = rtrim($argv[1], '/') . '/' . $name; + + if (!is_dir(dirname($path)) && !mkdir(dirname($path), 0755, true) && !is_dir(dirname($path))) { + fwrite(STDERR, 'cannot create ' . dirname($path) . "\n"); + exit(1); + } + + if (file_put_contents($path, $contents) !== strlen($contents)) { + fwrite(STDERR, 'cannot write ' . $path . "\n"); + exit(1); + } + } +} diff --git a/tests/bin/lifecycle.php b/tests/bin/lifecycle.php index 3dea67f..401343b 100644 --- a/tests/bin/lifecycle.php +++ b/tests/bin/lifecycle.php @@ -110,6 +110,56 @@ list($table, $column) = explode('.', preg_replace('/[^a-z_.]/', '', $argument), 2); db_execute('ALTER TABLE `' . $table . '` DROP COLUMN `' . $column . '`'); + break; + case 'templates': + // Run the template install on its own, as a second upgrade would. + include_once($config['base_path'] . '/plugins/cloud/setup.php'); + cloud_boot(); + $result = cloud_setup_templates(1); + + break; + case 'delete_graph_template': + // What an administrator deleting one shipped graph template leaves. + include_once($config['base_path'] . '/plugins/cloud/setup.php'); + cloud_boot(); + $id = (int) db_fetch_cell_prepared( + 'SELECT id FROM graph_templates WHERE hash = ?', + array(\Somethingwithproof\Cloud\TemplateRepository::hash('graph_template/' . $argument)) + ); + // The same rows graph_templates.php deletes for a template. + $graphs = array_column( + db_fetch_assoc_prepared('SELECT id FROM snmp_query_graph WHERE graph_template_id = ?', array($id)), + 'id' + ); + + foreach ($graphs as $graph) { + foreach (array('snmp_query_graph_rrd', 'snmp_query_graph_rrd_sv', 'snmp_query_graph_sv') as $table) { + db_execute_prepared('DELETE FROM ' . $table . ' WHERE snmp_query_graph_id = ?', array($graph)); + } + } + + db_execute_prepared( + 'DELETE FROM graph_template_input_defs WHERE graph_template_input_id IN ' . + '(SELECT id FROM graph_template_input WHERE graph_template_id = ?)', + array($id) + ); + + foreach (array('graph_templates', 'snmp_query_graph', 'graph_template_input', 'host_template_graph') as $table) { + db_execute_prepared( + 'DELETE FROM ' . $table . ' WHERE ' . ($table === 'graph_templates' ? 'id' : 'graph_template_id') . ' = ?', + array($id) + ); + } + + db_execute_prepared( + 'DELETE FROM graph_templates_graph WHERE graph_template_id = ? AND local_graph_id = 0', + array($id) + ); + db_execute_prepared( + 'DELETE FROM graph_templates_item WHERE graph_template_id = ? AND local_graph_id = 0', + array($id) + ); + break; case 'drop_table': db_execute('DROP TABLE IF EXISTS `' . preg_replace('/[^a-z_]/', '', $argument) . '`'); @@ -295,4 +345,26 @@ 'c' ), 'tables' => $tables, + // Rows of the tables a template import writes, to show a re-import adds none. + 'template_rows' => array( + 'host_template' => (int) db_fetch_cell('SELECT COUNT(*) FROM host_template'), + 'host_template_snmp' => (int) db_fetch_cell('SELECT COUNT(*) FROM host_template_snmp_query'), + 'snmp_query' => (int) db_fetch_cell('SELECT COUNT(*) FROM snmp_query'), + 'snmp_query_graph' => (int) db_fetch_cell('SELECT COUNT(*) FROM snmp_query_graph'), + 'snmp_query_graph_rrd' => (int) db_fetch_cell('SELECT COUNT(*) FROM snmp_query_graph_rrd'), + 'data_template' => (int) db_fetch_cell('SELECT COUNT(*) FROM data_template'), + 'data_template_rrd' => (int) db_fetch_cell('SELECT COUNT(*) FROM data_template_rrd WHERE local_data_id = 0'), + 'graph_templates' => (int) db_fetch_cell('SELECT COUNT(*) FROM graph_templates'), + 'graph_templates_item' => (int) db_fetch_cell('SELECT COUNT(*) FROM graph_templates_item WHERE local_graph_id = 0'), + 'graph_template_input' => (int) db_fetch_cell('SELECT COUNT(*) FROM graph_template_input'), + ), + 'template_names' => array_column( + db_fetch_assoc("SELECT name FROM graph_templates WHERE name LIKE 'Cloud: %' ORDER BY name"), + 'name' + ), + 'templates_sha' => db_fetch_cell("SELECT value FROM settings WHERE name = 'cloud_templates_sha256'"), + 'resource_files' => array_map( + 'basename', + glob($config['base_path'] . '/resource/script_server/cloud_*.xml') ?: array() + ), ), JSON_PRETTY_PRINT) . PHP_EOL;