2 ////////////////////////////////////////////////////////////////////////////////
6 // Description: Produce a graph showing file system sizes
8 // Author: Andrew@ClearSCM.com
9 // Created: Mon Apr 28 15:20:06 MST 2008
13 // (c) Copyright 2008, ClearSCM Inc., all rights reserved.
15 ////////////////////////////////////////////////////////////////////////////////
16 $script = basename ($_SERVER["PHP_SELF"]);
17 //$inc = $_SERVER["DOCUMENT_ROOT"];
18 $inc = "/var/www/html/Fsmon";
20 include_once "$inc/FsmonDB.php";
21 include_once "$inc/Fsutils.php";
23 include_once "$inc/pChart/pData.class";
24 include_once "$inc/pChart/pChart.class";
26 $system = $_REQUEST["system"];
27 $mount = $_REQUEST["mount"];
31 function mydebug ($msg) {
32 $debug = fopen ("/tmp/debug.log", "a");
34 fwrite ($debug, "$msg\n");
37 function setScaling () {
38 if ($_REQUEST["scale"] == "byte") {
40 } elseif ($_REQUEST["scale"] == "kbyte") {
42 } elseif ($_REQUEST["scale"] == "meg") {
49 function setPeriod () {
50 if ($_REQUEST["period"] == "hourly") {
51 return $_REQUEST["period"];
52 } elseif ($_REQUEST["period"] == "weekly") {
53 return $_REQUEST["period"];
54 } elseif ($_REQUEST["period"] == "monthly") {
55 return $_REQUEST["period"];
63 $scaling = setScaling ();
64 $period = setPeriod ();
66 $data = getFSInfo ($system, $mount, $period);
68 $fonts = "$inc/Fonts";
76 foreach ($data as $result) {
77 $system = $result["sysname"];
78 $mount = $result["mount"];
80 // Set X Axis label properly
81 if ($period == "hourly") {
82 $hours = substr ($result["timestamp"], 11, 2);
83 $minutes = substr ($result["timestamp"], 14, 2);
89 } elseif ($hours < 10) {
90 $hours = substr ($hours, 1, 1);
93 $Xlabel = "$hours:$minutes $ampm";
94 } elseif ($period == "daily") {
95 $day = substr ($result["timestamp"], 8, 2);
98 $day = substr ($day, 1, 1);
101 $month = substr ($result["timestamp"], 5, 2);
104 $month = substr ($month, 1, 1);
107 $year = substr ($result["timestamp"], 0, 4);
108 $Xlabel = "$month/$day/$year";
109 } elseif ($period == "weekly") {
110 $Xlabel = "Weekly not implemented";
111 } elseif ($period == "monthly") {
112 $month = substr ($result["timestamp"], 5, 2);
115 $month = substr ($month, 1, 1);
118 $year = substr ($result["timestamp"], 0, 4);
119 $Xlabel = "$month/$year";
121 $Xlabel = $result["timestamp"];
124 $DataSet->AddPoint ($result["used"] / $scaling, "Used", $Xlabel);
125 $DataSet->AddPoint ($result["free"] / $scaling, "Free", $Xlabel);
128 $DataSet->AddAllSeries();
129 $DataSet->SetAbsciseLabelSerie();
131 $DataSet->SetXAxisName ("Time");
133 // Initialise the graph
134 $Test = new pChart (700, 280);
136 $Test->setColorPalette (1, 0, 255, 0);
137 $Test->setColorPalette (0, 255, 0, 0);
139 $Test->drawGraphAreaGradient (100, 150, 175, 100, TARGET_BACKGROUND);
140 $Test->setFontProperties ("$fonts/tahoma.ttf", 8);
142 if ($scaling == BYTE) {
143 $Test->setGraphArea (110, 30, 680, 200);
144 $DataSet->SetYAxisName ("Bytes");
145 } elseif ($scaling == KBYTE) {
146 $Test->setGraphArea (90, 30, 680, 200);
147 $DataSet->SetYAxisName ("Kbytes");
148 } elseif ($scaling == MEG) {
149 $Test->setGraphArea (70, 30, 680, 200);
150 $DataSet->SetYAxisName ("Meg");
152 $Test->setGraphArea (55, 30, 680, 200);
153 $DataSet->SetYAxisName ("Gig");
156 $Test->drawRoundedRectangle (5, 5, 695, 275, 5, 230, 230, 230);
157 $Test->drawGraphAreaGradient (162, 183, 202, 50);
158 $Test->drawScale ($DataSet->GetData (), $DataSet->GetDataDescription (), SCALE_ADDALLSTART0, 200, 200, 200, true, 70, 2, true);
159 $Test->drawGrid (4, true, 230, 230, 230, 50);
162 $Test->setFontProperties ("$fonts/tahoma.ttf", 6);
163 $Test->drawTreshold (0, 143, 55, 72, true, true);
165 // Draw the bar graph
166 $Test->drawStackedBarGraph ($DataSet->GetData (), $DataSet->GetDataDescription (), 75);
169 $Test->setFontProperties ("$fonts/tahoma.ttf",8);
170 $Test->drawLegend (610, 35, $DataSet->GetDataDescription (), 130, 180, 205);
171 $Test->setFontProperties ("$fonts/tahoma.ttf", 10);
172 $Test->drawTitle (50, 22, "$system:$mount ($period)", 255, 255, 255, 675);