/** * get server stats * note : this can only be used after a call to update transfer-values in cfg- * array (eg by getTransferListArray) * * @return array * * "speedDown" 0 * "speedUp" 1 * "speedTotal" 2 * "cons" 3 * "freeSpace" 4 * "loadavg" 5 * "running" 6 * "queued" 7 * "speedDownPercent" 8 * "speedUpPercent" 9 * "driveSpacePercent" 10 * */ function getServerStats() { global $cfg; $serverStats = array(); // speedDown $speedDown = "n/a"; $speedDown = @number_format($cfg["total_download"], 2); array_push($serverStats, $speedDown); // speedUp $speedUp = "n/a"; $speedUp = @number_format($cfg["total_upload"], 2); array_push($serverStats, $speedUp); // speedTotal $speedTotal = "n/a"; $speedTotal = @number_format($cfg["total_download"] + $cfg["total_upload"], 2); array_push($serverStats, $speedTotal); // cons $cons = "n/a"; $cons = @netstatConnectionsSum(); array_push($serverStats, $cons); // freeSpace $freeSpace = "n/a"; $freeSpace = @formatFreeSpace($cfg["free_space"]); array_push($serverStats, $freeSpace); // loadavg $loadavg = "n/a"; $loadavg = @getLoadAverageString(); array_push($serverStats, $loadavg); // running $running = "n/a"; $running = @getRunningTransferCount(); array_push($serverStats, $running); // queued $queued = FluxdQmgr::countQueuedTransfers(); array_push($serverStats, $queued); // speedDownPercent $percentDownload = 0; $maxDownload = $cfg["bandwidth_down"] / 8; $percentDownload = $maxDownload > 0 ? @number_format($cfg["total_download"] / $maxDownload * 100, 0) : 0; array_push($serverStats, $percentDownload); // speedUpPercent $percentUpload = 0; $maxUpload = $cfg["bandwidth_up"] / 8; $percentUpload = $maxUpload > 0 ? @number_format($cfg["total_upload"] / $maxUpload * 100, 0) : 0; array_push($serverStats, $percentUpload); // driveSpacePercent $driveSpacePercent = 0; $driveSpacePercent = @getDriveSpace($cfg["path"]); array_push($serverStats, $driveSpacePercent); // return return $serverStats; }
$tmpl->setvar('_DAYXFER', $cfg['_DAYXFER']); $tmpl->setvar('_YOURXFERSTATS', $cfg['_YOURXFERSTATS']); $tmpl->setvar('totalxfer1', @formatFreeSpace($xfer_total['total']['total'] / 1048576)); $tmpl->setvar('monthxfer1', @formatFreeSpace($xfer_total['month']['total'] / 1048576)); $tmpl->setvar('weekxfer1', @formatFreeSpace($xfer_total['week']['total'] / 1048576)); $tmpl->setvar('dayxfer1', @formatFreeSpace($xfer_total['day']['total'] / 1048576)); $xfer = Xfer::getStats(); $tmpl->setvar('total2', @formatFreeSpace($xfer[$cfg["user"]]['total']['total'] / 1048576)); $tmpl->setvar('month2', @formatFreeSpace($xfer[$cfg["user"]]['month']['total'] / 1048576)); $tmpl->setvar('week2', @formatFreeSpace($xfer[$cfg["user"]]['week']['total'] / 1048576)); $tmpl->setvar('day2', @formatFreeSpace($xfer[$cfg["user"]]['day']['total'] / 1048576)); } // queue if (FluxdQmgr::isRunning()) { $tmpl->setvar('_QUEUEMANAGER', $cfg['_QUEUEMANAGER']); $tmpl->setvar('runningTransferCount', getRunningTransferCount()); $tmpl->setvar('countQueuedTransfers', FluxdQmgr::countQueuedTransfers()); $tmpl->setvar('limitGlobal', $cfg["fluxd_Qmgr_maxTotalTransfers"]); $tmpl->setvar('limitUser', $cfg["fluxd_Qmgr_maxUserTransfers"]); } // other $tmpl->setvar('_OTHERSERVERSTATS', $cfg['_OTHERSERVERSTATS']); $tmpl->setvar('downloadspeed1', @number_format($cfg["total_download"], 2)); $tmpl->setvar('downloadspeed11', @number_format($transfers['sum']['drate'], 2)); $tmpl->setvar('uploadspeed1', @number_format($cfg["total_upload"], 2)); $tmpl->setvar('uploadspeed11', @number_format($transfers['sum']['rate'], 2)); $tmpl->setvar('totalspeed1', @number_format($cfg["total_download"] + $cfg["total_upload"], 2)); $tmpl->setvar('totalspeed11', @number_format($transfers['sum']['rate'] + $transfers['sum']['drate'], 2)); $tmpl->setvar('id_connections1', $netstatConnectionsSum); $tmpl->setvar('id_connections11', $netstatConnectionsMax); $tmpl->setvar('drivespace1', $cfg['freeSpaceFormatted']);