Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdctl: support health check #792

Merged
merged 1 commit into from Oct 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 44 additions & 0 deletions pdctl/command/health_command.go
@@ -0,0 +1,44 @@
// Copyright 2017 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

package command

import (
"fmt"
"net/http"

"github.com/spf13/cobra"
)

var (
healthPrefix = "health"
)

// NewHealthCommand return a health subcommand of rootCmd
func NewHealthCommand() *cobra.Command {
m := &cobra.Command{
Use: "health",
Short: "show the health information",
Run: showHealthCommandFunc,
}
return m
}

func showHealthCommandFunc(cmd *cobra.Command, args []string) {
r, err := doRequest(cmd, healthPrefix, http.MethodGet)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(r)
}
1 change: 1 addition & 0 deletions pdctl/ctl.go
Expand Up @@ -51,6 +51,7 @@ func init() {
command.NewHotSpotCommand(),
command.NewClusterCommand(),
command.NewNamespaceCommand(),
command.NewHealthCommand(),
)
cobra.EnablePrefixMatching = true
}
Expand Down