使用os/exec来进行执行。

func GetHbck(wg *sync.WaitGroup) {
defer wg.Done()
cmd := exec.Command("/opt/hbase/bin/hbase", "hbck")
stdout, err := cmd.StdoutPipe()
if err != nil {
	log.Fatal(err)
}

defer stdout.Close()
if err := cmd.Start(); err != nil {
	log.Fatal(err)
}
opBytes, err := ioutil.ReadAll(stdout)
if err != nil {
	log.Fatal(err)
}
result := string(opBytes)
results := strings.Split(result, "\n")
status := strings.Split(results[len(results)-2], " ")[1]
inconsistencies, _ := strconv.Atoi(strings.Split(results[len(results)-3], " ")[0])
fmt.Printf("hbase_hbck,name=hbck status=\"%s\",inconsistencies=%d\n", status, inconsistencies)

}