// GetStatusVars gets registered statistics status variables.
// TODO: Refactor this function to avoid repeated memory allocation / dealloc
353543
func GetStatusVars(vars *SessionVars) (map[string]*StatusVal, error) {
	statusVars := make(map[string]*StatusVal)
	statisticsListLock.RLock()
	defer statisticsListLock.RUnlock()

	for _, statistics := range statisticsList {
		vals, err := statistics.Stats(vars)
		if err != nil {
			return nil, err
		}

		for name, val := range vals {
			scope := statistics.GetScope(name)
			statusVars[name] = &StatusVal{Value: val, Scope: scope}
		}
	}

	return statusVars, nil
}
307077
func GetStats() (stats Stats, err error) {
	var memInfo memoryStatusEx
	memInfo.cbSize = uint32(unsafe.Sizeof(memInfo))
	if mem, _, _ := procGlobalMemoryStatusEx.Call(uintptr(unsafe.Pointer(&memInfo))); mem == 0 {
		err = syscall.GetLastError()
	} else {
		stats.TotalRAM = memInfo.ullTotalPhys
	}

	return stats, err
}
1126300
func getCoresFromStatus(adminCoresStatus *AdminCoresStatus) []string {
	serverCores := []string{}
	for coreName := range adminCoresStatus.Status {
		serverCores = append(serverCores, coreName)
	}
	return serverCores
}
879886
func GetSessionSystemVar(s *variable.SessionVars, key string) (string, error) {
	key = strings.ToLower(key)
	sysVar := variable.SysVars[key]
	if sysVar == nil {
		return "", variable.UnknownSystemVar
	}
	sVal, ok := s.Systems[key]
	if ok {
		return sVal, nil
	}
	if sysVar.Scope&variable.ScopeGlobal == 0 {
		// None-Global variable can use pre-defined default value.
		return sysVar.Value, nil
	}
	gVal, err := s.GlobalVarsAccessor.GetGlobalSysVar(key)
	if err != nil {
		return "", errors.Trace(err)
	}
	s.Systems[key] = gVal
	return gVal, nil
}
1221929
func (mg *MailgunImpl) GetStats(ctx context.Context, events []string, opts *GetStatOptions) ([]Stats, error) {
	r := newHTTPRequest(generateApiUrl(mg, statsTotalEndpoint))

	if opts != nil {
		if !opts.Start.IsZero() {
			r.addParameter("start", opts.Start.Format(iso8601date))
		}
		if !opts.End.IsZero() {
			r.addParameter("end", opts.End.Format(iso8601date))
		}
		if opts.Resolution != "" {
			r.addParameter("resolution", string(opts.Resolution))
		}
		if opts.Duration != "" {
			r.addParameter("duration", opts.Duration)
		}
	}

	for _, e := range events {
		r.addParameter("event", e)
	}

	r.setClient(mg.Client())
	r.setBasicAuth(basicAuthUser, mg.APIKey())

	var res statsTotalResponse
	err := getResponseFromJSON(ctx, r, &res)
	if err != nil {
		return nil, err
	} else {
		return res.Stats, nil
	}
}
46615
func NewGetStatus(ctx *middleware.Context, handler GetStatusHandler) *GetStatus {
	return &GetStatus{Context: ctx, Handler: handler}
}
928666
func (pgs *PipelinesService) GetStatus(ctx context.Context, name string, offset int) (ps *PipelineStatus, resp *APIResponse, err error) {
	ps = &PipelineStatus{}
	_, resp, err = pgs.client.getAction(ctx, &APIClientRequest{
		Path:         fmt.Sprintf("pipelines/%s/status", name),
		ResponseBody: ps,
	})

	return
}
306736
func GetStats() (stats Stats, err error) {
	stats.TotalRAM, err = getHwMemsize()
	return stats, err
}
1126343
func (p *Pages) GetStatus() string {
	if p == nil || p.Status == nil {
		return ""
	}
	return *p.Status
}
911478
func GetStats(uuidPath string) (*Stats, error) {
	var bs Stats

	par := parser{uuidPath: uuidPath}

	// bcache stats

	// dir <uuidPath>
	par.setSubDir("")
	bs.Bcache.AverageKeySize = par.readValue("average_key_size")
	bs.Bcache.BtreeCacheSize = par.readValue("btree_cache_size")
	bs.Bcache.CacheAvailablePercent = par.readValue("cache_available_percent")
	bs.Bcache.Congested = par.readValue("congested")
	bs.Bcache.RootUsagePercent = par.readValue("root_usage_percent")
	bs.Bcache.TreeDepth = par.readValue("tree_depth")

	// bcache stats (internal)

	// dir <uuidPath>/internal
	par.setSubDir("internal")
	bs.Bcache.Internal.ActiveJournalEntries = par.readValue("active_journal_entries")
	bs.Bcache.Internal.BtreeNodes = par.readValue("btree_nodes")
	bs.Bcache.Internal.BtreeReadAverageDurationNanoSeconds = par.readValue("btree_read_average_duration_us")
	bs.Bcache.Internal.CacheReadRaces = par.readValue("cache_read_races")

	// bcache stats (period)

	// dir <uuidPath>/stats_five_minute
	par.setSubDir("stats_five_minute")
	bs.Bcache.FiveMin.Bypassed = par.readValue("bypassed")
	bs.Bcache.FiveMin.CacheHits = par.readValue("cache_hits")

	bs.Bcache.FiveMin.Bypassed = par.readValue("bypassed")
	bs.Bcache.FiveMin.CacheBypassHits = par.readValue("cache_bypass_hits")
	bs.Bcache.FiveMin.CacheBypassMisses = par.readValue("cache_bypass_misses")
	bs.Bcache.FiveMin.CacheHits = par.readValue("cache_hits")
	bs.Bcache.FiveMin.CacheMissCollisions = par.readValue("cache_miss_collisions")
	bs.Bcache.FiveMin.CacheMisses = par.readValue("cache_misses")
	bs.Bcache.FiveMin.CacheReadaheads = par.readValue("cache_readaheads")

	// dir <uuidPath>/stats_total
	par.setSubDir("stats_total")
	bs.Bcache.Total.Bypassed = par.readValue("bypassed")
	bs.Bcache.Total.CacheHits = par.readValue("cache_hits")

	bs.Bcache.Total.Bypassed = par.readValue("bypassed")
	bs.Bcache.Total.CacheBypassHits = par.readValue("cache_bypass_hits")
	bs.Bcache.Total.CacheBypassMisses = par.readValue("cache_bypass_misses")
	bs.Bcache.Total.CacheHits = par.readValue("cache_hits")
	bs.Bcache.Total.CacheMissCollisions = par.readValue("cache_miss_collisions")
	bs.Bcache.Total.CacheMisses = par.readValue("cache_misses")
	bs.Bcache.Total.CacheReadaheads = par.readValue("cache_readaheads")

	if par.err != nil {
		return nil, par.err
	}

	// bdev stats

	reg := path.Join(uuidPath, "bdev[0-9]*")
	bdevDirs, err := filepath.Glob(reg)
	if err != nil {
		return nil, err
	}

	bs.Bdevs = make([]BdevStats, len(bdevDirs))

	for ii, bdevDir := range bdevDirs {
		var bds = &bs.Bdevs[ii]

		bds.Name = filepath.Base(bdevDir)

		par.setSubDir(bds.Name)
		bds.DirtyData = par.readValue("dirty_data")

		// dir <uuidPath>/<bds.Name>/stats_five_minute
		par.setSubDir(bds.Name, "stats_five_minute")
		bds.FiveMin.Bypassed = par.readValue("bypassed")
		bds.FiveMin.CacheBypassHits = par.readValue("cache_bypass_hits")
		bds.FiveMin.CacheBypassMisses = par.readValue("cache_bypass_misses")
		bds.FiveMin.CacheHits = par.readValue("cache_hits")
		bds.FiveMin.CacheMissCollisions = par.readValue("cache_miss_collisions")
		bds.FiveMin.CacheMisses = par.readValue("cache_misses")
		bds.FiveMin.CacheReadaheads = par.readValue("cache_readaheads")

		// dir <uuidPath>/<bds.Name>/stats_total
		par.setSubDir("stats_total")
		bds.Total.Bypassed = par.readValue("bypassed")
		bds.Total.CacheBypassHits = par.readValue("cache_bypass_hits")
		bds.Total.CacheBypassMisses = par.readValue("cache_bypass_misses")
		bds.Total.CacheHits = par.readValue("cache_hits")
		bds.Total.CacheMissCollisions = par.readValue("cache_miss_collisions")
		bds.Total.CacheMisses = par.readValue("cache_misses")
		bds.Total.CacheReadaheads = par.readValue("cache_readaheads")
	}

	if par.err != nil {
		return nil, par.err
	}

	// cache stats

	reg = path.Join(uuidPath, "cache[0-9]*")
	cacheDirs, err := filepath.Glob(reg)
	if err != nil {
		return nil, err
	}
	bs.Caches = make([]CacheStats, len(cacheDirs))

	for ii, cacheDir := range cacheDirs {
		var cs = &bs.Caches[ii]
		cs.Name = filepath.Base(cacheDir)

		// dir is <uuidPath>/<cs.Name>
		par.setSubDir(cs.Name)
		cs.IOErrors = par.readValue("io_errors")
		cs.MetadataWritten = par.readValue("metadata_written")
		cs.Written = par.readValue("written")

		ps := par.getPriorityStats()
		cs.Priority = ps
	}

	if par.err != nil {
		return nil, par.err
	}

	return &bs, nil
}
885225
func getHostStatuses(w *rest.ResponseWriter, r *rest.Request, ctx *requestContext) {
	facade := ctx.getFacade()
	dataCtx := ctx.getDatastoreContext()

	values := r.URL.Query()

	var hostIDs []string
	if _, ok := values["hostId"]; ok {
		hostIDs = values["hostId"]
	} else {
		hosts, err := facade.GetReadHosts(dataCtx)
		if err != nil {
			restServerError(w, err)
			return
		}

		hostIDs = make([]string, len(hosts))
		for i, host := range hosts {
			hostIDs[i] = host.ID
		}
	}

	since := values.Get("since")
	var duration time.Duration
	if since == "" {
		duration = time.Hour
	} else {
		tint, err := strconv.ParseInt(since, 10, 64)
		if err != nil {
			restServerError(w, err)
			return
		}
		duration = time.Duration(tint) * time.Millisecond
	}

	statuses, err := facade.GetHostStatuses(dataCtx, hostIDs, time.Now().Add(-duration))
	if err != nil {
		restServerError(w, err)
		return
	}

	w.WriteJson(statuses)
}
941012
func (c *Controller) GetStatusModel() *models.ControllerStatus {
	c.mutex.RLock()
	defer c.mutex.RUnlock()

	status := &models.ControllerStatus{
		Name: c.name,
		UUID: strfmt.UUID(c.uuid),
		Configuration: &models.ControllerStatusConfiguration{
			ErrorRetry:     !c.params.NoErrorRetry,
			ErrorRetryBase: strfmt.Duration(c.params.ErrorRetryBaseDuration),
			Interval:       strfmt.Duration(c.params.RunInterval),
		},
		Status: &models.ControllerStatusStatus{
			SuccessCount:            int64(c.successCount),
			LastSuccessTimestamp:    strfmt.DateTime(c.lastSuccessStamp),
			FailureCount:            int64(c.failureCount),
			LastFailureTimestamp:    strfmt.DateTime(c.lastErrorStamp),
			ConsecutiveFailureCount: int64(c.consecutiveErrors),
		},
	}

	if c.lastError != nil {
		status.Status.LastFailureMsg = c.lastError.Error()
	}

	return status
}
37145
func (objMgr *ObjectManager) GetUpgradeStatus(statusType string) ([]UpgradeStatus, error) {
	var res []UpgradeStatus

	if statusType == "" {
		// TODO option may vary according to the WAPI version, need to
		// throw relevant  error.
		msg := fmt.Sprintf("Status type can not be nil")
		return res, errors.New(msg)
	}
	upgradestatus := NewUpgradeStatus(UpgradeStatus{Type: statusType})
	err := objMgr.connector.GetObject(upgradestatus, "", &res)

	return res, err
}
1330152
func (cmd *Cmd) GetVar(k string) (string, bool) {
	return cmd.context.GetVar(k)
}
485243
func (r *RoomService) GetStatistics(id string) (*RoomStatistics, *http.Response, error) {
	req, err := r.client.NewRequest("GET", fmt.Sprintf("room/%s/statistics", id), nil, nil)
	if err != nil {
		return nil, nil, err
	}

	roomStatistics := new(RoomStatistics)
	resp, err := r.client.Do(req, roomStatistics)
	if err != nil {
		return nil, resp, err
	}
	return roomStatistics, resp, nil
}
431983
func (m *RoundTripMetrics) GetStatusCodesCounts() map[int]int64 {
	sc := make(map[int]int64)
	for k, v := range m.statusCodes {
		if v.Count() != 0 {
			sc[k] = v.Count()
		}
	}
	return sc
}
343016
func (r Billing_Order) GetOrderStatuses() (resp []datatypes.Container_Billing_Order_Status, err error) {
	err = r.Session.DoRequest("SoftLayer_Billing_Order", "getOrderStatuses", nil, &r.Options, &resp)
	return
}