badmfck-api-server 1.5.8 → 1.5.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ interface IStatObject {
7
7
  apiErrors: Map<string, number>;
8
8
  }
9
9
  interface ISystemStat {
10
- cpuUsage: number;
10
+ cpuUsage: any;
11
11
  memoryTotal: number;
12
12
  memoryUsage: any;
13
13
  }
@@ -33,9 +33,9 @@ export declare class Monitor extends BaseEndpoint {
33
33
  netlog(req: HTTPRequestVO): Promise<TransferPacketVO<any>>;
34
34
  metrics(req: HTTPRequestVO): Promise<TransferPacketVO<any>>;
35
35
  serverStat(req: HTTPRequestVO): Promise<TransferPacketVO<any>>;
36
- mapToKeyValue(map: Map<string, number>): {
36
+ mapToKeyValue(map: Map<string, string | number>): {
37
37
  name: string;
38
- value: number;
38
+ value: string | number;
39
39
  }[];
40
40
  }
41
41
  export {};
@@ -177,12 +177,24 @@ class Monitor extends BaseEndpoint_1.BaseEndpoint {
177
177
  return { data: { stat: result, date: +date } };
178
178
  }
179
179
  async serverStat(req) {
180
+ const date = new Date();
181
+ const di = this.getDateIndex(date);
182
+ const stat = this.systemStat.get(di);
183
+ if (!stat)
184
+ return { data: [] };
185
+ let result = [];
186
+ for (let minutes of stat) {
187
+ result.push({
188
+ m: minutes[0],
189
+ mt: minutes[1].memoryTotal,
190
+ mu: minutes[1].memoryUsage,
191
+ cu: minutes[1].cpuUsage,
192
+ });
193
+ }
180
194
  return { data: {
181
- memory: {
182
- cpus: os_1.default.cpus(),
183
- uptime: process.uptime,
184
- osUptime: os_1.default.uptime
185
- }
195
+ uptime: process.uptime,
196
+ osUptime: os_1.default.uptime,
197
+ stat: result
186
198
  } };
187
199
  }
188
200
  mapToKeyValue(map) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "badmfck-api-server",
3
- "version": "1.5.8",
3
+ "version": "1.5.9",
4
4
  "description": "Simple API http server based on express",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",