This post will help creating php graphs. Many a times administrator requires graphs to illustrate resource utilization.
I am using Vsftp to upload user data using Cobian Backup.
To keep a track of higher utilization I am using bash script to insert folder size, owner & current date mysql table. I am using Libchart generate php graphs.
Using following php code, php graph can be generated.
include “/usr/local/etc/libchart/classes/libchart.php”;
mysql_connect(“localhost”,”USERNAME”,”PASSWORD”)or die(“cant connect”);
mysql_select_db(“DATABASE”)or dir(“cant select”);
header(“Content-type: image/png”);$chart = new HorizontalBarChart(900, 270);
$dataSet = new XYDataSet();
$qr=”select name,size from TABLE where `date` = ‘”.date(“Y-m-d”).”‘ order by size”;
$rs=mysql_query($qr)or die(mysql_error());
while($row=mysql_fetch_assoc($rs)){
$dataSet->addPoint(new Point($row['name'], $row['size']));
}
$dataSet->addPoint(new Point(“/wiki/Web_Browser”, 35));
$dataSet->addPoint(new Point(“/wiki/World_Wide_Web”, 68));*/
$chart->setDataSet($dataSet);$chart->getPlot()->setGraphPadding(new Padding(5, 30, 20, 140));
$chart->setTitle(“User Consumption -GB”);
$chart->render();
Source
