예제 #1
0
func NewChartFromTimeFloatPairWithTitle(title string, inputList []TimeFloatPair) kmgBootstrap.Panel {
	var body kmgView.HtmlRenderer
	if len(inputList) > 1 {
		body = CreateLineFromTimeFloatPair(inputList)
	} else {
		out := fmt.Sprintf("共 %d 条数据\n", len(inputList))
		for _, pair := range inputList {
			out += kmgTime.DefaultFormat(pair.X) + " : " + kmgStrconv.FormatFloat(pair.Y) + " \n"
		}
		body = kmgBootstrap.Pre(out)
	}
	return kmgBootstrap.Panel{
		Title: title + " 共 " + kmgStrconv.FormatInt(len(inputList)) + " 条数据",
		Body:  body,
	}
}
예제 #2
0
파일: cmd.go 프로젝트: keysonZZZ/kmg
func MustRpcSshCmd(ip string, cmd ...string) []byte {
	if len(cmd) == 0 {
		return []byte{}
	}
	if ip == "" {
		return []byte{}
	}
	cmdCombine := strings.Join(cmd, "&&")
	out, err := kmgCmd.CmdString("ssh -o StrictHostKeyChecking=no -o PasswordAuthentication=no root@" + ip + " " + cmdCombine).RunAndReturnOutput()
	logPath := "/tmp/rpcSshCmd-" + ip
	kmgFile.MustAppendFile(logPath, []byte(strings.Join([]string{cmdCombine, kmgTime.DefaultFormat(time.Now())}, "\n")))
	kmgFile.MustAppendFile(logPath, out)
	if err != nil {
		//		_, ok := err.(*exec.ExitError)
		//		if ok {
		//			return out
		//		}
		kmgFile.MustAppendFile(logPath, []byte(err.Error()))
		panic(err)
	}
	return out
}