Skip to content

Commit abcf9c1

Browse files
committed
added example to readme
1 parent 7ab2bb5 commit abcf9c1

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,33 @@
33
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/niklastreml/icinga-marshaler)
44
[![GoDoc](https://godoc.org/github.com/NiklasTreml/icinga-marshaler?status.svg)](https://godoc.org/github.com/NiklasTreml/icinga-marshaler)
55

6-
Small library that provides a utility function for easily marshalling any go struct into a format that icinga2 can understand.
6+
Small library that provides a utility function for easily marshalling any go struct into a format that icinga2 can understand. The library follows the specification mentioned [here](https://icinga.com/docs/icinga-2/latest/doc/05-service-monitoring/#performance-data-metrics).
7+
8+
# Example
9+
10+
```golang
11+
package main
12+
13+
func main() {
14+
type Check struct {
15+
BasicValue string
16+
FieldWithThresholds int64 `warn:"800" crit:"1024" min:"64" max:"2048"`
17+
FieldWithCustomName float64 `icinga:"MyCustomField"`
18+
EverythingTogether int32 `icinga:"Complex" warn:"800" crit:"1024" min:"64" max:"2048"`
19+
}
20+
21+
status := Check{
22+
BasicValue: "WARN",
23+
FieldWithThresholds: 1024,
24+
FieldWithCustomName: 63.5,
25+
EverythingTogether: 100,
26+
}
27+
28+
bytes := Marshal(status)
29+
fmt.Println(string(bytes))
30+
}
31+
```
32+
33+
Creates this output:
34+
35+
`'BasicValue'=WARN 'FieldWithThresholds'=1024;800;1024;64;2048 'MyCustomField'=63.5 'Complex'=100;800;1024;64;2048`

0 commit comments

Comments
 (0)