Class DeviceInfo#getSystemUsageInfo
DeviceInfo
- Defined in: deviceInfo.js
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
DeviceInfo#getSystemUsageInfo(successCallback, errorCallback, options)
Gets device usage information.
|
Class Detail
DeviceInfo#getSystemUsageInfo(successCallback, errorCallback, options)
Gets device usage information. Usage information includes cpu and memory status.
// Javascript code
function getSystemUsageInfo() {
function successCb(cbObject) {
console.log("cbObject : " + JSON.stringify(cbObject));
console.log("memory.total : " + cbObject.memory.total);
console.log("memory.free : " + cbObject.memory.free);
for (var i in cbObject.cpus) {
console.log("cpu.model " + cbObject.cpus[i].model);
console.log("cpu.times.user " + cbObject.cpus[i].times.user);
console.log("cpu.times.nice " + cbObject.cpus[i].times.nice);
console.log("cpu.times.sys " + cbObject.cpus[i].times.sys);
console.log("cpu.times.idle " + cbObject.cpus[i].times.idle);
console.log("cpu.times.irq " + cbObject.cpus[i].times.irq);
}
// Do something
}
function failureCb(cbObject) {
var errorCode = cbObject.errorCode;
var errorText = cbObject.errorText;
console.log ("Error Code [" + errorCode + "]: " + errorText);
}
var deviceInfo = new DeviceInfo();
var options = {cpus : true, memory : true};
deviceInfo.getSystemUsageInfo(successCb, failureCb, options);
}
- Parameters:
- {Function} successCallback
- success callback function.
- {Function} errorCallback
- failure callback function.
- {Object} options
Property Type Description Required cpus Boolean true to get CPU information, false otherwise. optional memory Boolean true to get memory information, false otherwise. optional
- Since:
- 1.2
- Returns:
- {Object}
Property Type Description Available cpus Array Array of objects containing information about each CPU/core installed: model, and times
(an object containing the number of milliseconds the CPU/core spent in: user, nice, sys, idle, and irq).optional memory Object Object containing total and free member fields.
'total' is total amount of system memory in bytes and 'free' is amount of free memory in bytes.optional - See:
- DeviceInfo.getPlatformInfo()