getUserAgent() { const packageUserAgent = `${packageJSON.name}/${packageJSON.version}` const platformUserAgent = `(${os.arch()}-${os.type()}-${os.release()}; Node.js,Version=${process.version})` const userAgent = `${packageUserAgent} ${platformUserAgent}` return userAgent }
const getOsInfo = () => { return { uptime: os.uptime(), type: os.type(), release: os.release(), hostname: os.hostname(), arch: os.arch(), platform: os.platform(), user: getUserInfo() }; }
function displayResults (results) { if (quiet === false) console.log('==========') const benchNames = Object.keys(results) for (var i = 0; i < benchNames.length; i += 1) { console.log(`${benchNames[i].toUpperCase()} benchmark averages`) const benchmark = results[benchNames[i]] const loggers = Object.keys(benchmark) for (var j = 0; j < loggers.length; j += 1) { var logger = benchmark[loggers[j]] var average = sum(logger) / logger.length console.log(`${loggers[j]} average: ${average.toFixed(3)}ms`) } } if (quiet === false) { console.log('==========') console.log( `System: ${type()}/${platform()} ${arch()} ${release()}`, `~ ${cpus()[0].model} (cores/threads: ${cpus().length})` ) } }
const infos = { hostname: os.hostname(), type: os.type(), platform: os.platform(), arch: os.arch(),
version: packageInfo.version, os: { type: os.type(), version: os.release() },
let host = server.host; let cmd = os.type() === 'Windows_NT' ? `netstat -ano | %windir%\\system32\\find.exe ` : `netstat -tln | grep `; if (!utils.isLocal(host)) { cmd = 'ssh ' + host + ' ' + cmd; p = os.type() === 'Windows_NT' ? `"${p}"` as any : p exec(cmd + p, function (err, stdout, stderr) { if (stdout || stderr) { } else { p = server.clientPort; p = os.type() === 'Windows_NT' ? `"${p}"` as any : p exec(cmd + p, function (err, stdout, stderr) { if (stdout || stderr) {
const getApp = function() { return { osName: type(), osVersion: osName(), freeMemory: freemem(), totalMemory: totalmem(), } }
function errorMessage () { // copied from npm's lib/utils/error-handler.js var os = require('os') log.error('System', os.type() + ' ' + os.release()) log.error('command', process.argv .map(JSON.stringify).join(' ')) log.error('cwd', process.cwd()) log.error('node -v', process.version) log.error('node-gyp -v', 'v' + prog.package.version) }
app.get('/info', function (req, res) { var info = { client: Config.Discogs.UserAgent, uptime: os.uptime(), cpu: os.cpus(), archicture: os.arch(), type: os.type() }; res.send(pretty(info)); });
function sanitizeFN ( name ) { // after https://github.com/pillarjs/encodeurl if ( os.type() == 'Windows_NT' ) { return String( name ).replace( sanitizeRE, encodeURIComponent ).replace( /%/g, '~' ) } else { return name } }
// Node native module function logOsData(){ console.log("--- OS INFO"); console.log(`Architecture: ${ os.arch() }`); console.log(`Total memory: ${ os.totalmem() }`); console.log(`Free memory: ${ os.freemem()} `); console.log(`Platform: ${ os.platform()} `); console.log(`Type: ${ os.type()} `); console.log(`Uptime: ${ os.uptime()} `); // console.log(`CPUs: ${ os.cpus() }`); // console.log(`User info: ${ os.userInfo()} `); // console.log(os); }
/** * attach the output of 'top' to the document * @param {String} docName * @param {String} docRev * @return {Promise} - fulfilled with new document revision */ function addAttachment (docName, docRev) { const args = os.type() === 'Darwin' ? ['-l', '1'] : ['-b', '-n', '1'] const stream = spawn('top', args).stdout const attName = `top-${Date.now()}.txt` const attContentType = 'text/plain' return db.addAttachment(dbName, docName, attName, docRev, attContentType, stream) .then(response => response.data.rev) }
function getSystemInfo() { let systemInfo = {agentVersion: packageJson.version || ''}; try { systemInfo.hostName = os.hostname(); systemInfo.node = {versions: process.versions}, systemInfo.os = { type: os.type(), release: os.release(), platform: os.platform(), }; } catch (error) { systemInfo.error = `failed getting system info: ${error}`; } return systemInfo; }
const infos = { hostname: os.hostname(), type: os.type(), platform: os.platform(), arch: os.arch(),