forked from open-falcon/falcon-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.go
41 lines (33 loc) · 843 Bytes
/
check.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 cmd
import (
"fmt"
"strings"
"github.com/open-falcon/falcon-plus/g"
"github.com/spf13/cobra"
)
var Check = &cobra.Command{
Use: "check [Module ...]",
Short: "Check the status of Open-Falcon modules",
Long: `
Check if the specified Open-Falcon modules are running.
Modules:
` + "all " + strings.Join(g.AllModulesInOrder, " "),
RunE: check,
}
func check(c *cobra.Command, args []string) error {
args = g.RmDup(args)
if len(args) == 0 {
args = g.AllModulesInOrder
}
for _, moduleName := range args {
if !g.HasModule(moduleName) {
return fmt.Errorf("%s doesn't exist", moduleName)
}
if g.IsRunning(moduleName) {
fmt.Printf("%20s %10s %15s \n", g.ModuleApps[moduleName], "UP", g.Pid(moduleName))
} else {
fmt.Printf("%20s %10s %15s \n", g.ModuleApps[moduleName], "DOWN", "-")
}
}
return nil
}