Skip to content

Commit 3fd7de9

Browse files
author
Thomas Rzen
committed
Numeric ZFS pool health, fragmentation trigger, APT triggers
zfs.health was a text item, so it could not be graphed or shown on a dashboard and the trigger had to compare strings. It is now UNSIGNED with a value map: 0 ONLINE, 1 DEGRADED, 2 FAULTED, 3 OFFLINE, 4 REMOVED, 5 UNAVAIL, 6 SUSPENDED. The mapping uses a chain of STR_REPLACE preprocessing steps, not a script. The seven state names share no substring, so step order does not matter. A state outside the list leaves text in place and the item turns visibly unsupported instead of reporting a wrong number. Three triggers were missing: - ZFS pool fragmentation above {$ZFS.FRAG.WARN}. The macro was documented with a default of 60 but no trigger used it, so it did nothing. - APT repository configuration has warnings, Info severity. This is the common case of the enterprise repository being enabled without a subscription. A host on the no-subscription repository reports one warning permanently, hence {$PVE.APT.REPO.WARN.MAX} to raise the tolerance there. - Package updates pending, Info severity and disabled by default, matching the item it depends on. The replication failure trigger now carries the error message PVE reported in its event name, so the reason is visible without opening the item. Verified: no threshold macro is left without a trigger using it.
1 parent 496b0ed commit 3fd7de9

2 files changed

Lines changed: 87 additions & 6 deletions

File tree

Virtualization/template_proxmox-ve-rest-api-zabbix/7.0/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ PVEAPIToken=zabbix@pam!Zabbix=<token-secret>
108108
| `{$PVE.REPL.FAIL.MAX}` | `0` | Tolerated consecutive failures of a replication job. Context form `{$PVE.REPL.FAIL.MAX:"105-0"}`. |
109109
| `{$PVE.NOTBACKEDUP.MAX}` | `0` | Tolerated number of guests without a backup job. Raise it if some guests are deliberately excluded. |
110110
| `{$PVE.APT.REPO.ERRORS.MAX}` | `0` | Tolerated number of unparsable APT repository files. |
111+
| `{$PVE.APT.REPO.WARN.MAX}` | `0` | Tolerated number of APT repository warnings. A host on the no-subscription repository permanently reports one warning, set this to 1 there. |
112+
| `{$PVE.APT.UPDATES.MAX}` | `0` | Tolerated number of pending package updates. Only relevant if the disabled apt/update items are switched on. |
111113

112114
### Timing Macros
113115

@@ -183,6 +185,8 @@ Set to `0` to suppress a trigger globally. Supports context macros for per-insta
183185
| VMs/LXC not all running | Info | Cluster-wide: running count < total count |
184186
| Guests not covered by any backup job | Warning | From `/cluster/backup-info/not-backed-up`. Catches the guest that was created after the backup job was defined. |
185187
| APT repository files are broken | Warning | At least one repository file cannot be parsed, updates will fail |
188+
| APT repository configuration has warnings | Info | For example the enterprise repository enabled without a subscription |
189+
| Package updates pending | Info | Disabled by default, like the item it depends on |
186190
| PVE subscription is not active | Warning | Disabled by default, see `{$PVE.SUBSCRIPTION.ALERT}` |
187191

188192
### VM / LXC Prototypes
@@ -221,6 +225,7 @@ Set to `0` to suppress a trigger globally. Supports context macros for per-insta
221225
| SSD wearout below threshold | Warning |
222226
| PVE service not running | Average |
223227
| ZFS pool not ONLINE | High |
228+
| ZFS pool fragmentation above `{$ZFS.FRAG.WARN}` | Warning |
224229
| ZFS pool usage over warning / critical threshold | Average / High |
225230
| Replication job failing | Average |
226231
| Replication job has not synced within `{$PVE.REPL.LAG}` | Warning |
@@ -262,6 +267,7 @@ The template includes a pre-built dashboard **"Proxmox VE - Monitoring Dashboard
262267
- **Replication:** The list endpoint already carries the job state, so no extra request per job is needed. Fields such as `last_sync` and `error` are absent before the first run or while the job is healthy; those items discard the value instead of turning unsupported.
263268
- **Subscription:** `/nodes/{node}/subscription` needs no special permission and answers with HTTP 200 even without a subscription, reporting status `notfound`.
264269
- **Permission errors:** The API answers with HTTP 403, so an item lacking permissions turns visibly unsupported rather than silently staying empty.
270+
- **ZFS pool health:** Stored as a number with a value map rather than as text, so it can be graphed and shown on a dashboard. 0 is ONLINE, everything above is a fault. The mapping is done with preprocessing steps, not with a script. A state outside the seven known zpool states leaves text in place and the item turns visibly unsupported instead of reporting a wrong number.
265271
- **Long term data:** Numeric performance and capacity items keep 365 days of trends. Timestamp items such as `last_sync` or `notafter` deliberately keep trends disabled, a trend over a Unix timestamp carries no meaning.
266272

267273
---

Virtualization/template_proxmox-ve-rest-api-zabbix/7.0/template_proxmox-ve-rest-api.yaml

Lines changed: 81 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4030,13 +4030,43 @@ zabbix_export:
40304030
type: DEPENDENT
40314031
key: 'zfs.health[{#ZPOOL}]'
40324032
delay: '0'
4033-
value_type: CHAR
4034-
trends: '0'
4035-
description: 'zpool health: ONLINE, DEGRADED, FAULTED, OFFLINE, REMOVED or UNAVAIL.'
4033+
value_type: UNSIGNED
4034+
trends: 365d
4035+
description: 'zpool health as a number so it can be graphed and used on a dashboard. 0 is ONLINE, everything above is a fault. The value map turns it back into the zpool wording.'
4036+
valuemap:
4037+
name: 'ZFS pool health'
40364038
preprocessing:
40374039
- type: JSONPATH
40384040
parameters:
40394041
- '$.data[?(@.name=="{#ZPOOL}")].health.first()'
4042+
- type: STR_REPLACE
4043+
parameters:
4044+
- ONLINE
4045+
- '0'
4046+
- type: STR_REPLACE
4047+
parameters:
4048+
- DEGRADED
4049+
- '1'
4050+
- type: STR_REPLACE
4051+
parameters:
4052+
- FAULTED
4053+
- '2'
4054+
- type: STR_REPLACE
4055+
parameters:
4056+
- OFFLINE
4057+
- '3'
4058+
- type: STR_REPLACE
4059+
parameters:
4060+
- REMOVED
4061+
- '4'
4062+
- type: STR_REPLACE
4063+
parameters:
4064+
- UNAVAIL
4065+
- '5'
4066+
- type: STR_REPLACE
4067+
parameters:
4068+
- SUSPENDED
4069+
- '6'
40404070
master_item:
40414071
key: pve.zfs.raw
40424072
tags:
@@ -4046,10 +4076,11 @@ zabbix_export:
40464076
value: '{#ZPOOL}'
40474077
trigger_prototypes:
40484078
- uuid: d65a4e365c134cea9cf48cfca9c173dc
4049-
expression: 'last(/Template Proxmox VE REST API/zfs.health[{#ZPOOL}])<>"ONLINE"'
4079+
expression: 'last(/Template Proxmox VE REST API/zfs.health[{#ZPOOL}])<>0'
40504080
name: 'ZFS pool {#ZPOOL} is not ONLINE on {HOST.NAME}'
4081+
event_name: 'ZFS pool {#ZPOOL} is {ITEM.VALUE1} on {HOST.NAME}'
40514082
priority: HIGH
4052-
description: 'zpool health is DEGRADED, FAULTED, OFFLINE, REMOVED or UNAVAIL. Check /nodes/{node}/disks/zfs/{pool} for the failing vdev.'
4083+
description: 'zpool health left ONLINE. Check /nodes/{node}/disks/zfs/{pool} for the failing vdev, the detail endpoint reports read, write and checksum errors per device.'
40534084
- uuid: 60c15d2ea06e465897ef285127da047c
40544085
name: 'ZFS pool size {#ZPOOL}'
40554086
type: DEPENDENT
@@ -4130,6 +4161,12 @@ zabbix_export:
41304161
value: ZFS
41314162
- tag: PVE
41324163
value: '{#ZPOOL}'
4164+
trigger_prototypes:
4165+
- uuid: ed2b6ba1d4cb4b029e7b75c0ff414ea0
4166+
expression: 'last(/Template Proxmox VE REST API/zfs.frag[{#ZPOOL}])>{$ZFS.FRAG.WARN:"{#ZPOOL}"}'
4167+
name: 'ZFS pool {#ZPOOL} fragmentation above {$ZFS.FRAG.WARN}% on {HOST.NAME}'
4168+
priority: WARNING
4169+
description: 'Free space in the pool is heavily fragmented, which slows down writes. Usually a consequence of a pool kept too full for too long. Freeing space helps, defragmenting a zpool is not possible.'
41334170
- uuid: 2167f0fa32e24ac9803b5aa3cd346bbe
41344171
name: 'ZFS pool dedup ratio {#ZPOOL}'
41354172
type: DEPENDENT
@@ -4217,8 +4254,9 @@ zabbix_export:
42174254
- uuid: 9d0695a301e54a4dbb9590dd62e79a37
42184255
expression: 'last(/Template Proxmox VE REST API/repl.fail_count[{#REPL_ID}])>{$PVE.REPL.FAIL.MAX}'
42194256
name: 'Replication job {#REPL_ID} failing on {HOST.NAME}'
4257+
event_name: 'Replication job {#REPL_ID} failing: {?last(//repl.error[{#REPL_ID}])}'
42204258
priority: AVERAGE
4221-
description: 'PVE counts consecutive failures of this replication job. The reason is in the corresponding error item.'
4259+
description: 'PVE counts consecutive failures of this replication job. The event name carries the error message PVE reported for the last run.'
42224260
- uuid: 40786cb4039d42c8bc5703ca03635c1e
42234261
name: 'Replication last sync {#REPL_ID}'
42244262
type: DEPENDENT
@@ -4503,6 +4541,12 @@ zabbix_export:
45034541
- macro: '{$PVE.APT.REPO.ERRORS.MAX}'
45044542
value: '0'
45054543
description: 'Tolerated number of unparsable APT repository files before alerting.'
4544+
- macro: '{$PVE.APT.REPO.WARN.MAX}'
4545+
value: '0'
4546+
description: 'Tolerated number of APT repository warnings. A host on the no-subscription repository permanently reports one warning, set this to 1 there.'
4547+
- macro: '{$PVE.APT.UPDATES.MAX}'
4548+
value: '0'
4549+
description: 'Tolerated number of pending package updates. Only relevant if the disabled apt/update items are switched on.'
45064550
- macro: '{$PVE.CERT.EXPIRE.DAYS}'
45074551
value: 21d
45084552
description: 'Lead time before certificate expiry. Must include a time unit, for example 21d.'
@@ -5347,6 +5391,23 @@ zabbix_export:
53475391
newvalue: paused
53485392
- value: '3'
53495393
newvalue: unknown
5394+
- uuid: 4edeb346d0d64155ad2e8063d7a4cab8
5395+
name: 'ZFS pool health'
5396+
mappings:
5397+
- value: '0'
5398+
newvalue: ONLINE
5399+
- value: '1'
5400+
newvalue: DEGRADED
5401+
- value: '2'
5402+
newvalue: FAULTED
5403+
- value: '3'
5404+
newvalue: OFFLINE
5405+
- value: '4'
5406+
newvalue: REMOVED
5407+
- value: '5'
5408+
newvalue: UNAVAIL
5409+
- value: '6'
5410+
newvalue: SUSPENDED
53505411
triggers:
53515412
- uuid: bdaeac3c76ec44ef96bf78ca83ba0dad
53525413
expression: 'min(/Template Proxmox VE REST API/pve.loadaverage.oneminute,900) >= last(/Template Proxmox VE REST API/pve.cpus)'
@@ -5399,6 +5460,20 @@ zabbix_export:
53995460
opdata: 'Broken files: {ITEM.LASTVALUE1}'
54005461
priority: WARNING
54015462
description: 'At least one APT repository file cannot be parsed. Updates will fail until this is fixed.'
5463+
- uuid: 5fe993f6929a4e05ab7bca6e61c8b631
5464+
expression: 'last(/Template Proxmox VE REST API/pve.apt.repos.warnings)>{$PVE.APT.REPO.WARN.MAX}'
5465+
name: 'APT repository configuration has warnings on {HOST.NAME}'
5466+
opdata: 'Warnings: {ITEM.LASTVALUE1}'
5467+
priority: INFO
5468+
description: 'PVE reports a problem with the repository configuration, for example the enterprise repository being enabled without a subscription. A host on the no-subscription repository reports one warning permanently, raise {$PVE.APT.REPO.WARN.MAX} to 1 there.'
5469+
manual_close: 'YES'
5470+
- uuid: 516ffe6de3804b97aa29d41e333deba3
5471+
expression: 'last(/Template Proxmox VE REST API/pve.apt.updates.count)>{$PVE.APT.UPDATES.MAX}'
5472+
name: '{ITEM.LASTVALUE} package update(s) pending on {HOST.NAME}'
5473+
priority: INFO
5474+
status: DISABLED
5475+
description: 'Disabled by default, like the item it depends on. The master item needs Sys.Modify, which PVEAuditor does not grant.'
5476+
manual_close: 'YES'
54025477
- uuid: 57b2f7fad21f4672874712a66208931a
54035478
expression: 'last(/Template Proxmox VE REST API/pve.subscription.status)<>"active" and {$PVE.SUBSCRIPTION.ALERT}=1'
54045479
name: 'PVE subscription is not active on {HOST.NAME} ({ITEM.LASTVALUE})'

0 commit comments

Comments
 (0)