Skip to content

Example

This page shows an example of adding new zProperties. Note the special DEFAULTS entry, which is supported in many places as a way to set default properties for all other entries in a section. In this case it will set category to ACME Widgeter for the zWidgeterEnable and zWidgeterInterval zProperties.

zenpack.yaml
name: ZenPacks.acme.Widgeter

zProperties:
  DEFAULTS:
    category: ACME Widgeter

  zWidgeterEnable:
    type: boolean
    default: true

  zWidgeterInterval:
    type: string
    default: 300

Next, we extend the example to add a device class and monitoring template complete with a datasource, threshold and graph.

zenpack.yaml
device_classes:
  /Server/ACME/Widgeter:
    templates:
      Device:
        description: ACME Widgeter monitoring.
        targetPythonClass: ZenPacks.acme.Widgeter.Widgeter

        datasources:
          status:
            type: COMMAND
            parser: Nagios
            commandTemplate: "echo OK|available=1"

            datapoints:
              available:
                rrdtype: GAUGE
                rrdmin: 0
                rrdmax: 1

        thresholds:
          unavailable:
            dsnames: [status_available]
              eventClass: /Status
              severity: Critical
              minval: 1

        graphs:
          Availability:
            units: percent
            miny: 0
            maxy: 100

            graphpoints:
              Availability:
                dpName: status_available
                rpn: 100,*
                format: "%7.2lf%%"
                lineType: AREA

And extend again by adding a new device type, component type and relationship between them.

zenpack.yaml
classes:
  Widgeter:
    base: [zenpacklib.Device]
    meta_type: ACMEWidgeter

  Widget:
    base: [zenpacklib.Component]
    meta_type: ACMEWidget
    properties:
      flavor:
        label: Flavor
        type: string

class_relationships:
  - Widgeter 1:MC Widget