Sharing for others...
I just wrote myself, the below code to convert the Kaseya db raw data into
usable hard drive percentages or gb amounts. Very simple code, but might be of use to others.
-Chris ,
// Calculate the percentage of HD space used
// UsedSpace / TotalSpace
$UsedSpacePercentage = $row["UsedSpace"] / $row["TotalSpace"];
$UsedSpacePercentage = round((float)$UsedSpacePercentage * 100 );
$UsedSpacePercentageNumber = $UsedSpacePercentage;
$FreeSpacePercentage = 100 - $UsedSpacePercentage;
$FreeSpacePercentageNumber = $FreeSpacePercentage;
$FreeSpacePercentage = $FreeSpacePercentage . '%';
$UsedSpacePercentage = $UsedSpacePercentage . '%';
// End of Calculate the percentage of HD space used
// convert the freespace variable into GB from bytes
if ($row["FreeSpace"] > 1000) {
$row["FreeSpace"] = $row["FreeSpace"] / 1000;
$row["FreeSpace"] = number_format($row["FreeSpace"]);
$row["FreeSpace"] = $row["FreeSpace"] . " <font size=\"-1\">GB</font>";
}
// end of convert the freespace variable into GB from bytes
// convert the freespace variable into GB from bytes
if ($row["TotalSpace"] > 1000) {
$row["TotalSpace"] = $row["TotalSpace"] / 1000;
$row["TotalSpace"] = number_format($row["TotalSpace"]);
$row["TotalSpace"] = $row["TotalSpace"] . " <font size=\"-1\">GB</font>";
}
// end of convert the freespace variable into GB from bytes
// convert the freespace variable into GB from bytes
if ($row["UsedSpace"] > 1000) {
$row["UsedSpace"] = $row["UsedSpace"] / 1000;
$row["UsedSpace"] = number_format($row["UsedSpace"]);
$row["UsedSpace"] = $row["UsedSpace"] . " <font size=\"-1\">GB</font>";
}
// end of convert the freespace variable into GB from bytes
// Only display this row if the hard disk has less than xx% free, of which xx%
//is a variable which is user selectable, 10%, 15%, 20%, etc.
$PercentFreeFilter = "10" ;
if ($FreeSpacePercentageNumber < $PercentFreeFilter ) {
echo "<font size=\"-1\">";
echo "<tr>";
echo "<td class=\"colL\">" . "<a class='k2popupiframe' href=\"http://k2/Toolbox/agentDashFrame.asp?agentGuid=" . $row["agentGuid"] . "\">" . "<img src=\"http://192.168.1.250/noc/images/computericon.jpg\" width=\"20\" height=\"20\"></a>" . "</td>";
$row["machName"] = substr($row["machName"], 0, 20);
echo "<td class=\"colL\"><font size=\"-1\"><FONT COLOR=\"FF0000\">" . $row["machName"] . "</font></td><td class=\"colM\"><font size=\"-1\">" . $row["FreeSpace"] . "</font></td><td class=\"colM\"><font size=\"-1\">" . $row["DriveLetter"] . ":\</font></td><td class=\"colM\"><font size=\"-1\">" . $row["TotalSpace"] . "</font></td><td class=\"colM\"><font size=\"-1\">" . $row["UsedSpace"] . "</font></td><td><font size=\"-1\">" . $UsedSpacePercentage . "</font></td><td><font size=\"-1\">" . $FreeSpacePercentage . "</font></td></tr>";
} // end of the FreeSpacePercentageNumber IF statement