When a ZenPack installs or upgrades, it reinstalls its own monitoring templates at whatever device class path it originally defined them. If you've directly edited that same template (same name, same path), or created a custom ZenPack that overwrites existing templates, any installation of the original ZenPack overwrites your templates.
There are two ways to avoid this:
- Don't change the original device class. Create a subclass and make your changes there.
- Copy the template, and append
-replacementor-additionto the name instead of editing the original template.
-replacement substitutes for the original template. For example, if your ZenPack ships an ExampleVolume template, you create ExampleVolume-replacement at the same device class. The Collection Zone (Resource Manager in on-premises deployments) uses your replacement instead of the original. The original stays untouched, so the ZenPack can freely overwrite it on every install or upgrade without affecting your customization.
-addition layers on top of the original instead of replacing it. For example, ExampleVolume-addition runs alongside ExampleVolume, so you keep the original monitoring intact and add your own data sources, thresholds, and graphs on top.
With either approach, a zenpack update or zenpack install upgrade can freely overwrite the original template contents, because your customizations live in a separate object that the ZenPack never touches.
ZenPack backup with ZenPackLib
If you don't use a subclass or the -replacement option, the ZenPack installation still backs up your changes when the ZenPack uses the ZenPackLib library. Your template is saved with a suffix showing the date and time of the upgrade, in the format <TemplateName>-backup-preupgrade-<YYYYMMDDHHMM> (for example, ExampleVolume-backup-preupgrade-202606291710). You can then rename the new template and remove the suffix from your custom template to restore its original name.
This pre-upgrade backup only applies to default templates provided by the ZenPack being upgraded. It doesn't create a backup copy of a -replacement template you created manually.
Use this backup process only as a last resort. The subclass and -replacement/-addition options are better choices because they don't require manual intervention after every upgrade.
!!! note A -replacement template isn't touched during upgrades, so it won't receive code changes made to a default template to fix issues or add features. If the ZenPack requires those changes to function, update your -replacement template manually to match.
Comments