Perfs size reduction
MODIFY
src/storage/mongodb/MongoDBStorage.ts
src/storage/mongodb/MongoDBStorage.ts
@@ -159,6 +159,7 @@ export default class MongoDBStorage {
await this.handleIndexesInCollection(tenantID, 'chargingstations', [
{ fields: { coordinates: '2dsphere' } },
{ fields: { deleted: 1, issuer: 1 } },
+ { fields: { 'connectors.status': 1 } },
]);
await Logging.logDebug({
tenantID: tenantID,
@@ -335,7 +336,7 @@ export default class MongoDBStorage {
try {
await this.db.createCollection(tenantCollectionName);
} catch (error) {
- console.error(`>>>>> Error in creating collection '${tenantCollectionName}': ${error.message}`);
+ console.error(`>>>>> Error in creating collection '${tenantCollectionName}': ${error.message as string}`);
}
}
// Indexes?
@@ -350,11 +351,13 @@ export default class MongoDBStorage {
const foundIndex = indexes.find((index) => this.buildIndexName(index.fields) === databaseIndex.name);
if (!foundIndex) {
if (Utils.isDevelopmentEnv()) {
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
console.log(`Drop index ${databaseIndex.name} on collection ${tenantID}.${name}`);
}
try {
await this.db.collection(tenantCollectionName).dropIndex(databaseIndex.key);
} catch (error) {
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
console.error(`>>>>> Error in dropping index '${databaseIndex.name}' in '${tenantCollectionName}': ${error.message}`);
}
}
@@ -370,7 +373,7 @@ export default class MongoDBStorage {
// eslint-disable-next-line @typescript-eslint/await-thenable
await this.db.collection(tenantCollectionName).createIndex(index.fields, index.options);
} catch (error) {
- console.error(`>>>>> Error in creating index '${JSON.stringify(index.fields)}' with options '${JSON.stringify(index.options)}' in '${tenantCollectionName}': ${error.message}`);
+ console.error(`>>>>> Error in creating index '${JSON.stringify(index.fields)}' with options '${JSON.stringify(index.options)}' in '${tenantCollectionName}': ${error.message as string}`);
}
}
}

MODIFY
src/storage/mongodb/PerformanceStorage.ts
src/storage/mongodb/PerformanceStorage.ts
@@ -12,10 +12,10 @@ export default class PerformanceStorage {
Utils.convertToObjectID(performanceRecord.tenantID) : Constants.DEFAULT_TENANT,
timestamp: Utils.convertToDate(performanceRecord.timestamp),
host: performanceRecord.host,
- cpusInfo: performanceRecord.cpusInfo,
+ numberOfCPU: performanceRecord.numberOfCPU,
+ modelOfCPU: performanceRecord.modelOfCPU,
memoryTotalGb: performanceRecord.memoryTotalGb,
memoryFreeGb: performanceRecord.memoryFreeGb,
- networkInterface: performanceRecord.networkInterface,
loadAverageLastMin: performanceRecord.loadAverageLastMin,
process: performanceRecord.process,
processMemoryUsage: performanceRecord.processMemoryUsage,

MODIFY
src/types/Performance.ts
src/types/Performance.ts
-import os, { CpuInfo } from 'os';
-
import { ServerAction } from './Server';
export default interface PerformanceRecord {
@@ -10,13 +8,13 @@ export default interface PerformanceRecord {
sizeKb?: number;
host: string;
process: string;
- processMemoryUsage: NodeJS.MemoryUsage,
- processCPUUsage: NodeJS.CpuUsage,
- cpusInfo: CpuInfo[],
+ processMemoryUsage: NodeJS.MemoryUsage;
+ processCPUUsage: NodeJS.CpuUsage;
+ numberOfCPU: number;
+ modelOfCPU: string;
memoryTotalGb: number;
memoryFreeGb: number;
- loadAverageLastMin: number,
- networkInterface: NodeJS.Dict<os.NetworkInterfaceInfo[]>,
+ loadAverageLastMin: number;
numberOfChargingStations?: number;
source: string;
module: string;

MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
@@ -1492,6 +1492,7 @@ export default class Utils {
module: string; method: string; action: ServerAction|string; group?: PerformanceRecordGroup;
httpUrl?: string; httpMethod?: string; httpCode?: number; chargingStationID?: string,
}): PerformanceRecord {
+ const cpuInfo = os.cpus();
return {
tenantID: params.tenantID,
timestamp: new Date(),
@@ -1501,11 +1502,11 @@ export default class Utils {
process: cluster.isWorker ? 'worker ' + cluster.worker.id.toString() : 'master',
processMemoryUsage: process.memoryUsage(),
processCPUUsage: process.cpuUsage(),
- cpusInfo: os.cpus(),
+ numberOfCPU: cpuInfo.length,
+ modelOfCPU: cpuInfo.length > 0 ? cpuInfo[0].model : '',
memoryTotalGb: Utils.createDecimal(os.totalmem()).div(Constants.ONE_BILLION).toNumber(),
memoryFreeGb: Utils.createDecimal(os.freemem()).div(Constants.ONE_BILLION).toNumber(),
loadAverageLastMin: os.loadavg()[0],
- networkInterface: os.networkInterfaces(),
numberOfChargingStations: global.centralSystemJsonServer?.getNumberOfJsonConnections(),
source: params.source,
module: params.module,

Perfs size reduction