top.js 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. 'use strict';
  2. const moment = require('moment');
  3. const Schema = require('mongoose').Schema;
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. // top表
  6. const TopSchema = {
  7. pid: { type: String, required: false, maxLength: 200 }, // 信息ID
  8. user: { type: String, required: false, maxLength: 500 }, // 用户ID
  9. pr: { type: String, required: false }, // 进程的调度优先级
  10. ni: { type: String, required: false }, // 进程的nice值
  11. virt: { type: String, required: false }, // 进程使用的虚拟内存
  12. res: { type: String, required: false }, // 驻留内存大小
  13. shr: { type: String, required: false }, // 共享内存
  14. s: { type: String, required: false }, // 进程的状态
  15. cpu: { type: String, required: false }, // CPU时间百分比
  16. mem: { type: String, required: false }, // 可用物理内存百分比
  17. time: { type: String, required: false, maxLength: 100 }, // 任务启动后到现在所使用的全部CPU时间
  18. command: { type: String, required: false, maxLength: 100 }, // 运行进程所使用的命令
  19. date: { type: String, required: false, maxLength: 100, default: moment().format('YYYY-MM-DD') }, // 运行进程所使用的命令
  20. };
  21. const schema = new Schema(TopSchema, { toJSON: { virtuals: true } });
  22. schema.index({ id: 1 });
  23. schema.plugin(metaPlugin);
  24. module.exports = app => {
  25. const { mongoose } = app;
  26. return mongoose.model('Top', schema, 'top');
  27. };