Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getLoadAverages(){
return os.loadavg();
}
/**
var timerId = setInterval(function () {
var time = new Date().getTime()
var metrics = {}
metrics['collectd-sys-load'] = os.loadavg()
metrics['collectd-mem-free'] = os.freemem()
metrics['collectd-mem-used'] = os.totalmem() - os.freemem()
if (self.isLinux) {
linux.df(function dfMetrics (err, data) {
if (err) {
return logger.error('Error in df() for disk-usage metrics:' + err)
}
if (data && data.length > 0) {
data.forEach(function (disk) {
if (/\/dev\/.+/i.test(disk.filesystem)) {
var dev = disk.filesystem.split('/')[2]
var usedName = 'collectd5-disk-space-used\tdf-' + dev + '/df_complex-used'
var usedValue = disk.used * 1024
var freeName = 'collectd5-disk-space-free\tdf-' + dev + '/df_complex-free'
var freeValue = disk.available * 1024
agent.addMetrics({
var update = function() {
var properties = {
'loadavg': _.first(os.loadavg()),
'totalmem': os.totalmem(),
'freemem': os.freemem()
};
client.postEvent(program.event, properties)
.then(function() {
console.log("posted");
}, function(e) {
console.log("failed:", e.message || e);
});
};
var aggregateStats = function(callback) {
var masterMem = process.memoryUsage();
var stats = { all: {}, perApp: {}, aggregated: {} };
stats.aggregated = {
loadavg: os.loadavg(),
totalmem: os.totalmem(),
freemem: os.freemem(),
usedmem: (os.totalmem() - os.freemem()),
cpus: os.cpus().length,
processes: 1,
workers: 0,
rss: masterMem.rss,
heapTotal: masterMem.heapTotal,
heapUsed: masterMem.heapUsed
};
stats.perApp[ process.argv[1] ] = util._extend({ workers: 1}, process.memoryUsage());
for(var id in cluster.workers) {
stats.aggregated.processes++;
return Observable.interval(interval * 1000).timestamp().map(x => {
return {
load: loadavg(),
timestamp: new Date(x.timestamp),
sequenceNumber: x.value
};
});
}
setInterval(function () {
var memory = process.memoryUsage();
this.log.info('sample#node.rss=' + memory.rss, 'sample#node.heapTotal=' + memory.heapTotal, 'sample#node.heapUsed=' + memory.heapUsed);
var load = os.loadavg();
this.log.info('sample#os.load1=' + load[0], 'sample#os.load5=' + load[1], 'sample#os.load15=' + load[2]);
var bench = new Hoek.Bench();
setImmediate(function () {
self.log.info('sample#node.threadDelay=' + bench.elapsed());
});
}.bind(this), this.opts.statsInterval);
};
setInterval(function(){
var loadavg = os.loadavg();
var length = loadavg.length;
var avg = loadavg.reduce(function(total, num){ return total + num }, 0)/length;
var memory = 1 - os.freemem()/os.totalmem();
matrix.type('monitor').send({ 'cpu': avg, 'memory': (memory*100) });
},1000);
app.get('/os', function (req, res, next) {
var ret = {
hostname: os.hostname(),
platform: os.platform(),
type: os.type(),
loadAvg: os.loadavg(),
totalMemory: os.totalmem() / 1024 / 1024 / 1024,
freemem: os.freemem() / 1024 / 1024 / 1024,
usageMem: ((os.totalmem() - os.freemem()) / 1024 / 1024 / 1024),
cpus: os.cpus(),
tmpdir: os.tmpdir(),
networking: os.networkInterfaces(),
uptime: os.uptime(),
arch: os.arch(),
release: os.release(),
endianness: os.endianness(),
status: 'ok'
};
res.json(ret);
});
eventEmitter.on('tileFinished', function()
{
if (os.loadavg()[0] <= cpus+1)
{
if (y < tilecount-1)
y++;
else
{
if (x < tilecount-1)
{
x++;
y = 0;
}
else if (z < configuration.maxPrerender)
{
z++;
logger.info('Rendering zoom level '+z);
tilecount = Math.pow(2, z);
x = 0;