/*
Uptime proxies linux system command for 'uptime'.
*/
969443
func Uptime() string {
	kon := Console{Command: "uptime"}
	kon.Run()
	return strings.Fields(kon.StdOutput)[0]
}
447057
func (api *NFSAPI) SleepUntilUp(id int64, timeout time.Duration) error {
	handler := waitingForUpFunc(func() (hasUpDown, error) {
		return api.Read(id)
	}, 0)
	return blockingPoll(handler, timeout)
}
778559
func (d *DNSProvider) Timeout() (timeout, interval time.Duration) {
	return d.config.PropagationTimeout, d.config.PollingInterval
}
246220
func RunningTime(pid int) int64 {
	upTimeFile, err := os.Open("/proc/uptime")
	if err != nil {
		panic(err)
	}
	defer upTimeFile.Close()
	bs, err := ioutil.ReadAll(upTimeFile)
	if err != nil {
		panic(err)
	}
	//uptime is first paramater in uptime file
	upTime, err := strconv.ParseFloat(strings.Split(string(bs), " ")[0], 64)
	if err != nil {
		panic(err)
	}
	stat, err := os.Open("/proc/" + strconv.Itoa(pid) + "/stat")
	if err != nil {
		panic(err)
	}
	defer stat.Close()
	bs, err = ioutil.ReadAll(stat)
	if err != nil {
		panic(err)
	}
	//startTime is 22nd paramater in the stat file
	startTime, err := strconv.ParseInt(strings.Split(string(bs), " ")[21], 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(upTime*1000) - int64(startTime*1000)/sc_clk_tck
}
735731
func (s *service) up() {
	s.active = true
	log.Infof("%v: %v service up", s.vserver, s)

	ncc := s.vserver.ncc
	if err := ncc.Dial(); err != nil {
		log.Fatalf("%v: failed to connect to NCC: %v", s.vserver, err)
	}
	defer ncc.Close()

	log.Infof("%v: adding IPVS service %v", s.vserver, s.ipvsSvc)
	if err := ncc.IPVSAddService(s.ipvsSvc); err != nil {
		log.Fatalf("%v: failed to add service %v: %v", s.vserver, s, err)
	}

	// Update destinations *after* the IPVS service exists.
	s.updateDests()
}
1272856
func (w *Wrapper) UpsertProxy(s services.Server) error {
	return w.Write.UpsertProxy(s)
}
101437
func (d *NetworkDevice) isUp(times int) bool {
	for i := 0; i < times; i++ {
		if d._isUp() {
			return true
		}
	}
	return false
}
1351046
func (c *config) GetTime(key string, args ...interface{}) time.Time {
	val, err := c.GetTimeErr(key, args...)
	if err != nil {
		c.errorHandler(key, err, args...)
	}
	return val
}
667023
func NewSystemTime(TIME_UNIX_USEC uint64, TIME_BOOT_MS uint32) *SystemTime {
	m := SystemTime{}
	m.TIME_UNIX_USEC = TIME_UNIX_USEC
	m.TIME_BOOT_MS = TIME_BOOT_MS
	return &m
}
1124082
func Deserialize(p []byte) u.Uptime {
	flatUp := structs.GetRootAsUptime(p, 0)
	var up u.Uptime
	up.Timestamp = flatUp.Timestamp()
	up.Total = flatUp.Total()
	up.Idle = flatUp.Idle()
	return up
}
53070
func Get() (p []byte, err error) {
	var u up.Uptime
	err = u.Get()
	if err != nil {
		return nil, err
	}
	return Serialize(&u), nil
}
1029472
func (vr *VoiceResponse) DateUpdatedAsTime() (time.Time, error) {
	return time.Parse(time.RFC1123Z, vr.DateUpdated)
}
381345
func Get() (p []byte, err error) {
	var u up.Uptime
	err = u.Get()
	if err != nil {
		return nil, err
	}
	return json.Marshal(&u)
}
1133245
func DiskRestGetUsage(context *gin.Context) {
	body, err := disk.ServiceGetUsage()
	util.RestHandleResponse(context, body, err)
}
93148
func (f *TimeFuncs) Unix(in interface{}) (gotime.Time, error) {
	sec, nsec, err := parseNum(in)
	if err != nil {
		return gotime.Time{}, err
	}
	return gotime.Unix(sec, nsec), nil
}
370648
func (c *Client) UpsertProxy(s services.Server) error {
	data, err := services.GetServerMarshaler().MarshalServer(s)
	if err != nil {
		return trace.Wrap(err)
	}
	args := &upsertServerRawReq{
		Server: data,
	}
	_, err = c.PostJSON(c.Endpoint("proxies"), args)
	return trace.Wrap(err)
}
37032
func getPeerUptimes(serverInfo []ServerInfo) time.Duration {
	// In a single node Erasure or FS backend setup the uptime of
	// the setup is the uptime of the single minio server
	// instance.
	if !globalIsDistXL {
		return UTCNow().Sub(globalBootTime)
	}

	var times []time.Duration

	for _, info := range serverInfo {
		if info.Error != "" {
			continue
		}
		times = append(times, info.Data.Properties.Uptime)
	}

	// Sort uptimes in chronological order.
	sort.Sort(uptimes(times))

	// Return the latest time as the uptime.
	return times[0]
}