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