this.broker.Promise.resolve()
.then(() => cpuUsage().then(res => {
this.set(METRIC.OS_CPU_UTILIZATION, res.avg);
try {
const cpus = os.cpus();
this.set(METRIC.OS_CPU_TOTAL, cpus.length);
this.set(METRIC.OS_CPU_USER, cpus.reduce((a,b) => a + b.times.user, 0));
this.set(METRIC.OS_CPU_SYSTEM, cpus.reduce((a,b) => a + b.times.sys, 0));
cpus.forEach((cpu, index) => {
this.set(METRIC.OS_CPU_INFO_MODEL, cpu.model, { index });
this.set(METRIC.OS_CPU_INFO_SPEED, cpu.speed, { index });
this.set(METRIC.OS_CPU_INFO_TIMES_USER, cpu.times.user, { index });
this.set(METRIC.OS_CPU_INFO_TIMES_SYS, cpu.times.sys, { index });
});
} catch(err) {
}
}))
.catch(() => {
})
.then(() => {
this.logger.debug(`Collected common metric values in ${duration.toFixed(3)} msec.`);
})