Files
pi-control/resources/plugins/fritzbox/resources/templates/traffic_monitoring.tmp.php
Gregor Schulte b303dd00d6 Init Repo
2021-06-17 12:24:22 +02:00

34 lines
1.3 KiB
PHP

<?php
if (PHP_SAPI != 'cli') exit();
define('PICONTROL', true);
$doNotCheckForAuthentification = true;
(include_once realpath(dirname(__FILE__)).'/../../../../init.php') or die('Error: 0x0000');
(include_once LIBRARY_PATH.'main/main.function.php') or die('Error: 0x0001');
(include_once LIBRARY_PATH.'statistic/statistic.class.php') or die('Error: 0x0002');
(include_once LIBRARY_PATH.'plugin/plugin.function.php') or die('Error: 0x0003');
initPluginConstants();
(include_once PLUGIN_PATH.'resources/library/main/main.function.php') or die('Error: 9x0001');
$fritzboxAddress = getPluginConfig('main:address', 'http://fritz.box');
$fritzboxVersion = getPluginConfig('main:version', '5');
$currentBandwidth = getCurrentBandwidth($fritzboxAddress, $fritzboxVersion);
$maxBandwidth = getMaxBandwidth($fritzboxAddress, $fritzboxVersion);
if (is_array($currentBandwidth) && is_array($maxBandwidth))
{
$log = new LogStatistic();
$log->setFile(LOG_PATH.'plugin/fritzbox.traffic-download.csv');
$log->setLimit(1008);
$log->add(array(time(), round($maxBandwidth['down']/8), $currentBandwidth['down']));
$log->close();
$log = new LogStatistic();
$log->setFile(LOG_PATH.'plugin/fritzbox.traffic-upload.csv');
$log->setLimit(1008);
$log->add(array(time(), round($maxBandwidth['up']/8), $currentBandwidth['up']));
$log->close();
}
?>