func (self *ApierV1) GetCacheStats(attrs utils.AttrCacheStats, reply *utils.CacheStats) error { cs := new(utils.CacheStats) cs.Destinations = cache.CountEntries(utils.DESTINATION_PREFIX) cs.ReverseDestinations = cache.CountEntries(utils.REVERSE_DESTINATION_PREFIX) cs.RatingPlans = cache.CountEntries(utils.RATING_PLAN_PREFIX) cs.RatingProfiles = cache.CountEntries(utils.RATING_PROFILE_PREFIX) cs.Actions = cache.CountEntries(utils.ACTION_PREFIX) cs.ActionPlans = cache.CountEntries(utils.ACTION_PLAN_PREFIX) cs.SharedGroups = cache.CountEntries(utils.SHARED_GROUP_PREFIX) cs.DerivedChargers = cache.CountEntries(utils.DERIVEDCHARGERS_PREFIX) cs.LcrProfiles = cache.CountEntries(utils.LCR_PREFIX) cs.Aliases = cache.CountEntries(utils.ALIASES_PREFIX) cs.ReverseAliases = cache.CountEntries(utils.REVERSE_ALIASES_PREFIX) cs.ResourceLimits = cache.CountEntries(utils.ResourceLimitsPrefix) if self.CdrStatsSrv != nil { var queueIds []string if err := self.CdrStatsSrv.Call("CDRStatsV1.GetQueueIds", 0, &queueIds); err != nil { return utils.NewErrServerError(err) } cs.CdrStats = len(queueIds) } if self.Users != nil { var ups engine.UserProfiles if err := self.Users.Call("UsersV1.GetUsers", &engine.UserProfile{}, &ups); err != nil { return utils.NewErrServerError(err) } cs.Users = len(ups) } *reply = *cs return nil }
func (self *ApierV1) GetCacheStats(attrs utils.AttrCacheStats, reply *utils.CacheStats) error { cs := new(utils.CacheStats) cs.Destinations = engine.CacheCountEntries(utils.DESTINATION_PREFIX) cs.RatingPlans = engine.CacheCountEntries(utils.RATING_PLAN_PREFIX) cs.RatingProfiles = engine.CacheCountEntries(utils.RATING_PROFILE_PREFIX) cs.Actions = engine.CacheCountEntries(utils.ACTION_PREFIX) cs.ActionPlans = engine.CacheCountEntries(utils.ACTION_PLAN_PREFIX) cs.SharedGroups = engine.CacheCountEntries(utils.SHARED_GROUP_PREFIX) cs.DerivedChargers = engine.CacheCountEntries(utils.DERIVEDCHARGERS_PREFIX) cs.LcrProfiles = engine.CacheCountEntries(utils.LCR_PREFIX) cs.Aliases = engine.CacheCountEntries(utils.ALIASES_PREFIX) if self.CdrStatsSrv != nil { var queueIds []string if err := self.CdrStatsSrv.Call("CDRStatsV1.GetQueueIds", 0, &queueIds); err != nil { return utils.NewErrServerError(err) } cs.CdrStats = len(queueIds) } if self.Users != nil { var ups engine.UserProfiles if err := self.Users.Call("UsersV1.GetUsers", &engine.UserProfile{}, &ups); err != nil { return utils.NewErrServerError(err) } cs.Users = len(ups) } if loadHistInsts, err := self.AccountDb.GetLoadHistory(1, false); err != nil || len(loadHistInsts) == 0 { if err != nil { // Not really an error here since we only count in cache utils.Logger.Warning(fmt.Sprintf("ApierV1.GetCacheStats, error on GetLoadHistory: %s", err.Error())) } cs.LastLoadID = utils.NOT_AVAILABLE cs.LastRatingLoadID = utils.NOT_AVAILABLE cs.LastAccountingLoadID = utils.NOT_AVAILABLE cs.LastLoadTime = utils.NOT_AVAILABLE } else { cs.LastLoadID = loadHistInsts[0].LoadID cs.LastRatingLoadID = loadHistInsts[0].RatingLoadID cs.LastAccountingLoadID = loadHistInsts[0].AccountingLoadID cs.LastLoadTime = loadHistInsts[0].LoadTime.Format(time.RFC3339) } *reply = *cs return nil }