-
Notifications
You must be signed in to change notification settings - Fork 19
/
main.go
41 lines (36 loc) · 865 Bytes
/
main.go
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
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/falcosecurity/client-go/pkg/api/outputs"
"github.com/falcosecurity/client-go/pkg/client"
"github.com/gogo/protobuf/jsonpb"
)
func printOutput(res *outputs.Response) error {
out, err := (&jsonpb.Marshaler{}).MarshalToString(res)
if err != nil {
return err
}
fmt.Println(out)
return nil
}
func main() {
c, err := client.NewForConfig(context.Background(), &client.Config{
Hostname: "localhost",
Port: 5060,
CertFile: "/etc/falco/certs/client.crt",
KeyFile: "/etc/falco/certs/client.key",
CARootFile: "/etc/falco/certs/ca.crt",
})
if err != nil {
log.Fatalf("unable to connect: %v", err)
}
defer c.Close()
ctx := context.Background()
err = c.OutputsWatch(ctx, printOutput, time.Second*1)
if err != nil {
log.Fatalf("outputs watch error: %v", err)
}
}