zabbix_export: version: '6.0' date: '2021-11-21T22:06:03Z' groups: - uuid: 846977d1dfed4968bc5f8bdb363285bc name: 'Templates/Operating systems' templates: - uuid: 07065ad7dc4846098587d1b12a7cdedd template: 'restic backup by Zabbix agent' name: 'restic backup by Zabbix agent' description: | ## Overview Get alerts when your restic backup have failed, or didn't finish on time. The default is in last 26 hours but can be changed via a MACRO. Two MACROs are available: * `{$BACKUP_STATUS_FILE}` which contain the full path of the status file. Default is `/home/backup/status.json`. * `{$MAX_HOURS_BETWEEN}` which contain the maximum number of hours before it triggers an alert. Default is `26` hours (for backup running once a day, plus some time if it takes a bit longer than usual). This is using the status file generated by [resticprofile](https://github.com/creativeprojects/resticprofile/). For more information, see the [README](https://github.com/creativeprojects/resticprofile/tree/master/contrib/zabbix). groups: - name: 'Templates/Operating systems' items: - uuid: f304d9cbf4d0457a94fd11eae96d6354 name: 'Status file' key: 'vfs.file.contents[{$BACKUP_STATUS_FILE}]' delay: 1h trends: '0' value_type: TEXT preprocessing: - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 1d tags: - tag: Application value: Backup discovery_rules: - uuid: 64247957696c41bfb10867332c15472f name: Profiles type: DEPENDENT key: backup.profiles delay: '0' item_prototypes: - uuid: e1fc889a79744ae9967c6f08551505a8 name: 'Backup profile {#PROFILENAME} / {#PROFILECOMMAND} error' type: DEPENDENT key: 'backup.error[{#PROFILENAME}, {#PROFILECOMMAND}]' delay: '0' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - '$.profiles["{#PROFILENAME}"]["{#PROFILECOMMAND}"].error' master_item: key: 'vfs.file.contents[{$BACKUP_STATUS_FILE}]' tags: - tag: Application value: Backup - uuid: 8a998301486a4aee806f6b78cdff46e4 name: 'Backup profile {#PROFILENAME} / {#PROFILECOMMAND} success' type: DEPENDENT key: 'backup.success[{#PROFILENAME}, {#PROFILECOMMAND}]' delay: '0' preprocessing: - type: JSONPATH parameters: - '$.profiles["{#PROFILENAME}"]["{#PROFILECOMMAND}"].success' - type: BOOL_TO_DECIMAL parameters: - '' master_item: key: 'vfs.file.contents[{$BACKUP_STATUS_FILE}]' tags: - tag: Application value: Backup trigger_prototypes: - uuid: 76baa76cbba341d386d6337d27195c29 expression: 'last(/restic backup by Zabbix agent/backup.success[{#PROFILENAME}, {#PROFILECOMMAND}])=0' name: 'Last {#PROFILENAME} / {#PROFILECOMMAND} failed' priority: HIGH manual_close: 'YES' - uuid: 0a80ab2a888b4581bdc61ce5e6be61b6 name: 'Backup profile {#PROFILENAME} / {#PROFILECOMMAND} time' type: DEPENDENT key: 'backup.time[{#PROFILENAME}, {#PROFILECOMMAND}]' delay: '0' units: unixtime preprocessing: - type: JSONPATH parameters: - '$.profiles["{#PROFILENAME}"]["{#PROFILECOMMAND}"].time' - type: JAVASCRIPT parameters: - 'return Math.round(Date.parse(value)/1000)' master_item: key: 'vfs.file.contents[{$BACKUP_STATUS_FILE}]' tags: - tag: Application value: Backup trigger_prototypes: - uuid: 61e909042f7c48f0bee9b04941e6e58c expression: 'now()-last(/restic backup by Zabbix agent/backup.time[{#PROFILENAME}, {#PROFILECOMMAND}])>({$MAX_HOURS_BETWEEN}*3600)' name: 'Last {#PROFILENAME} / {#PROFILECOMMAND} did not run' priority: HIGH description: | Last profile has not finished on time (or has not started): last run finished more than {$MAX_HOURS_BETWEEN} hour(s) ago manual_close: 'YES' master_item: key: 'vfs.file.contents[{$BACKUP_STATUS_FILE}]' preprocessing: - type: JAVASCRIPT parameters: - | var output = [] var status = JSON.parse(value) Object.keys(status.profiles).forEach(function(profileName) { Object.keys(status.profiles[profileName]).forEach(function(entry) { output.push({ "{#PROFILENAME}": profileName, "{#PROFILECOMMAND}": entry, }) }) }); return JSON.stringify(output) tags: - tag: from value: local macros: - macro: '{$BACKUP_STATUS_FILE}' value: /home/backup/status.json description: 'resticprofile status file' - macro: '{$MAX_HOURS_BETWEEN}' value: '26' - uuid: 1c05e941ac4048e3805adc3c91877432 template: 'restic backup by Zabbix agent active' name: 'restic backup by Zabbix agent active' description: | ## Overview Get alerts when your restic backup have failed, or didn't finish on time. The default is in last 26 hours but can be changed via a MACRO. Two MACROs are available: * `{$BACKUP_STATUS_FILE}` which contain the full path of the status file. Default is `/home/backup/status.json`. * `{$MAX_HOURS_BETWEEN}` which contain the maximum number of hours before it triggers an alert. Default is `26` hours (for backup running once a day, plus some time if it takes a bit longer than usual). This is using the status file generated by [resticprofile](https://github.com/creativeprojects/resticprofile/). For more information, see the [README](https://github.com/creativeprojects/resticprofile/tree/master/contrib/zabbix). ## Overview Get alerts when your restic backup have failed, or didn't finish on time. The default is in last 26 hours but can be changed via a MACRO. Two MACROs are available: * `{$BACKUP_STATUS_FILE}` which contain the full path of the status file. Default is `/home/backup/status.json`. * `{$MAX_HOURS_BETWEEN}` which contain the maximum number of hours before it triggers an alert. Default is `26` hours (for backup running once a day, plus some time if it takes a bit longer than usual). This is using the status file generated by [resticprofile](https://github.com/creativeprojects/resticprofile/). For more information, see the [README](https://github.com/creativeprojects/resticprofile/tree/master/contrib/zabbix). groups: - name: 'Templates/Operating systems' items: - uuid: 3de6700c79d144dfabbad511e377730d name: 'Status file' type: ZABBIX_ACTIVE key: 'vfs.file.contents[{$BACKUP_STATUS_FILE}]' delay: 1h trends: '0' value_type: TEXT preprocessing: - type: DISCARD_UNCHANGED_HEARTBEAT parameters: - 1d tags: - tag: Application value: Backup discovery_rules: - uuid: af1817c991064bf188a9f0c58df193c6 name: Profiles type: DEPENDENT key: backup.profiles delay: '0' item_prototypes: - uuid: fa53135a6941471581eb8ccfe302916f name: 'Backup profile {#PROFILENAME} / {#PROFILECOMMAND} error' type: DEPENDENT key: 'backup.error[{#PROFILENAME}, {#PROFILECOMMAND}]' delay: '0' trends: '0' value_type: TEXT preprocessing: - type: JSONPATH parameters: - '$.profiles["{#PROFILENAME}"]["{#PROFILECOMMAND}"].error' master_item: key: 'vfs.file.contents[{$BACKUP_STATUS_FILE}]' tags: - tag: Application value: Backup - uuid: 546cf45055274228aaed1c02ac62cc44 name: 'Backup profile {#PROFILENAME} / {#PROFILECOMMAND} success' type: DEPENDENT key: 'backup.success[{#PROFILENAME}, {#PROFILECOMMAND}]' delay: '0' preprocessing: - type: JSONPATH parameters: - '$.profiles["{#PROFILENAME}"]["{#PROFILECOMMAND}"].success' - type: BOOL_TO_DECIMAL parameters: - '' master_item: key: 'vfs.file.contents[{$BACKUP_STATUS_FILE}]' tags: - tag: Application value: Backup trigger_prototypes: - uuid: 18ee58fdd60c4f249e12159c8d73d2be expression: 'last(/restic backup by Zabbix agent active/backup.success[{#PROFILENAME}, {#PROFILECOMMAND}])=0' name: 'Last {#PROFILENAME} / {#PROFILECOMMAND} failed' priority: HIGH manual_close: 'YES' - uuid: 3119635c34844a03b5dcb7da85ffaa8a name: 'Backup profile {#PROFILENAME} / {#PROFILECOMMAND} time' type: DEPENDENT key: 'backup.time[{#PROFILENAME}, {#PROFILECOMMAND}]' delay: '0' units: unixtime preprocessing: - type: JSONPATH parameters: - '$.profiles["{#PROFILENAME}"]["{#PROFILECOMMAND}"].time' - type: JAVASCRIPT parameters: - 'return Math.round(Date.parse(value)/1000)' master_item: key: 'vfs.file.contents[{$BACKUP_STATUS_FILE}]' tags: - tag: Application value: Backup trigger_prototypes: - uuid: 306348b3f9ba426db83ea4e0eeb88994 expression: 'now()-last(/restic backup by Zabbix agent active/backup.time[{#PROFILENAME}, {#PROFILECOMMAND}])>({$MAX_HOURS_BETWEEN}*3600)' name: 'Last {#PROFILENAME} / {#PROFILECOMMAND} did not run' priority: HIGH description: | Last profile has not finished on time (or has not started): last run finished more than {$MAX_HOURS_BETWEEN} hour(s) ago manual_close: 'YES' master_item: key: 'vfs.file.contents[{$BACKUP_STATUS_FILE}]' preprocessing: - type: JAVASCRIPT parameters: - | var output = [] var status = JSON.parse(value) Object.keys(status.profiles).forEach(function(profileName) { Object.keys(status.profiles[profileName]).forEach(function(entry) { output.push({ "{#PROFILENAME}": profileName, "{#PROFILECOMMAND}": entry, }) }) }); return JSON.stringify(output) tags: - tag: from value: local macros: - macro: '{$BACKUP_STATUS_FILE}' value: /home/backup/status.json description: 'resticprofile status file' - macro: '{$MAX_HOURS_BETWEEN}' value: '26'