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 += '
' + '
' + '
' + percent + '%
'; 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 += ""; } } 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 += ""; html += ""; if (devchunk !== -1) { html += ""; } if (devalgo !== -1) { html += ""; } if (devsuper !== -1) { html += ""; } else { html += ""; } if (devactive !== -1 && devregis !== -1) { html += ""; } html += "
" + mditems[i]["@attributes"]["Device_Name"] + "
Status" + mditems[i]["@attributes"]["Disk_Status"] + "
RAID-Level" + mditems[i]["@attributes"]["Level"] + "
Chunk Size" + devchunk + "K
Algorithm" + devalgo + "
Persistent Superblockavailable
Persistent Superblocknot available
Registered/" + String.fromCharCode(8203) + "Active Disks" + devregis + "/" + String.fromCharCode(8203) + devactive + "
"; 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(); } }