forked from DataDog/datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
listchecks.go
47 lines (40 loc) · 1.28 KB
/
listchecks.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
42
43
44
45
46
47
// Unless explicitly stated otherwise all files in this repository are licensed
// under the Apache License Version 2.0.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2018 Datadog, Inc.
package app
import (
"fmt"
"github.com/DataDog/datadog-agent/cmd/agent/common"
"github.com/DataDog/datadog-agent/pkg/api/util"
"github.com/DataDog/datadog-agent/pkg/config"
"github.com/spf13/cobra"
)
func init() {
// TODO: re-enable when the API endpoint is implemented
// AgentCmd.AddCommand(listCheckCommand)
}
var listCheckCommand = &cobra.Command{
Use: "list-checks",
Short: "Query the agent for the list of checks running",
Long: ``,
RunE: func(cmd *cobra.Command, args []string) error {
err := common.SetupConfig(confFilePath)
if err != nil {
return fmt.Errorf("unable to set up global agent configuration: %v", err)
}
return doListChecks()
},
}
// query for the version
func doListChecks() error {
c := util.GetClient(false) // FIX: get certificates right then make this true
urlstr := fmt.Sprintf("https://localhost:%v/check/", config.Datadog.GetInt("cmd_port"))
body, e := util.DoGet(c, urlstr)
if e != nil {
fmt.Printf("Error getting version string: %s\n", e)
return e
}
fmt.Printf("Checks: %s\n", body)
return nil
}