forked from engineering/cloudservices
fix memory checking issue
parent
0b08700140
commit
2cec8a45ae
|
@ -1,3 +1,4 @@
|
||||||
|
/* eslint-disable no-continue */
|
||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
import { Client } from '..';
|
import { Client } from '..';
|
||||||
import { RichEmbed } from '../class';
|
import { RichEmbed } from '../class';
|
||||||
|
@ -17,17 +18,12 @@ export default function memory(client: Client) {
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
try {
|
try {
|
||||||
const accounts = await client.db.Account.find();
|
const accounts = await client.db.Account.find();
|
||||||
console.log(accounts);
|
|
||||||
for (const acc of accounts) {
|
for (const acc of accounts) {
|
||||||
console.log(acc.username);
|
if (acc.root === true) continue;
|
||||||
console.log(acc.root);
|
|
||||||
if (acc.root === true) return;
|
|
||||||
// memory in bytes
|
// memory in bytes
|
||||||
const mem = Number(await client.util.exec(`memory ${acc.username}`)) * 1000;
|
const mem = Number(await client.util.exec(`memory ${acc.username}`)) * 1000;
|
||||||
console.log(mem);
|
|
||||||
// memory in megabytes
|
// memory in megabytes
|
||||||
const memoryConversion = mem / 1024 / 1024;
|
const memoryConversion = mem / 1024 / 1024;
|
||||||
console.log(memoryConversion);
|
|
||||||
let userLimits: { soft: number, hard: number };
|
let userLimits: { soft: number, hard: number };
|
||||||
if (acc.tier === 1) {
|
if (acc.tier === 1) {
|
||||||
userLimits = { soft: memoryLimits.TIER_1_SOFT, hard: memoryLimits.TIER_1_HARD };
|
userLimits = { soft: memoryLimits.TIER_1_SOFT, hard: memoryLimits.TIER_1_HARD };
|
||||||
|
@ -40,7 +36,6 @@ export default function memory(client: Client) {
|
||||||
/* if the user has exceeded their soft memory limit, which is the one described in the
|
/* if the user has exceeded their soft memory limit, which is the one described in the
|
||||||
resource limit guidelines, we'll inform staff.
|
resource limit guidelines, we'll inform staff.
|
||||||
*/
|
*/
|
||||||
console.log(memoryConversion, userLimits.soft, userLimits.hard);
|
|
||||||
if (memoryConversion >= userLimits.soft) {
|
if (memoryConversion >= userLimits.soft) {
|
||||||
client.signale.info(`RAM Soft Limit Reached | ${acc.username} | ${memoryConversion}/${userLimits.soft} MB`);
|
client.signale.info(`RAM Soft Limit Reached | ${acc.username} | ${memoryConversion}/${userLimits.soft} MB`);
|
||||||
const embed = new RichEmbed();
|
const embed = new RichEmbed();
|
||||||
|
|
Loading…
Reference in New Issue