Files
votianng/html/sysadmin/monitor_capacity.php
2026-03-29 10:34:57 +02:00

89 lines
2.2 KiB
PHP

<?php
/*=======================================================================
*
* monitor_capacity.php
*
* Autor: Marc Vollmann
*
=======================================================================*/
include_once ("../include/mcglobal.inc.php");
getSecHttpVars("1",array("serverName","mountedVolume", "volumeSpace","showtitle"));
if (!isset($serverName) || $serverName == "") : $serverName = "???"; endif;
if (!isset($mountedVolume) || $mountedVolume == "") : $mountedVolume = "home"; endif;
if (!isset($showtitle) || $showtitle == "") : $showtitle = ""; endif;
$currentTime = getDateTime("0");
$volumeSpace = "";
$out = shell_exec("df -h");
$tmpPos = strpos($out, "/" . $mountedVolume);
if (!($tmpPos === false)) :
$volumeSpace = substr($out, $tmpPos - 4, 2);
else :
$volumeSpace = "--%";
endif;
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="../css/phoenix.css">
<script type="text/javascript">
var refreshStatus = 1;
var statusMessage = "<?php echo $statusMessage ?>";
function displayStatusMessage() {
if (statusMessage != "") {
alert(statusMessage);
}
};
function startReload() {
if (refreshStatus == 1) {
// self.location.reload();
document.forms[0].submit();
}
}
function startTimeout() {
self.setTimeout("startReload()", 1000000);
}
</script>
</head>
<body onLoad="startTimeout();displayStatusMessage();">
<form action="../sysadmin/monitor_capacity.php" method="post">
<input type="hidden" name="serverName" value="<?php echo $serverName ?>">
<input type="hidden" name="mountedVolume" value="<?php echo $mountedVolume ?>">
<input type="hidden" name="showtitle" value="<?php echo $showtitle ?>">
<table>
<tr>
<td colspan="3">
<?php if ($showtitle != "") : ?>
&nbsp;&nbsp;&nbsp;<b>VOLUME SPACE:</b>
<?php endif; ?>
&nbsp;&nbsp;&nbsp;&nbsp;<span class="f7np1">(<?php echo substr($currentTime,-8) ?>)</span>
</td>
<?php
echo "<td class=\"f8np1\">&nbsp;&nbsp;" . $serverName . ": </td><td class=\"" . ($volumeSpace < "90" ? "f8np1_darkgreen\">" . $volumeSpace . "" : "f8np1_red\">" . $volumeSpace) . "%</td>\n";
?>
</tr>
</table>
</form>
</body>
</html>