Select Supported Platforms

Select Supported Architectures

Select Tier

Github Name


v0.2.0 · public · Published over 3 years ago

README
Asset Definition
Release Notes
Release Assets

Sensu Bonsai Asset
goreleaser
Go Test
goreleaser

Template Toolkit Command

Template Toolkit

Table of Contents

Overview

template-toolkit-command is a Sensuctl command plugin using the
Sensu Plugin SDK. This Sensuctl command plugin allows you to test and
validate Sensu plugin template strings, to ensure the templating logic works
correctly before you use them in other plugins.

Usage examples

Sensuctl command plugin for validating and testing Sensu plugin templates

Usage:
  template-toolkit-command [flags]
  template-toolkit-command [command]

Available Commands:
  help        Help about any command
  version     Print the version number of this plugin

Flags:
  -t, --template string   A template string, in Golang text/template format
  -d, --dump-names        Dump the event object names that can be used in a Golang template
  -h, --help              help for template-toolkit-command

Use "template-toolkit-command [command] --help" for more information about a command.

Configuration

Sensuctl command asset registration

Sensuctl command assets are the best way to make use of this plugin. If
you're not using an asset, please consider doing so! You can use the
following command to add the asset:

sensuctl command install template-toolkit-command sensu/template-toolkit-command

Sensuctl command usage

Requires event json representation stdin to operate correctly.

To test the output of a template:

cat event.json | sensuctl command exec template-toolkit-command -- --template "{{ .Check.Name}}"
Executing command with --template {{ .Check.Name }}
Template String Output: "keepalive"

sensuctl event info webserver01 check-http --format json | sensuctl command exec template-toolkit-command -- --template "Server: {{.Entity.Name}} Check: {{.Check.Name}} Status: {{.Check.State}}"
Executing command with --template Server: {{.Entity.Name}} Check: {{.Check.Name}} Status: {{.Check.State}}
Template String Output: Server: "webserver01 Check: check-http Status: passing"

To see the variable names available for use in a template:

sensuctl event info webserver01 check-http --format json | sensuctl command exec template-toolkit-command -- --dump-names
.Entity{
    .EntityClass: "agent",
    .System:      .System{
        .Hostname:        "webserver01",
        .OS:              "linux",
[...]
.Check{
    .Command:           "check-http.rb -u http://webserver01/",
    .Handlers:          {"slack", "email"},
    .HighFlapThreshold: 0x0,
[...]

Installation from source

The preferred way of installing and deploying this plugin is to use it as an
asset. If you would like to compile and install the plugin from source or
contribute to it, download the latest version or create an executable from
this source.

From the local path of the template-toolkit-command repository:

go build

Contributing

For more information about contributing to this plugin, see Contributing.

Are you sure you want to report this asset?

Please describe the reason for reporting this asset. Our moderators will be notified and will disable the asset if it is found to be inappropriate.

×

You must be signed in to report this asset.

Sign In with Github

Download

×

Either download the source code:

Download Source

Or download the asset definition: