Commit f692d5aa authored by szh's avatar szh

up

parent 629a4038
...@@ -42,7 +42,7 @@ type updateInfo struct { ...@@ -42,7 +42,7 @@ type updateInfo struct {
type Server struct { type Server struct {
Disks []*pai.Disk `json:"disks"` //硬盘信息 Disks []*pai.Disk `json:"disks"` //硬盘信息
NodeProcesssInfo ProcessInfo `json:"node_processs_info"` //节点信息 NodeProcessInfo ProcessInfo `json:"node_process_info"` //节点信息
Error string `json:"error"` //错误信息 Error string `json:"error"` //错误信息
} }
...@@ -101,14 +101,14 @@ func getWalletInfo() error { ...@@ -101,14 +101,14 @@ func getWalletInfo() error {
if buffer.String() == "" { if buffer.String() == "" {
tlog.Info("node dose not exist") tlog.Info("node dose not exist")
return fmt.Errorf("node dose not exist") return fmt.Errorf("node dose not exist")
} else {
fmt.Println(buffer.String())
rawProcessInfo = getProcessInfo(setting.BityuanSetting.Name)
if rawProcessInfo == "" {
tlog.Info("node down")
return errors.New("node down")
}
} }
fmt.Println(buffer.String())
rawProcessInfo = getProcessInfo(setting.BityuanSetting.Name)
if rawProcessInfo == "" {
tlog.Info("node down")
return errors.New("node down")
}
} }
record := StrFilter(strings.Split(rawProcessInfo, " "), "") record := StrFilter(strings.Split(rawProcessInfo, " "), "")
...@@ -117,7 +117,7 @@ func getWalletInfo() error { ...@@ -117,7 +117,7 @@ func getWalletInfo() error {
Bityuan.Pid = record[1] Bityuan.Pid = record[1]
Bityuan.Path = record[10] Bityuan.Path = record[10]
Bityuan.PName = path.Base(Bityuan.Path) Bityuan.PName = path.Base(Bityuan.Path)
ServerStatus.NodeProcesssInfo = Bityuan ServerStatus.NodeProcessInfo = Bityuan
} }
return nil return nil
} }
...@@ -384,7 +384,7 @@ func Unlock() error { ...@@ -384,7 +384,7 @@ func Unlock() error {
} }
pass := strings.Replace(string(passwd), "\n", "", -1) pass := strings.Replace(string(passwd), "\n", "", -1)
reply, err := setting.PaiClient.Unlock(&types.WalletUnLock{ reply, err := setting.PaiClient.Unlock(&types.WalletUnLock{
Passwd: string(pass), Passwd: pass,
Timeout: 0, Timeout: 0,
WalletOrTicket: false, WalletOrTicket: false,
XXX_NoUnkeyedLiteral: struct{}{}, XXX_NoUnkeyedLiteral: struct{}{},
...@@ -470,17 +470,17 @@ func AutoSSHClean() error { ...@@ -470,17 +470,17 @@ func AutoSSHClean() error {
tlog.Info("getAutoSSHProcessInfo", "pai", *pai) tlog.Info("getAutoSSHProcessInfo", "pai", *pai)
if pai.Stime > 0 && (time.Now().Unix()-pai.Stime) > 72*3600 && pai.Pid > 0 { if pai.Stime > 0 && (time.Now().Unix()-pai.Stime) > 72*3600 && pai.Pid > 0 {
err := KillAutoSsh(pai.Pid) err := KillAutoSSH(pai.Pid)
if err != nil { if err != nil {
tlog.Error("KillAutoSsh", "err", err) tlog.Error("KillAutoSSH", "err", err)
return err return err
} }
tlog.Info("KillAutoSsh Success", "pid", pai.Pid) tlog.Info("KillAutoSSH Success", "pid", pai.Pid)
} }
return nil return nil
} }
func KillAutoSsh(pid int32) error { func KillAutoSSH(pid int32) error {
ps := fmt.Sprintf("%d", pid) ps := fmt.Sprintf("%d", pid)
cmd := exec.Command("kill", ps) cmd := exec.Command("kill", ps)
return cmd.Run() return cmd.Run()
......
...@@ -28,7 +28,7 @@ func GetLocalArchType() string { ...@@ -28,7 +28,7 @@ func GetLocalArchType() string {
return "" return ""
} }
func GetLocalUuid() string { func GetLocalUUID() string {
cmd := exec.Command("dmidecode") cmd := exec.Command("dmidecode")
var buf, errbuf bytes.Buffer var buf, errbuf bytes.Buffer
cmd.Stdout = &buf cmd.Stdout = &buf
......
...@@ -36,7 +36,7 @@ func CheckPermission(src string) bool { ...@@ -36,7 +36,7 @@ func CheckPermission(src string) bool {
// IsNotExistMkDir create a directory if it does not exist // IsNotExistMkDir create a directory if it does not exist
func IsNotExistMkDir(src string) error { func IsNotExistMkDir(src string) error {
if notExist := CheckNotExist(src); notExist == true { if notExist := CheckNotExist(src); notExist {
if err := MkDir(src); err != nil { if err := MkDir(src); err != nil {
return err return err
} }
...@@ -74,7 +74,7 @@ func MustOpen(fileName, filePath string) (*os.File, error) { ...@@ -74,7 +74,7 @@ func MustOpen(fileName, filePath string) (*os.File, error) {
src := dir + "/" + filePath src := dir + "/" + filePath
perm := CheckPermission(src) perm := CheckPermission(src)
if perm == true { if perm {
return nil, fmt.Errorf("file.CheckPermission Permission denied src: %s", src) return nil, fmt.Errorf("file.CheckPermission Permission denied src: %s", src)
} }
......
...@@ -105,7 +105,7 @@ func (p *Pai) GetConfig() bool { ...@@ -105,7 +105,7 @@ func (p *Pai) GetConfig() bool {
return true return true
} }
} else if pai.GetArchType() == "x86_64" { } else if pai.GetArchType() == "x86_64" {
uuid := cmd.GetLocalUuid() uuid := cmd.GetLocalUUID()
if uuid != "" { if uuid != "" {
p.Serial = uuid p.Serial = uuid
return true return true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment