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
16 changes: 15 additions & 1 deletion .github/workflows/plugin-ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,21 @@ jobs:
mv log/main.log log/cacti.log
echo "== end-to-end log"
cat log/e2e.log
if grep -E "FATAL:|ERROR:|WARNING:" log/e2e.log | grep -v "GPU WARNING: Node [0-9]*: collection failed"; then
# Cacti shares this log with core and other plugins. Gate only on
# diagnostics emitted by this plugin; the assertions and command
# status above cover the end-to-end test itself.
awk '
/GPU (FATAL|ERROR|WARNING):/ && $0 !~ /GPU WARNING: Node [0-9]+: collection failed/ {
print
found = 1
}
END { if (found) exit 10 }
' log/e2e.log
scan_rc=$?
if [ "$scan_rc" -eq 10 ]; then
rc=1
elif [ "$scan_rc" -ne 0 ]; then
echo "Unable to scan the end-to-end log (awk exit $scan_rc)" >&2
rc=1
fi
if [ "$rc" -ne 0 ]; then
Expand Down
6 changes: 3 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ Phase 1 (NVIDIA through SNMP extend), first version 0.1.0. Not yet run on GPU ha
- GPU Nodes (GPU Admin), GPU Inventory and GPU Health (GPU View), each limited to devices the user may see.
- GPU identity records keyed by vendor and UUID, with replacement detection, confirmed moves between nodes, absence after a configurable number of collections, and JSON export.
- Collection of `nvidia-smi` through two fixed SNMP `extend` lines on each node ([docs/node-setup.md](docs/node-setup.md)), with strict parsing that turns any bad output into unknown values.
- The *GPU - Devices* data query, the *GPU - Metrics* data template, and ten graphs per GPU: Utilization, Memory, Temperature, Power, Clocks, Throttle, ECC Errors, New ECC Errors, Retired Pages, and Sample Age.
- The *GPU - Devices* data query, the *GPU - Metrics* data template, and eleven graphs per GPU: Utilization, Memory, Temperature, Power, Power Percent, Clocks, Throttle, ECC Errors, New ECC Errors, Retired Pages, and Sample Age.
- Decoded clock event reasons as alertable 0 or 1 indicators, with the raw mask kept and shown on GPU Health.
- The clock event reasons are read as `clocks_event_reasons.active`, falling back to `clocks_throttle_reasons.active` through an optional third extend entry, `cacti_gpu_legacy`, when nvidia-smi refuses the new name (#36).
- At most 128 GPUs per node are supported, which keeps the metrics output well under snmpd's 100 KiB limit.
- New corrected and uncorrected ECC errors since the previous sample, computed by the plugin as gauges; retired single-bit and double-bit page counts; the ECC mode, shown on GPU Health when ECC values are unknown.
- Thold threshold templates for temperature, power against its limit, the hardware and thermal throttle indicators, new uncorrected ECC errors, pending page retirement, and sample age ([docs/alerting.md](docs/alerting.md)).
- Thold threshold templates for temperature, power percentage against its limit, the hardware and thermal throttle indicators, new uncorrected ECC errors, pending page retirement, and sample age ([docs/alerting.md](docs/alerting.md)).
- The GPU Health page: freshness, last collection outcome, Maint state, backend, tool and driver versions, GPU presence, ECC state, and the raw clock event mask. It never contacts a node.
- An RRD file found at a new GPU data source's path is renamed instead of reused, so a database restored older than the RRD directory attaches no history to another GPU ([docs/backup.md](docs/backup.md)).
- *Remove the plugin's Cacti objects on uninstall* (default off): uninstall then removes the plugin's templates that nothing outside it uses, and its data query XML if unchanged. It never deletes RRD files, devices, graphs, or data sources.
Expand All @@ -28,7 +28,7 @@ Phase 1 (NVIDIA through SNMP extend), first version 0.1.0. Not yet run on GPU ha
- Schema version 3 adds the observation columns `ecc_corr_new`, `ecc_uncorr_new`, `retired_sbe`, `retired_dbe`, and `ecc_mode`. The upgrade runs when the Plugins page or a GPU page is opened.
- The metrics `extend` line now also asks for `ecc.mode.current`, `retired_pages.sbe`, and `retired_pages.dbe`. Update it on every node from [docs/node-setup.md](docs/node-setup.md); until then the node's collection fails with *Output rejected*.
- Only on a node whose `nvidia-smi` is older than the clock event reasons rename, add the optional `cacti_gpu_legacy` extend line from the same page. A metrics line with the current field list that asks for `clocks_throttle_reasons.active` in the last position also works, because both names print the same bitmask there; a line with the earlier field list does not.
- Re-import `templates/gpu_thold_templates.xml` in Thold to pick up template changes.
- Re-import `templates/gpu_thold_templates.xml` in Thold to pick up template changes. Existing power threshold rows keep their stored settings after a template re-import; edit each existing power threshold or recreate it from the template to monitor the derived `power_pct` value.

### Not yet supported

Expand Down
2 changes: 1 addition & 1 deletion docs/PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ Rules, tested by fixtures (REQ-ID-001 to 006):
| Data source and graphs | Graph templates per GPU | Created by Cacti's data query path from the templates |
| Data source for staleness | A field of the same data query (`age`) | Always numeric |

As built in milestone 3: the data query is *GPU - Devices*, one data template (*GPU - Metrics*) holds every model field, and eight graph templates (Utilization, Memory, Temperature, Power, Clocks, Throttle, ECC Errors, Sample Age) are created for each present GPU. Every model field is drawn by one of them, because `rrdtool_function_create()` puts into the RRD file only the data source items some graph item uses; an undrawn field such as a throttle indicator or `age` would never be stored, so Thold could not use it. The plugin copies the data query XML to `<path_cacti>/resource/script_server/plugin_gpu.xml`, so that directory must be writable by the installing user. Absent GPUs stay in the listing rather than using `index_transient`; an operator's **Remove from Data Query** on an absent GPU takes it out, and it returns if reported again. The index delimiter is `!`, which a `vendor/UUID` key cannot contain, and the data query sets `arg_num_indexes`. Uninstall removes the templates and the XML only when *Remove the plugin's Cacti objects on uninstall* is checked (default off), each template only where nothing outside the plugin uses it and the XML only if unchanged; it never deletes RRD files, devices, graphs, or data sources (#30). Milestone 4 adds *New ECC Errors* and *Retired Pages*, ten graphs in all.
As built in milestone 3: the data query is *GPU - Devices*, one data template (*GPU - Metrics*) holds every model field, and graph templates cover Utilization, Memory, Temperature, Power, Power Percent, Clocks, Throttle, ECC Errors, New ECC Errors, Retired Pages, and Sample Age. Every model field is drawn by one of them, because `rrdtool_function_create()` puts into the RRD file only the data source items some graph item uses; an undrawn field such as a throttle indicator or `age` would never be stored, so Thold could not use it. The plugin copies the data query XML to `<path_cacti>/resource/script_server/plugin_gpu.xml`, so that directory must be writable by the installing user. Absent GPUs stay in the listing rather than using `index_transient`; an operator's **Remove from Data Query** on an absent GPU takes it out, and it returns if reported again. The index delimiter is `!`, which a `vendor/UUID` key cannot contain, and the data query sets `arg_num_indexes`. Uninstall removes the templates and the XML only when *Remove the plugin's Cacti objects on uninstall* is checked (default off), each template only where nothing outside the plugin uses it and the XML only if unchanged; it never deletes RRD files, devices, graphs, or data sources (#30). Milestone 4 adds *New ECC Errors* and *Retired Pages*.

Templates ship as Cacti template XML and are imported with `import_xml_data()`, matched by hash so re-imports update rather than duplicate, under a lock so two upgrades cannot import together. The data query uses reindex method None; the plugin runs a forced reindex after each inventory change so titles refresh. `api_device_update_host_template()` (called from `api_device_save()` when a template is applied) runs `REPLACE INTO host_snmp_query` with the global default reindex method for data queries that have no cache rows yet, so the plugin sets None again afterward; `api_device_save()` itself only forces method 0 for devices with SNMP version 0. Confirmed by source at `release/1.2.31` and `1.2.x`; running it is *live* ([research/cacti-core.md](research/cacti-core.md)). A data query XML may instead set `index_transient`, which stops removed indexes being marked orphan; M3 chooses between that and keeping absent GPUs in the listing.

Expand Down
6 changes: 3 additions & 3 deletions docs/alerting.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ Tested against Thold v1.8.2 (`1eb406bd0f81f3204358cce7bd43c8bb5adc8e4a`) and Mai
4. Turn on Thold's *Auto Create Thresholds* setting, so Thold creates the thresholds as the plugin creates each GPU's graphs. This is the path the end-to-end test takes.
5. Devices that already had the GPU Node template before step 3 are not linked yet: add the templates under *Associated Threshold Templates* on each device's page, then select the devices under **Management > Devices** and run the **Apply Thresholds** action.

Thold creates one threshold per template for each GPU's data source. Notification lists, emails, and repeat settings are Thold's; set them on the templates or the thresholds.
Thold creates one threshold per template for each GPU's data source. Notification lists, emails, and repeat settings are Thold's; set them on the templates or thresholds.

## Shipped templates

| Template | Item | Breaches when | After |
|---|---|---|---|
| GPU - Temperature High | `temp_gpu` | above 85 °C | 2 polls |
| GPU - Power Above Limit | `power` | above 100 percent of `power_limit` | 2 polls |
| GPU - Power Above Limit | `power_pct` | above 100 percent of the current power limit | 2 polls |
| GPU - Software Thermal Slowdown | `thr_sw_thermal` | 1 | 1 poll |
| GPU - Hardware Thermal Slowdown | `thr_hw_thermal` | 1 | 1 poll |
| GPU - Hardware Power Brake | `thr_hw_power_brake` | 1 | 1 poll |
Expand All @@ -46,7 +46,7 @@ The template list is generated from `lib/TholdTemplateXml.php`, and a unit test

## What the end-to-end test proves

`tests/bin/alert-flow.php` imports the shipped templates with Thold's own import, links them to the GPU Node template, and lets Thold create the thresholds when the plugin creates the graphs. It then changes the fake `nvidia-smi` output behind a real `snmpd`, collects over SNMPv3, runs Cacti's poller and Thold's check, and reads Thold's log:
`tests/bin/alert-flow.php` imports the shipped templates with Thold's own import, links them to the GPU Node template, and lets Thold create the thresholds when the plugin creates the graphs. The `power_pct` data source is computed from the current sample's `power` and `power_limit` values without integer rounding. Missing readings and nonpositive limits produce an unknown value, which does not breach. The test then changes the fake `nvidia-smi` output behind a real `snmpd`, collects over SNMPv3, runs Cacti's poller and Thold's check, and reads Thold's log:

- a hot, hardware-throttled GPU with new uncorrected errors and a pending page retirement fires each threshold, the temperature only on its second poll, and each restores when the value returns;
- a driver reload drops the ECC total to 0: the new-error value reads `U`, nothing breaches, and Thold stays enabled; two new errors after the reset fire the threshold again, and it restores;
Expand Down
1 change: 1 addition & 0 deletions docs/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Milestone 3 implements the nvidia-smi column. The DCGM and AMD columns record th
| `temp_gpu` | GPU temperature | degrees C | gauge | U to U | `temperature.gpu` | 150 | `metric --temperature` `edge` (#18) |
| `power` | Board power draw | watts | gauge | 0 to U | `power.draw` | 155 | `metric --power` `socket_power` |
| `power_limit` | Board power limit | watts | gauge | 0 to U | `power.limit` | 160 | #18 |
| `power_pct` | Board power as a percentage of its limit | percent | gauge | 0 to U | computed from current `power` and `power_limit` samples | computed from `power` and `power_limit` in the current sample | computed from `power` and `power_limit` in the current sample |
| `clock_sm` | SM clock | MHz | gauge | 0 to U | `clocks.sm` | 1603 (hertz, divided by 1,000,000), or 100 (unit not stated) | `metric --clock` (#18) |
| `clock_mem` | Memory clock | MHz | gauge | 0 to U | `clocks.mem` | 1604 (hertz, divided by 1,000,000), or 101 (unit not stated) | `metric --clock` (#18) |
| `ecc_corr` | Corrected ECC errors since driver load | count | gauge | 0 to U | `ecc.errors.corrected.volatile.total` | 310 | `metric --ecc` `total_correctable_count` |
Expand Down
7 changes: 7 additions & 0 deletions lib/Freshness.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,13 @@ public static function value(string $field, array $row, int $now, int $staleAfte
return null;
}

if ($field === 'power_pct') {
$power = Row::float($row, 'power');
$limit = Row::float($row, 'power_limit');

return $power === null || $limit === null || $limit <= 0.0 ? null : $power / $limit * 100.0;
}

return in_array($field, Schema::observationMetrics(), true) ? Row::float($row, $field) : null;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/MetricModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
new Metric('temp_gpu', 'GPU temperature', 'degrees C', $gauge, null, null, 'temperature.gpu', 1.0, null, '150', 1.0, '`metric --temperature` `edge` (#18)'),
new Metric('power', 'Board power draw', 'watts', $gauge, 0.0, null, 'power.draw', 1.0, null, '155', 1.0, '`metric --power` `socket_power`'),
new Metric('power_limit', 'Board power limit', 'watts', $gauge, 0.0, null, 'power.limit', 1.0, null, '160', 1.0, '#18'),
new Metric('power_pct', 'Board power as a percentage of its limit', 'percent', $gauge, 0.0, null, null, 1.0, null, 'computed from `power` and `power_limit` in the current sample', 1.0, 'computed from `power` and `power_limit` in the current sample'),

Check warning on line 81 in lib/MetricModel.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

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

See more on https://sonarcloud.io/project/issues?id=somethingwithproof_plugin_gpu&issues=AaHonn-zcWhJbf0ON9YU&open=AaHonn-zcWhJbf0ON9YU&pullRequest=76
new Metric('clock_sm', 'SM clock', 'MHz', $gauge, 0.0, null, 'clocks.sm', 1.0, null, '1603 (hertz, divided by 1,000,000), or 100 (unit not stated)', 1.0e-6, '`metric --clock` (#18)'),
new Metric('clock_mem', 'Memory clock', 'MHz', $gauge, 0.0, null, 'clocks.mem', 1.0, null, '1604 (hertz, divided by 1,000,000), or 101 (unit not stated)', 1.0e-6, '`metric --clock` (#18)'),
new Metric('ecc_corr', 'Corrected ECC errors since driver load', 'count', $gauge, 0.0, null, 'ecc.errors.corrected.volatile.total', 1.0, null, '310', 1.0, '`metric --ecc` `total_correctable_count`'),
Expand Down Expand Up @@ -162,6 +163,7 @@
$metric->nvidiaField !== null => sprintf('`%s`', $metric->nvidiaField),
$metric->maskBit !== null => sprintf('`%s`, bit 0x%X', self::MASK_FIELD, $metric->maskBit),
isset(self::DELTAS[$metric->name]) => sprintf('computed from consecutive `%s` samples', self::DELTAS[$metric->name]),
$metric->name === 'power_pct' => 'computed from current `power` and `power_limit` samples',
default => 'computed from `timestamp`',
};

Expand Down
3 changes: 3 additions & 0 deletions lib/TemplateXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ public static function graphs(): array {
['power', self::AREA, 'F2B705', 'Draw'],
['power_limit', self::LINE1, 'B00020', 'Limit'],
]],
'GPU - Power Percent' => ['label' => 'percent of limit', 'base' => 1000, 'upper' => '0', 'items' => [
['power_pct', self::LINE2, 'F2B705', 'Draw'],
]],
'GPU - Clocks' => ['label' => 'MHz', 'base' => 1000, 'upper' => '0', 'items' => [
['clock_sm', self::LINE2, '76B900', 'SM'],
['clock_mem', self::LINE1, '7A3E9D', 'Memory'],
Expand Down
20 changes: 6 additions & 14 deletions lib/TholdTemplateXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,12 @@
final class TholdTemplateXml {
public const FILE = 'gpu_thold_templates.xml';

// Thold's thold_type 0 is High / Low; data_type 0 is the exact value
// and 3 is an RPN expression. The percentage helper maps an unknown
// power limit to zero, so power uses an explicit unknown-preserving RPN.
// Thold's data_type 0 compares the stored gauge value directly.
private const HIGH_LOW = 0;
private const EXACT = 0;
private const EXPRESSION = 3;

public const POWER_EXPRESSION = 'POWER,UN,POWER_LIMIT,UN,OR,POWER_LIMIT,UN,1,POWER_LIMIT,IF,0,LE,OR,UNKN,'
. 'POWER,UN,0,POWER,IF,POWER_LIMIT,UN,1,POWER_LIMIT,IF,0,LE,1,'
. 'POWER_LIMIT,UN,1,POWER_LIMIT,IF,IF,/,100,*,IF';

/**
* name => [data source item, high threshold, fail trigger in polls,
* percentage of this item, or ''].
* name => [data source item, high threshold, fail trigger in polls, ''].
*
* A fail trigger counts Cacti polls; the collector reads each node once
* per poller cycle, so one poll is one collection interval
Expand All @@ -66,7 +58,7 @@ final class TholdTemplateXml {
public static function templates(): array {
return [
'GPU - Temperature High' => ['temp_gpu', '85', 2, ''],
'GPU - Power Above Limit' => ['power', '100', 2, 'power_limit'],
'GPU - Power Above Limit' => ['power_pct', '100', 2, ''],
'GPU - Software Thermal Slowdown' => ['thr_sw_thermal', '0.5', 1, ''],
'GPU - Hardware Thermal Slowdown' => ['thr_hw_thermal', '0.5', 1, ''],
'GPU - Hardware Power Brake' => ['thr_hw_power_brake', '0.5', 1, ''],
Expand All @@ -93,7 +85,7 @@ public static function xml(): string {
$out = "<templates>\n";
$sequence = 1;

foreach (self::templates() as $name => [$item, $high, $trigger, $percentOf]) {
foreach (self::templates() as $name => [$item, $high, $trigger]) {
$metric = MetricModel::find($item);

if ($metric === null) {
Expand All @@ -113,9 +105,9 @@ public static function xml(): string {
'thold_hi' => $high,
'thold_low' => '',
'thold_fail_trigger' => (string) $trigger,
'data_type' => (string) ($percentOf === '' ? self::EXACT : self::EXPRESSION),
'data_type' => (string) self::EXACT,
'percent_ds' => '',
'expression' => $percentOf === '' ? '' : self::POWER_EXPRESSION,
'expression' => '',
'repeat_alert' => '0',
'restored_alert' => '',
];
Expand Down
5 changes: 5 additions & 0 deletions resource/script_server/plugin_gpu.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@
<direction>output</direction>
<query_name>power_limit</query_name>
</power_limit>
<power_pct>
<name>Board power as a percentage of its limit</name>
<direction>output</direction>
<query_name>power_pct</query_name>
</power_pct>
<clock_sm>
<name>SM clock</name>
<direction>output</direction>
Expand Down
Loading
Loading