License
MIT License
v0.1.0 · public · Published about 4 years ago
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.
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.
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 add jspaleta/template-toolkit-command
Requires event json representation stdin to operate correctly.
To test the output of a template:
cat event.json | sensuctl command execute jspaleta/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 execute jspaleta/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 | sensuctl command execute jspaleta/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,
[...]
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
For more information about contributing to this plugin, see Contributing.
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.
×