bandwidthd-php: PHP files to graph bandwidthd data in a postgresql

database
Signed-off-by: Jean-Michel Lacroix <lacroix@lepine-lacroix.info>
bandwidthd-php is a set of PHP files that allows to graph bandwidthd
data stored in a postgresql database.  This bandwidthd data can be
generated using bandwidthd-pgsql in OpenWRT or LEDE or with
bandwidthd on different OS (Windows, Linux for example).

Addition of a config file and an init file.
Modification of the Makefile to take in account the changes above
Signed-off-by: Jean-Michel Lacroix <lacroix@lepine-lacroix.info>
This commit is contained in:
Jean-Michel Lacroix
2016-07-14 13:38:05 -04:00
parent 7685db7a9d
commit 3a49a7dbe6
10 changed files with 946 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
<?php
define("INT_DAILY", 60*60*24*2);
define("INT_WEEKLY", 60*60*24*8);
define("INT_MONTHLY", 60*60*24*35);
define("INT_YEARLY", 60*60*24*400);
define("XOFFSET", 90);
define("YOFFSET", 45);
require("config.conf");
function ConnectDb()
{
global $db_connect_string;
$db = pg_pconnect($db_connect_string);
if (!$db)
{
printf("DB Error, could not connect to database");
exit(1);
}
return($db);
}
function fmtb($kbytes)
{
$Max = 1024;
$Output = $kbytes;
$Suffix = 'K';
if ($Output > $Max)
{
$Output /= 1024;
$Suffix = 'M';
}
if ($Output > $Max)
{
$Output /= 1024;
$Suffix = 'G';
}
if ($Output > $Max)
{
$Output /= 1024;
$Suffix = 'T';
}
return(sprintf("<td align=right><tt>%.1f%s</td>", $Output, $Suffix));
}
$starttime = time();
set_time_limit(300);
?>