Skip to content

Commit

Permalink
Return Date for idle and offline Account and Domain dates.
Browse files Browse the repository at this point in the history
Properly invoke date fetchers in monitoring code.
  • Loading branch information
Misterblue committed Nov 2, 2020
1 parent b6f928c commit a7be99a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Entities/Accounts.ts
Expand Up @@ -182,12 +182,12 @@ export const Accounts = {
return false;
},
// Return the ISODate when an account is considered offline
dateWhenNotOnline(): string {
dateWhenNotOnline(): Date {
const whenOffline = new Date(
Date.now()
- (Config["metaverse-server"]["heartbeat-seconds-until-offline"] * 1000)
);
return whenOffline.toISOString();
return whenOffline;
},
// getter property that is 'true' if the user is a grid administrator
isAdmin(pAcct: AccountEntity): boolean {
Expand Down
4 changes: 2 additions & 2 deletions src/Entities/Domains.ts
Expand Up @@ -108,9 +108,9 @@ export const Domains = {
new GenericFilter({ 'id': pEntity.id }), pFields);
},
// Return the Date when an domain is considered inactive
dateWhenNotActive(): string {
dateWhenNotActive(): Date {
const notActiveTime = new Date(Date.now() - 1000 * Config["metaverse-server"]["domain-seconds-until-offline"]);
return notActiveTime.toISOString();
return notActiveTime;
},
// Return 'true' if the passed string could be a domainId. Used as a precheck before querying the Db.
// For the moment, do a simple check to see if it is probably a GUID.
Expand Down
4 changes: 2 additions & 2 deletions src/Monitoring/StatsMetaverse.ts
Expand Up @@ -37,7 +37,7 @@ export class StatsMetaverse extends Stat {
// Count of all accounts that are sending heartbeats
const totalOnline = new ValueStat('totalOnline', 'metaverse', 'count', async (stat) => {
const numOnline = await Accounts.accountCount(
new GenericFilter( { 'timeOfLastHeartbeat': { '$gte': Accounts.dateWhenNotOnline }})
new GenericFilter( { 'timeOfLastHeartbeat': { '$gte': Accounts.dateWhenNotOnline() }})
);
Logger.debug(`StatsMetaverse.totalOnline: counting ${numOnline}`);
stat.Event(numOnline);
Expand Down Expand Up @@ -80,7 +80,7 @@ export class StatsMetaverse extends Stat {
// Number of domains that are sending heartbeats
const activeDomains = new ValueStat('activeDomains', 'metaverse', 'count', async (stat) => {
const numDomains = await Domains.domainCount(
new GenericFilter( { 'timeOfLastHeartbeat': { '$gte': Domains.dateWhenNotActive }})
new GenericFilter( { 'timeOfLastHeartbeat': { '$gte': Domains.dateWhenNotActive() }})
);
stat.Event(numDomains);
});
Expand Down

0 comments on commit a7be99a

Please sign in to comment.