这是indexloc提供的服务,不要输入任何密码
Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Conversation

@giganteous
Copy link
Contributor

With regards to the os.diskspace alert, I like to write my exceptions for disks like this:

lookup disk_space {
    entry host=netlog,disk=/data {
        warn_percent_free = 5
        crit_percent_free = 0
    }
    entry host=*,disk=* {
        warn_percent_free = 10
        crit_percent_free = 0
    }
}

Currently this gives an error: "unexpected invalid character: / in section declaration", this change should remove the bug.

Thanks,

captncraig pushed a commit that referenced this pull request Sep 3, 2015
cmd/Bosun: support / in lookup sections
@captncraig captncraig merged commit f11e6f4 into bosun-monitor:master Sep 3, 2015
@giganteous giganteous deleted the add-slash-to-parse branch September 3, 2015 18:37
mvuets pushed a commit to bookingcom/bosun that referenced this pull request Apr 18, 2018
In this commit I try to partly address an issue raised in the report bosun-monitor#1297:
I want to generate a JSON on `actionBodyAck` and send it to an HTTP API.
One of the fields in the JSON payload should contain a message attached
to the performed action and also a list of ids of affected incidents,
e.g.: "User X acknowledged N incidents (ids: 1, 2, 4) with a note: M".
I need to use `makeMap` and `json` functions, which take a "pipeline"
in Go's terms, to build a properly encoded JSON; but I also need a
way to traverse `.States[]` and extract a list of ids in a form of a
"pipeline". I could traverse with a help of the `{{range}}` template
action, but there is no way I can capture the result of that execution.

This patch adds a template function `execTmpl` which executes given Go
text/template provided a data structure and returns a resulting string
which can be kept in a template variable or passed on through the
template pipeline. Another way of looking at it is in-line or
sub-templates.

    {{- $list := execTmpl "{{range .}}<li>{{.Id}}</li>\n{{end}}" .States -}}
    {{- $html := printf "%v<br/>Affected incidents:<ul>%v</ul>" .Message $list -}}
    {{- makeMap "message" $html | json -}}

At first I wanted to take advantage of Go's named sub-templates
(`{{define NAME}}...`) and pass that NAME to `execTmpl` instead of a
literal template. Unfortunately template functions do not get a context
of a template in which they are being invoked, therefore I did not have
an access to the parent template containing sub-templates. I could wrap
it in a closure, but there are too many text/template instances created
in different places in code, so I figured that I will give the current
approach a go first and see how is it accepted.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants