-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhttpsvr.go
More file actions
57 lines (50 loc) · 1.12 KB
/
httpsvr.go
File metadata and controls
57 lines (50 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"fmt"
"net/http"
"github.com/OutOfBedlam/tine/engine"
_ "github.com/OutOfBedlam/tine/plugins/all"
)
func main() {
addr := "127.0.0.1:8080"
router := http.NewServeMux()
router.HandleFunc("GET /cpu", engine.HttpHandleFunc(cpuPipeline))
router.HandleFunc("GET /screenshot", engine.HttpHandleFunc(screenshotPipeline))
router.HandleFunc("GET /template", engine.HttpHandleFunc(templatePipeline))
fmt.Printf("\nstart server http://%s\n\n", addr)
http.ListenAndServe(addr, router)
}
const cpuPipeline = `
[[inlets.cpu]]
interval = "3s"
totalcpu = true
percpu = false
[[flows.select]]
includes = ["#_ts", "*"]
[[outlets.file]]
format = "json"
decimal = 2
`
const screenshotPipeline = `
[[inlets.screenshot]]
count = 1
displays = [0]
[[outlets.image]]
path = "nonamed.png" ## <- Required to set image type (.jpeg, .png, .gif ....)
`
const templatePipeline = `
[[inlets.load]]
count = 1
[[outlets.template]]
templates = [
'''
<html>
<body>
{{ range . }}
<li> <b>{{ (index ._ts).Format "2006 Jan 02 15:04:05" }}</b> {{ index .load1 }}
{{ end }}
</body>
</html>
''',
]
`