diff options
| author | Chris Lu <chris.lu@gmail.com> | 2021-11-05 17:39:41 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2021-11-05 17:39:41 -0700 |
| commit | 314c32514b1134f5605ca8bc3e1cdf785943b53b (patch) | |
| tree | 0eab459a232c07916156fd09bde1e9979ec637d2 | |
| parent | 7348d2ae6398387bb96526f1d3d9f6fcafc3d4da (diff) | |
| download | seaweedfs-314c32514b1134f5605ca8bc3e1cdf785943b53b.tar.xz seaweedfs-314c32514b1134f5605ca8bc3e1cdf785943b53b.zip | |
add command to list filers
| -rw-r--r-- | weed/shell/command_cluster_ps.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/weed/shell/command_cluster_ps.go b/weed/shell/command_cluster_ps.go new file mode 100644 index 000000000..ff92064db --- /dev/null +++ b/weed/shell/command_cluster_ps.go @@ -0,0 +1,54 @@ +package shell + +import ( + "context" + "flag" + "fmt" + "io" + + "github.com/chrislusf/seaweedfs/weed/pb/master_pb" +) + +func init() { + Commands = append(Commands, &commandClusterPs{}) +} + +type commandClusterPs struct { +} + +func (c *commandClusterPs) Name() string { + return "cluster.ps" +} + +func (c *commandClusterPs) Help() string { + return `check current cluster process status + + cluster.ps + +` +} + +func (c *commandClusterPs) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) { + + clusterPsCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError) + if err = clusterPsCommand.Parse(args); err != nil { + return nil + } + + err = commandEnv.MasterClient.WithClient(func(client master_pb.SeaweedClient) error { + resp, err := client.ListClusterNodes(context.Background(), &master_pb.ListClusterNodesRequest{ + ClientType: "filer", + }) + + fmt.Fprintf(writer, "the cluster has %d filers\n", len(resp.ClusterNodes)) + for _, node := range resp.ClusterNodes { + fmt.Fprintf(writer, " * %s (%v)\n", node.Address, node.Version) + } + return err + }) + if err != nil { + return + } + + return nil +} |
