function renderPlugin_mdstatus(data) {
function raid_buildaction(data) {
var html = "", name = "", percent = 0;
if (data !== undefined) {
name = data['Name'];
if ((name !== undefined) && (parseInt(name) !== -1)) {
percent = Math.round(parseFloat(data['Percent']));
html += "
Current Action:" + String.fromCharCode(160) + name + "
";
html += '
';
html += "Finishing in:" + String.fromCharCode(160) + data['Time_To_Finish'] + String.fromCharCode(160) + data['Time_Unit'];
html += "
";
}
}
return html;
}
function raid_diskicon(data) {
var html = "";
var img = "", alt = "";
html += "";
switch (data["Status"]) {
case " ":
case "":
img = "harddriveok.png";
alt = "ok";
break;
case "F":
img = "harddrivefail.png";
alt = "fail";
break;
case "S":
img = "harddrivespare.png";
alt = "spare";
break;
case "W":
img = "harddrivewarn.png";
alt = "warning";
break;
default:
alert("--" + data["Status"] + "--");
img = "error.png";
alt = "error";
break;
}
html += "
";
html += "
" + data["Name"] + "";
html += "
";
return html;
}
if (data['Plugins']['Plugin_MDStatus'] !== undefined) {
$('#mdstatus').empty();
if (data['Plugins']['Plugin_MDStatus']['Supported_Types'] !== undefined) {
var stitems = items(data['Plugins']['Plugin_MDStatus']['Supported_Types']['Type']);
if (stitems.length > 0) {
var htmltypes = "Supported RAID-Types | ";
for (i = 0; i < stitems.length ; i++) {
htmltypes += stitems[i]["@attributes"]["Name"] + " ";
}
htmltypes += " |
---|
";
$('#mdstatus').append(htmltypes);
$('#block_mdstatus').show();
} else {
$('#block_mdstatus').hide();
}
} else {
$('#block_mdstatus').hide();
}
var mditems = items(data['Plugins']['Plugin_MDStatus']['Raid']);
if (mditems.length > 0) {
var html = '';
for (i = 0; i < mditems.length ; i++) {
if (i) {
html += "
| ";
} else {
html += " |
RAID-Devices | ";
}
if (mditems[i]['Disks'] !== undefined) {
var devchunk = parseInt(mditems[i]["@attributes"]["Chunk_Size"]);
var devsuper = parseInt(mditems[i]["@attributes"]["Persistent_Superblock"]);
var devalgo = parseInt(mditems[i]["@attributes"]["Algorithm"]);
var devactive = parseInt(mditems[i]["@attributes"]["Disks_Active"]);
var devregis = parseInt(mditems[i]["@attributes"]["Disks_Registered"]);
html += "";
html += "";
var diskitems = items(mditems[i]['Disks']['Disk']);
for (j = 0; j < diskitems.length ; j++) {
html += raid_diskicon(diskitems[j]["@attributes"]);
}
html += " | ";
if (mditems[i]['Action'] !== undefined) {
var buildedaction = raid_buildaction(mditems[i]['Action']['@attributes']);
if (buildedaction) {
html += " | " + buildedaction + " | ";
}
}
html += "";
html += "" + mditems[i]["@attributes"]["Device_Name"] + " | | ";
html += "Status | " + mditems[i]["@attributes"]["Disk_Status"] + " | ";
html += "RAID-Level | " + mditems[i]["@attributes"]["Level"] + " | ";
if (devchunk !== -1) {
html += "Chunk Size | " + devchunk + "K | ";
}
if (devalgo !== -1) {
html += "Algorithm | " + devalgo + " | ";
}
if (devsuper !== -1) {
html += "Persistent Superblock | available | ";
} else {
html += "Persistent Superblock | not available | ";
}
if (devactive !== -1 && devregis !== -1) {
html += "Registered/" + String.fromCharCode(8203) + "Active Disks | " + devregis + "/" + String.fromCharCode(8203) + devactive + " | ";
}
html += " ";
html += "";
html += " ";
}
html +=" |
";
}
$('#mdstatus').append(html);
for (i = 0; i < mditems.length ; i++) {
if (mditems[i]['Disks'] !== undefined) {
$('#mdstatus-'+i).treegrid({
initialState: 'collapsed',
expanderExpandedClass: 'normalicon normalicon-down',
expanderCollapsedClass: 'normalicon normalicon-right'
});
}
}
}
} else {
$('#block_mdstatus').hide();
}
}