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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ A degraded InfiniBand link still passes traffic. A 4X link that retrains at 1X l

The plugin closes these gaps by reading the fabric through its own diagnostic tools (and later through UFM), identifying nodes and ports by GUID, and publishing counters and link state as Cacti data sources. It reads only: it never resets counters or changes port state.

## First discovery

A new fabric has no nodes, and sweeps start from the script server only for a node that is mapped to a Cacti device. The first discovery is therefore a manual step. After saving an enabled fabric, run this once on the poller the fabric is assigned to, as the poller's account, with `/path/to/cacti` replaced by your Cacti directory (the absolute path also works from cron):

```
php /path/to/cacti/plugins/fabric/fabric_sweep.php --fabric=ID --force
```

The inventory then fills in. Map nodes to Cacti devices on the Fabric Admin page; later sweeps start from the data query. While no node of a fabric is mapped, nothing refreshes its inventory, so run the same command again, from cron if you like, to record new or missing nodes. The health page shows this command for an enabled fabric that has not been discovered or has no mapped node.

## Planned scope

| Phase | Scope | Milestones |
Expand Down
2 changes: 1 addition & 1 deletion docs/PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ Milestone 2 is implemented on a local branch. Where it differs from the requirem
- **Limited.** A link state `limited` is added for a link that enabled values explain. No diags tool supplies those values, so phase 1 never reports it.
- **Device deletion.** REQ-LIFE-003 does not apply yet: milestone 2 creates no Cacti devices. Deleting a fabric removes only plugin rows.
- **Recorded fixtures.** REQ-TEST-001 asks for captures from real tools. The fixtures are generated from rdma-core v66.0's print formats and marked as such; captures stay with #14.
- **Starting a sweep.** The script server call that starts a sweep arrives with the data query in milestone 3. Until then sweeps run from `fabric_sweep.php`.
- **Starting a sweep.** The script server call that starts a sweep arrives with the data query in milestone 3. It sweeps only the nodes mapped to the polled device, so the first discovery of a fabric, and any refresh while no node is mapped, still runs from `fabric_sweep.php` (ADR 0008 rejects a `poller_bottom` prefetch). README and the health page say so.
- **Unreadable iblinkinfo lines.** REQ-INV-004 keeps the inventory whole on a parse failure; no requirement asks the same of link states, and one node description should not hide every link in the fabric. A line that starts with a port GUID but reads in no way or in more than one, which a description imitating the tool's fields can cause, is skipped. The node keeps its last link states, the count is stored per fabric and shown on the health page with a warning, and the rest is applied. Any other unknown line, a repeated port, contradicting fields, or output without a final newline still fails the whole read.
- **Accepted identities.** REQ-INV-005 is kept: a changed identity or a GUID printed more than once is a conflict, the node is not swept, and only an operator clears it. When the operator accepts the seen identity, the plugin records what that discovery saw under the GUID: each identity printed and whether the GUID was printed more than once. A later discovery that sees exactly that again raises no new conflict, so an accepted duplicate stays accepted. A sighting with any other identity, or a duplicate with other blocks, raises a new conflict. A GUID printed once again with the accepted identity is an ordinary match.
- **One fabric per adapter port.** Two fabrics on one poller, adapter, and port would see the same nodes, and the second would import each again, unmapped. The form refuses it and a unique key backs the form. A backend without a local adapter (phase 2) needs its own key.
Expand Down
12 changes: 11 additions & 1 deletion docs/i18n/ar-SA/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Source: README.md; SHA256: 19164b87c715ee79192e7772b7cd0029dc6c5e3c07d8ddc7dc44ebabb34ece2b -->
<!-- Source: README.md; SHA256: ce5af61a1bc993ec2aae6d4f22c3885694632f2b1d5eb94e2ce88b8390e96f1e -->

<!-- translations:start -->
[English](../../../README.md) | [简体中文](../zh-CN/README.md) | [हिन्दी](../hi-IN/README.md) | [Español (España)](../es-ES/README.md) | [Español (Latinoamérica)](../es-419/README.md) | [العربية](README.md)
Expand Down Expand Up @@ -53,6 +53,16 @@

تسد الإضافة هذه الفجوات بقراءة شبكة الربط عبر أدوات تشخيصها (ولاحقًا عبر UFM)، وتحديد العقد والمنافذ بواسطة GUID، ونشر العدّادات وحالة الروابط كمصادر بيانات Cacti. إنها تقرأ فقط: لا تعيد ضبط العدّادات ولا تغيّر حالة المنافذ مطلقًا.

## الاكتشاف الأول

لا تحتوي شبكة الربط الجديدة على عقد، ولا يبدأ الفحص من خادم النصوص إلا من عقدة مرتبطة بجهاز Cacti، لذا فالاكتشاف الأول خطوة يدوية. بعد حفظ شبكة ربط مفعّلة، شغّل الأمر التالي مرة واحدة على المُستطلِع المسندة إليه، بحساب المُستطلِع، مع استبدال `/path/to/cacti` بمسار دليل Cacti لديك (يعمل المسار المطلق أيضًا من cron):

```
php /path/to/cacti/plugins/fabric/fabric_sweep.php --fabric=ID --force
```

بعد ذلك يمتلئ المخزون. اربط العقد بأجهزة Cacti في صفحة Fabric Admin؛ وتبدأ الفحوص اللاحقة من استعلام البيانات. ما دامت أي عقدة من شبكة الربط غير مرتبطة فلا يُحدَّث مخزونها، لذا شغّل الأمر نفسه مجددًا، ومن cron إن شئت، لتسجيل العقد الجديدة أو المفقودة. تعرض صفحة الصحة هذا الأمر لشبكة ربط مفعّلة لم تُكتشف أو لا تحتوي على عقدة مرتبطة.

<a id="planned-scope"></a>
## النطاق المخطط

Expand Down
12 changes: 11 additions & 1 deletion docs/i18n/es-419/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Source: README.md; SHA256: 19164b87c715ee79192e7772b7cd0029dc6c5e3c07d8ddc7dc44ebabb34ece2b -->
<!-- Source: README.md; SHA256: ce5af61a1bc993ec2aae6d4f22c3885694632f2b1d5eb94e2ce88b8390e96f1e -->

<!-- translations:start -->
[English](../../../README.md) | [简体中文](../zh-CN/README.md) | [हिन्दी](../hi-IN/README.md) | [Español (España)](../es-ES/README.md) | [Español (Latinoamérica)](README.md) | [العربية](../ar-SA/README.md)
Expand Down Expand Up @@ -53,6 +53,16 @@ Un enlace InfiniBand degradado sigue transportando tráfico. Un enlace 4X que re

El complemento cubre esas carencias leyendo la red mediante sus herramientas de diagnóstico (y posteriormente mediante UFM), identificando nodos y puertos por GUID y publicando contadores y estados de enlaces como fuentes de datos Cacti. Solo lee: nunca reinicia contadores ni cambia el estado de los puertos.

## Primer descubrimiento

Un fabric nuevo no tiene nodos, y las consultas que inicia el servidor de scripts parten solo de un nodo asignado a un dispositivo de Cacti. Por eso el primer descubrimiento es un paso manual. Después de guardar un fabric habilitado, ejecute esto una vez en el sondeador al que está asignado, con la cuenta del sondeador y sustituyendo `/path/to/cacti` por su directorio de Cacti (la ruta absoluta también funciona desde cron):

```
php /path/to/cacti/plugins/fabric/fabric_sweep.php --fabric=ID --force
```

Después se llena el inventario. Asigne los nodos a dispositivos de Cacti en la página Fabric Admin; las consultas posteriores parten de la consulta de datos. Mientras ningún nodo de un fabric esté asignado, nada actualiza su inventario; ejecute de nuevo el mismo comando, desde cron si lo desea, para registrar nodos nuevos o ausentes. La página de estado muestra este comando para un fabric habilitado que no se ha descubierto o que no tiene ningún nodo asignado.

<a id="planned-scope"></a>
## Alcance previsto

Expand Down
12 changes: 11 additions & 1 deletion docs/i18n/es-ES/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Source: README.md; SHA256: 19164b87c715ee79192e7772b7cd0029dc6c5e3c07d8ddc7dc44ebabb34ece2b -->
<!-- Source: README.md; SHA256: ce5af61a1bc993ec2aae6d4f22c3885694632f2b1d5eb94e2ce88b8390e96f1e -->

<!-- translations:start -->
[English](../../../README.md) | [简体中文](../zh-CN/README.md) | [हिन्दी](../hi-IN/README.md) | [Español (España)](README.md) | [Español (Latinoamérica)](../es-419/README.md) | [العربية](../ar-SA/README.md)
Expand Down Expand Up @@ -53,6 +53,16 @@ Un enlace InfiniBand degradado sigue transportando tráfico. Un enlace 4X que re

El complemento cubre esas carencias leyendo la red mediante sus herramientas de diagnóstico (y posteriormente mediante UFM), identificando nodos y puertos por GUID y publicando contadores y estados de enlaces como fuentes de datos Cacti. Solo lee: nunca reinicia contadores ni cambia el estado de los puertos.

## Primer descubrimiento

Un fabric nuevo no tiene nodos, y las consultas que inicia el servidor de scripts parten solo de un nodo asignado a un dispositivo de Cacti. Por eso el primer descubrimiento es un paso manual. Después de guardar un fabric habilitado, ejecute esto una vez en el sondeador al que está asignado, con la cuenta del sondeador y sustituyendo `/path/to/cacti` por su directorio de Cacti (la ruta absoluta también funciona desde cron):

```
php /path/to/cacti/plugins/fabric/fabric_sweep.php --fabric=ID --force
```

Después se llena el inventario. Asigne los nodos a dispositivos de Cacti en la página Fabric Admin; las consultas posteriores parten de la consulta de datos. Mientras ningún nodo de un fabric esté asignado, nada actualiza su inventario; ejecute de nuevo el mismo comando, desde cron si lo desea, para registrar nodos nuevos o ausentes. La página de estado muestra este comando para un fabric habilitado que no se ha descubierto o que no tiene ningún nodo asignado.

<a id="planned-scope"></a>
## Alcance previsto

Expand Down
12 changes: 11 additions & 1 deletion docs/i18n/hi-IN/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Source: README.md; SHA256: 19164b87c715ee79192e7772b7cd0029dc6c5e3c07d8ddc7dc44ebabb34ece2b -->
<!-- Source: README.md; SHA256: ce5af61a1bc993ec2aae6d4f22c3885694632f2b1d5eb94e2ce88b8390e96f1e -->

<!-- translations:start -->
[English](../../../README.md) | [简体中文](../zh-CN/README.md) | [हिन्दी](README.md) | [Español (España)](../es-ES/README.md) | [Español (Latinoamérica)](../es-419/README.md) | [العربية](../ar-SA/README.md)
Expand Down Expand Up @@ -53,6 +53,16 @@ Cacti डिवाइस अनुमतियाँ अब भी हर उप

प्लगइन फ़ैब्रिक के अपने निदान उपकरणों (और बाद में UFM) से पढ़कर, नोड और पोर्ट को GUID से पहचानकर और काउंटर तथा लिंक स्थिति को Cacti डेटा स्रोत बनाकर ये कमियाँ भरता है। यह केवल पढ़ता है: कभी काउंटर रीसेट या पोर्ट स्थिति नहीं बदलता।

## पहली खोज

नए फ़ैब्रिक में कोई नोड नहीं होता, और स्क्रिप्ट सर्वर से शुरू होने वाला सर्वेक्षण केवल Cacti डिवाइस से जुड़े नोड से शुरू होता है। इसलिए पहली खोज मैन्युअल चरण है। सक्षम फ़ैब्रिक सहेजने के बाद, जिस पोलर को वह दिया गया है उस पर पोलर के खाते से यह एक बार चलाएँ, जहाँ `/path/to/cacti` की जगह अपनी Cacti निर्देशिका लिखें (पूर्ण पथ cron में भी काम करता है):

```
php /path/to/cacti/plugins/fabric/fabric_sweep.php --fabric=ID --force
```

इसके बाद सूची भर जाती है। Fabric Admin पृष्ठ पर नोड को Cacti डिवाइस से जोड़ें; बाद के सर्वेक्षण डेटा क्वेरी से शुरू होते हैं। जब तक फ़ैब्रिक का कोई नोड जुड़ा नहीं है, उसकी सूची ताज़ा नहीं होती, इसलिए नए या गायब नोड दर्ज करने के लिए यही कमांड फिर चलाएँ, चाहें तो cron से। जिस सक्षम फ़ैब्रिक की खोज नहीं हुई या जिसका कोई नोड जुड़ा नहीं है, उसके लिए स्वास्थ्य पृष्ठ यही कमांड दिखाता है।

<a id="planned-scope"></a>
## नियोजित दायरा

Expand Down
12 changes: 11 additions & 1 deletion docs/i18n/zh-CN/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Source: README.md; SHA256: 19164b87c715ee79192e7772b7cd0029dc6c5e3c07d8ddc7dc44ebabb34ece2b -->
<!-- Source: README.md; SHA256: ce5af61a1bc993ec2aae6d4f22c3885694632f2b1d5eb94e2ce88b8390e96f1e -->

<!-- translations:start -->
[English](../../../README.md) | [简体中文](README.md) | [हिन्दी](../hi-IN/README.md) | [Español (España)](../es-ES/README.md) | [Español (Latinoamérica)](../es-419/README.md) | [العربية](../ar-SA/README.md)
Expand Down Expand Up @@ -53,6 +53,16 @@ Cacti 设备权限仍限制每位用户可访问的行和操作;未映射对

插件通过网络自身的诊断工具(以后也通过 UFM)读取互连网络,按 GUID 标识节点和端口,并将计数器和链路状态发布为 Cacti 数据源,补足这些缺口。它只读取:绝不重置计数器或改变端口状态。

## 首次发现

新的互连网络没有节点,而脚本服务器发起的扫描只会从已分配给 Cacti 设备的节点开始,因此首次发现需要手动完成。保存已启用的互连网络后,请在其所分配的采集器上,以采集器账户运行一次(请将 `/path/to/cacti` 替换为您的 Cacti 目录;绝对路径同样适用于 cron):

```
php /path/to/cacti/plugins/fabric/fabric_sweep.php --fabric=ID --force
```

之后清单会被填充。在 Fabric Admin 页面将节点分配给 Cacti 设备;后续扫描由数据查询发起。互连网络中没有任何节点被分配时,其清单不会刷新,请再次运行同一命令(可通过 cron)以记录新增或缺失的节点。对于尚未发现或没有已分配节点的已启用互连网络,健康页面会显示此命令。

<a id="planned-scope"></a>
## 计划范围

Expand Down
3 changes: 2 additions & 1 deletion fabric_health.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
return fabric_device_allowed($host) || $fabric_hosts->gone($host);
}),
$fabric_templates,
$fabric_import
$fabric_import,
(string) $config['base_path']
);

top_header();
Expand Down
29 changes: 28 additions & 1 deletion lib/HealthPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
private readonly DeviceAccess $access,
private readonly ?TemplateInstaller $templates = null,
private readonly bool $canImport = false,
private readonly string $basePath = '/path/to/cacti',
) {
}

Expand Down Expand Up @@ -91,6 +92,16 @@
return;
}

// Whether a fabric has a mapped node must not depend on which devices
// this user may see, so count before the permission filter.
$mapped = [];

foreach ($nodes as $node) {
if ($node->hostId > 0) {
$mapped[$node->fabricId] = true;
}
}

$nodes = $this->access->visible($nodes);
$proposals = array_values(array_filter($proposals, fn (array $r): bool => $this->access->host(Row::int($r, 'old_host_id')) && $this->access->host(Row::int($r, 'new_host_id'))));
$now = $this->clock->now();
Expand All @@ -107,8 +118,12 @@

$warnings = [];

// The command is shown with an absolute path so it also works from cron.
$base = rtrim($this->basePath, '/');

foreach ($fabrics as $fabric) {
$row = $this->health->find($fabric->id) ?? [];
$found = $this->health->find($fabric->id);
$row = $found ?? [];

$fabricNodes = array_filter($nodes, static fn (Node $n): bool => $n->fabricId === $fabric->id);
$outcomes = [];
Expand All @@ -132,6 +147,18 @@
$warnings[] = __('Fabric %s: it is assigned to poller %d, but only the main poller can sweep a fabric until remote poller support is added. It is not swept; assign it to the main poller.', $fabric->name, $fabric->pollerId, 'fabric');
}

// Sweeps start from a mapped node (ADR 0008), so a fabric with no
// discovery or no mapped node waits for the command line.
if ($found === null) {
$warnings[] = __('Fabric %s: its health record could not be read, so its discovery state is unknown. See the Cacti log.', $fabric->name, 'fabric');

Check warning on line 153 in lib/HealthPage.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 151 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_fabric&issues=AaH3pk7J26GABcqzOkMI&open=AaH3pk7J26GABcqzOkMI&pullRequest=80
} elseif ($fabric->enabled() && $fabric->onMainPoller()) {
if (Row::int($row, 'discovery_attempt') === 0) {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
$warnings[] = __('Fabric %s: it has not been discovered. Sweeps start only from a node mapped to a Cacti device, so run "php %s/plugins/fabric/fabric_sweep.php --fabric=%d --force" on the main poller once.', $fabric->name, $base, $fabric->id, 'fabric');

Check warning on line 156 in lib/HealthPage.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 258 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_fabric&issues=AaH3pk7J26GABcqzOkMJ&open=AaH3pk7J26GABcqzOkMJ&pullRequest=80
} elseif (!isset($mapped[$fabric->id])) {
$warnings[] = __('Fabric %s: no node is mapped to a Cacti device, so no sweep starts and the inventory is not refreshed. Map a node on the Fabric Admin page, or run "php %s/plugins/fabric/fabric_sweep.php --fabric=%d --force" on the main poller.', $fabric->name, $base, $fabric->id, 'fabric');

Check warning on line 158 in lib/HealthPage.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 298 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_fabric&issues=AaH3pk7J26GABcqzOkMK&open=AaH3pk7J26GABcqzOkMK&pullRequest=80
}
}

if (Row::int($row, 'links_skipped') > 0 && Row::string($row, 'links_error') === '') {
$warnings[] = __('Fabric %s: %d iblinkinfo lines could not be read, most likely because a node description imitates the tool output. Those nodes keep their last link states.', $fabric->name, Row::int($row, 'links_skipped'), 'fabric');
}
Expand Down
Binary file modified locales/LC_MESSAGES/ar-SA.mo
Binary file not shown.
Binary file modified locales/LC_MESSAGES/es-419.mo
Binary file not shown.
Binary file modified locales/LC_MESSAGES/es-ES.mo
Binary file not shown.
Binary file modified locales/LC_MESSAGES/hi-IN.mo
Binary file not shown.
Binary file modified locales/LC_MESSAGES/zh-CN.mo
Binary file not shown.
15 changes: 15 additions & 0 deletions locales/po/ar-SA.po
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,21 @@ msgstr "شبكة الربط %s: المخزون %s؛ كان آخر اكتشاف
msgid "Fabric %s: it is assigned to poller %d, but only the main poller can sweep a fabric until remote poller support is added. It is not swept; assign it to the main poller."
msgstr "شبكة الربط %s: أُسندت إلى المُستطلِع %d، لكن لا يمكن فحصها إلا بالمُستطلِع الرئيسي حتى تُضاف إمكانية المُستطلِعات البعيدة. لا تُفحص حاليًا؛ أسندها إلى المُستطلِع الرئيسي."

#: lib/HealthPage.php
#, php-format
msgid "Fabric %s: its health record could not be read, so its discovery state is unknown. See the Cacti log."
msgstr "شبكة الربط %s: تعذّرت قراءة سجل حالتها الصحية، لذا حالة اكتشافها غير معروفة. راجع سجل Cacti."

#: lib/HealthPage.php
#, php-format
msgid "Fabric %s: it has not been discovered. Sweeps start only from a node mapped to a Cacti device, so run \"php %s/plugins/fabric/fabric_sweep.php --fabric=%d --force\" on the main poller once."
msgstr "شبكة الربط %s: لم يُكتشف بعد. لا يبدأ الفحص إلا من عقدة مرتبطة بجهاز Cacti، لذا شغّل \"php %s/plugins/fabric/fabric_sweep.php --fabric=%d --force\" مرة واحدة على المُستطلِع الرئيسي."

#: lib/HealthPage.php
#, php-format
msgid "Fabric %s: no node is mapped to a Cacti device, so no sweep starts and the inventory is not refreshed. Map a node on the Fabric Admin page, or run \"php %s/plugins/fabric/fabric_sweep.php --fabric=%d --force\" on the main poller."
msgstr "شبكة الربط %s: لا توجد عقدة مرتبطة بجهاز Cacti، لذلك لا يبدأ أي فحص ولا يُحدَّث المخزون. اربط عقدة في صفحة Fabric Admin، أو شغّل \"php %s/plugins/fabric/fabric_sweep.php --fabric=%d --force\" على المُستطلِع الرئيسي."

#: lib/HealthPage.php
#, php-format
msgid "Fabric %s: %d iblinkinfo lines could not be read, most likely because a node description imitates the tool output. Those nodes keep their last link states."
Expand Down
Loading