-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhost.go
More file actions
65 lines (57 loc) · 1.66 KB
/
host.go
File metadata and controls
65 lines (57 loc) · 1.66 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
58
59
60
61
62
63
64
65
package main
import (
"github.com/FurqanSoftware/bullet/core"
"github.com/FurqanSoftware/bullet/distro"
"github.com/spf13/cobra"
)
var HostShellCmd = &cobra.Command{
Use: "host:shell",
Short: "Open an interactive shell on a server",
Long: `Start an interactive bash session over SSH on the selected node.`,
RunE: func(cmd *cobra.Command, args []string) error {
s, err := NewSelector().Node(currentScope)
if err != nil {
return err
}
return core.Shell(s, currentConfiguration)
},
}
var (
flagDfWatch bool
flagDfArguments string
)
var HostDfCmd = &cobra.Command{
Use: "host:df",
Short: "Show disk usage on a server",
Long: `Run df on the selected node to show disk space usage. Use --watch
for continuous updates or --arguments to pass additional flags to df.`,
RunE: func(cmd *cobra.Command, args []string) error {
s, err := NewSelector().Node(currentScope)
if err != nil {
return err
}
return core.Df(s, currentConfiguration, distro.DfOptions{
Watch: flagDfWatch,
Arguments: flagDfArguments,
})
},
}
var HostTopCmd = &cobra.Command{
Use: "host:top",
Short: "Show running processes on a server",
Long: `Run top interactively on the selected node.`,
RunE: func(cmd *cobra.Command, args []string) error {
s, err := NewSelector().Node(currentScope)
if err != nil {
return err
}
return core.Top(s, currentConfiguration)
},
}
func init() {
RootCmd.AddCommand(HostShellCmd)
HostDfCmd.Flags().BoolVarP(&flagDfWatch, "watch", "w", false, "runs df with watch")
HostDfCmd.Flags().StringVarP(&flagDfArguments, "arguments", "a", "", "additional arguments for df")
RootCmd.AddCommand(HostDfCmd)
RootCmd.AddCommand(HostTopCmd)
}