function IOStatMonitor (frequency) {
this.commandLine = "/usr/sbin/iostat -d -C -w " + frequency;
}
IOStatMonitor.prototype = new CommandMonitor();
IOStatMonitor.prototype.processLine = function (line)
{
// KB/t tps MB/s KB/t tps MB/s KB/t tps MB/s us sy id
// 20.06 5 0.09 9.70 0 0.00 10.67 0 0.00 4 3 92
// Take off leading and trailing spaces
line = line.replace(/^\s+/, "");
line = line.replace(/\s+$/, "");
// Look for a line of numbers
var match;
if ((match = line.match(/^(\s*[\d\.]+)+$/)) != null) {
var n = match[0].split(/\s+/);
if (n.length > 0 && n.length % 3 == 0) {
// Add up all the MB/s numbers
var mbps = 0.0;
for (var i = 2; i < n.length - 3; i += 3) {
mbps += parseFloat(n[i]);
}
// Grab the inverse of the CPU idle time and call it load
var load = 100 - parseInt(n[n.length - 1]);
// alert("disk io: " + mbps + ", load: " + load);
if (this.ioCallback != null) {
this.ioCallback(mbps);
}
if (this.loadCallback != null) {
this.loadCallback(load);
}
}
else {
alert("iostat format violation: expecting groups of three:");
alert(line);
}
}
}