func (routeServerGeneralInfo *RouteServerGeneralInfo) Routes(m *martini.ClassicMartini) { m.Get("/server/info/general", func(w http.ResponseWriter, r *http.Request) string { log.WriteLog("addr: /server/info/general") shttp.SetResponseJsonHeader(w) result := map[string]string{} val, err := service.NewGetSystemTimeInfo().GetInfo() if nil != err { return model.GetErrorObjDtoJson(err) } result["time"] = val runTimeInfo, err1 := service.NewGetSystemRunTimeInfo().GetInfo() if nil != err1 { return model.GetErrorObjDtoJson(err1) } result["runtime"] = fmt.Sprintf("%d天 %d小时 %d分钟", runTimeInfo.Day, runTimeInfo.Hour, runTimeInfo.Min) hostname, err3 := os.Hostname() if nil != err3 { return model.GetErrorObjDtoJson(err3) } result["hostname"] = hostname ver, err2 := utils.CmdOutputNoLn("uname", "-r") if nil != err2 { return model.GetErrorObjDtoJson(err2) } result["kernel"] = ver return model.GetDataDtoJson(result) }) }
func (getSystemTimeInfoLinux *GetSystemTimeInfoLinux) GetInfo() (string, error) { osErr := getLinuxOSError() if nil != osErr { return "", osErr } return utils.CmdOutputNoLn("/bin/date") }
func (processTimerFuncHandleRestartCMSProc *processTimerFuncHandleRestartCMSProc) run(param interface{}) error { var cmdLine string = param.(string) getProcInfo := &getCMSProcessInfoLinux{} _, err := getProcInfo.GetInfo(cmdLine) if nil != err { return err } resp, err := utils.CmdOutputNoLn("ls", CMS_UNIX_DOMAIN_SOCKET) if nil != err { return err } if resp != CMS_UNIX_DOMAIN_SOCKET { return errors.New(fmt.Sprintf("没有找到文件%s", CMS_UNIX_DOMAIN_SOCKET)) } return nil }