var util = require("util"); var os = require("os"); var showMem = function () { var mem = process.memoryUsage(); var format = function (bytes) { return (bytes / 1024 / 1024).toFixed(2) + 'MB'; }; var time = new Date(); console.log('现在时间:' + time); console.log('Porcess: heapTotal ' + format(mem.heapTotal) + ' heapUsed ' + format(mem.heapUsed) + ' rss ' + format(mem.rss)); console.log( 'nodejs version: ' + process.version); //获取nodejs版本号 console.log(os.platform()); console.log(os.release()); console.log(os.tmpdir()); console.log(((os.totalmem()) / 1024 / 1024) + 'MB'); console.log(os.type()); console.log(os.uptime() / 60 / 60); var upTime = '已开机:'; var upTimeTotalSecond = os.uptime(); var upHour = parseInt(os.uptime() / 60 / 60); var upMinute = parseInt((upTimeTotalSecond - upHour * 60 * 60) / 60); var upSecond = parseInt(upTimeTotalSecond - upHour * 60 * 60 - upMinute * 60); upTime = upTime + upHour + '小时' + upMinute + '分钟' + upSecond + '秒'; console.log(upTime); console.log('------------------------------------------------------ '); }; showMem(); // setInterval(showMem,3 * 1000);