Skip to content

Commit

Permalink
Clean naming conventions used in stats reporting (#30)
Browse files Browse the repository at this point in the history
* clean orgStats naming

* factor out org stats

* have space report show running and stopped app instances

* include space services count... but to be honest, its not necessary we're going to completely redo the output
  • Loading branch information
aegershman authored Nov 24, 2019
1 parent 3289405 commit f0833c0
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,12 @@ func (orgs Orgs) Stats(c chan OrgStats) {
runningUniqueApps := org.RunningAppsCount()
stoppedUniqueApps := totalUniqueApps - runningUniqueApps

lAIs := org.AppInstancesCount()
rAIs := org.RunningAppInstancesCount()
sAIs := lAIs - rAIs
appInstancesCount := org.AppInstancesCount()
runningAppInstancesCount := org.RunningAppInstancesCount()
stoppedAppInstancesCount := appInstancesCount - runningAppInstancesCount

servicesCount := org.ServicesCount()

c <- OrgStats{
Name: org.Name,
MemoryQuota: org.MemoryQuota,
Expand All @@ -374,10 +377,10 @@ func (orgs Orgs) Stats(c chan OrgStats) {
AppsCount: totalUniqueApps,
RunningAppsCount: runningUniqueApps,
StoppedAppsCount: stoppedUniqueApps,
AppInstancesCount: lAIs,
RunningAppInstancesCount: rAIs,
StoppedAppInstancesCount: sAIs,
ServicesCount: org.ServicesCount(),
AppInstancesCount: appInstancesCount,
RunningAppInstancesCount: runningAppInstancesCount,
StoppedAppInstancesCount: stoppedAppInstancesCount,
ServicesCount: servicesCount,
}
}
close(c)
Expand All @@ -393,13 +396,14 @@ func (report *Report) String() string {
totalServiceInstances := 0

const (
orgOverviewMsg = "Org %s is consuming %d MB of %d MB.\n"
spaceOverviewMsg = "\tSpace %s is consuming %d MB memory (%d%%) of org quota.\n"
spaceCanonicalAppInstancesMsg = "\t\t%d canonical app instances\n"
spaceBillableAppInstancesMsg = "\t\t%d billable app instances (includes AIs and billable SIs, like SCS)\n"
spaceUniqueAppGuidsMsg = "\t\t%d unique app_guids: %d running %d stopped\n"
spaceServiceSuiteMsg = "\t\t%d service instances of type Service Suite (mysql, redis, rmq)\n"
reportSummaryMsg = "[WARNING: THIS REPORT SUMMARY IS MISLEADING AND INCORRECT. IT WILL BE FIXED SOON.] You have deployed %d apps across %d org(s), with a total of %d app instances configured. You are currently running %d apps with %d app instances and using %d service instances of type Service Suite.\n"
orgOverviewMsg = "Org %s is consuming %d MB of %d MB.\n"
spaceOverviewMsg = "\tSpace %s is consuming %d MB memory (%d%%) of org quota.\n"
spaceAppInstancesMsg = "\t\t%d app instances: %d running %d stopped\n"
spaceBillableAppInstancesMsg = "\t\t%d billable app instances (includes AIs and billable SIs, like SCS)\n"
spaceUniqueAppGuidsMsg = "\t\t%d unique app_guids: %d running %d stopped\n"
spaceServiceMsg = "\t\t%d service instances total\n"
spaceServiceSuiteMsg = "\t\t%d service instances of type Service Suite (mysql, redis, rmq)\n"
reportSummaryMsg = "[WARNING: THIS REPORT SUMMARY IS MISLEADING AND INCORRECT. IT WILL BE FIXED SOON.] You have deployed %d apps across %d org(s), with a total of %d app instances configured. You are currently running %d apps with %d app instances and using %d service instances of type Service Suite.\n"
)

chOrgStats := make(chan OrgStats, len(report.Orgs))
Expand All @@ -418,12 +422,14 @@ func (report *Report) String() string {
response.WriteString(fmt.Sprintf(spaceOverviewMsg, spaceState.Name, spaceState.ConsumedMemory, spaceMemoryConsumedPercentage))
}

response.WriteString(fmt.Sprintf(spaceCanonicalAppInstancesMsg, spaceState.AppInstancesCount))
response.WriteString(fmt.Sprintf(spaceAppInstancesMsg, spaceState.AppInstancesCount, spaceState.RunningAppInstancesCount, spaceState.StoppedAppInstancesCount))

response.WriteString(fmt.Sprintf(spaceBillableAppInstancesMsg, spaceState.BillableAppInstancesCount))

response.WriteString(fmt.Sprintf(spaceUniqueAppGuidsMsg, spaceState.AppsCount, spaceState.RunningAppsCount, spaceState.StoppedAppsCount))

response.WriteString(fmt.Sprintf(spaceServiceMsg, spaceState.ServicesCount))

response.WriteString(fmt.Sprintf(spaceServiceSuiteMsg, spaceState.ServicesSuiteForPivotalPlatformCount))

}
Expand Down

0 comments on commit f0833c0

Please sign in to comment.