merge-requests/1/merge
Matthew 2019-11-09 23:46:21 -05:00
parent adf1240116
commit 6af603b96b
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
2 changed files with 3 additions and 2 deletions

View File

@ -32,7 +32,7 @@ export default class Whois extends Command {
embed.addField('Created By', `<@${this.client.users.get(account.createdBy).id}>`, true); embed.addField('Created By', `<@${this.client.users.get(account.createdBy).id}>`, true);
embed.addField('Created At', moment(account.createdAt).format('dddd, MMMM Do YYYY, h:mm:ss A'), true); embed.addField('Created At', moment(account.createdAt).format('dddd, MMMM Do YYYY, h:mm:ss A'), true);
const cpuUsage = await this.client.util.exec(`top -b -n 1 -u ${account.username} | awk 'NR>7 { sum += $9; } END { print sum; }'`); const cpuUsage = await this.client.util.exec(`top -b -n 1 -u ${account.username} | awk 'NR>7 { sum += $9; } END { print sum; }'`);
embed.addField('CPU Usage', `${cpuUsage.split('\n')[0]}%`, true); embed.addField('CPU Usage', cpuUsage ? `${cpuUsage.split('\n')[0]}%` : '0%', true);
embed.addField('Memory', dataConversion(Number(await this.client.util.exec(`memory ${account.username}`))), true); embed.addField('Memory', dataConversion(Number(await this.client.util.exec(`memory ${account.username}`))), true);
const data = await this.client.redis.get(`storage-${account.username}`) ? dataConversion(Number(await this.client.redis.get(`storage-${account.username}`))) : 'N/A'; const data = await this.client.redis.get(`storage-${account.username}`) ? dataConversion(Number(await this.client.redis.get(`storage-${account.username}`))) : 'N/A';
embed.addField('Storage', data, true); embed.addField('Storage', data, true);

View File

@ -2,7 +2,7 @@
import fs from 'fs-extra'; import fs from 'fs-extra';
import { Client } from '..'; import { Client } from '..';
export default function storage(client: Client) { export default async function storage(client: Client) {
const main = async () => { const main = async () => {
const accounts = await client.db.Account.find(); const accounts = await client.db.Account.find();
for (const account of accounts) { for (const account of accounts) {
@ -18,6 +18,7 @@ export default function storage(client: Client) {
await client.redis.set(`storage-${account.username}`, bytes); await client.redis.set(`storage-${account.username}`, bytes);
} }
}; };
await main();
setInterval(async () => { setInterval(async () => {
await main(); await main();
}, 900000); }, 900000);