2 ////////////////////////////////////////////////////////////////////////////////
5 // Description: Produce a graph of filesystem usage
6 // Author: Andrew@ClearSCM.com
7 // Created: Mon Apr 28 15:20:06 MST 2008
11 // (c) Copyright 2008, ClearSCM Inc., all rights reserved.
13 ////////////////////////////////////////////////////////////////////////////////
14 $script = basename ($_SERVER["PHP_SELF"]);
16 include_once "FsmonDB.php";
17 include_once "Fsutils.php";
21 $system = $_REQUEST["system"];
22 $mount = $_REQUEST["mount"];
23 $period = $_REQUEST["period"];
24 $scale = $_REQUEST["scale"];
26 function createHeader () {
27 global $version, $system, $mount;
29 $sysLabel = (empty ($system)) ? "All Systems" : $system;
30 $mountLabel = (empty ($mount)) ? "All Filesystems" : $mount;
33 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
34 "http://www.w3.org/TR/html4/strict.dtd">
37 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
38 <link rel="stylesheet" type="text/css" media="screen" href="/css/Testing.css">
39 <link rel="stylesheet" type="text/css" media="screen" href="/css/Tables.css">
40 <title>FSMon v($version) $sysLabel - $mountLabel</title>
47 <h1 align="center">Filesystem Monitor</h1>
53 function createPage ($system, $mount = "", $period = "daily", $scale = "gig") {
54 $data = getFSInfo ($system, $mount, $period);
60 <th class="left">System</th>
66 <th class="right">Reserve</th>
72 foreach ($data as $line) {
75 <td>$line[sysname]</td>
77 <td>$line[timestamp]</td>
78 <td align="right">$line[size]</td>
79 <td align="right">$line[used]</td>
80 <td align="right">$line[free]</td>
81 <td align="right">$line[reserve]</td>
94 function displayReport ($system = "", $mount = "", $period = "daily", $scale = "gig") {
95 print createPage ($system, $mount, $period, $scale);
98 function displayMount ($system = "", $mount = "", $period = "daily", $scale = "gig") {
102 <table cellspacing="0" align="center">
104 <form action="$script">
105 <td align="center">System:
106 <select name="system" class="inputfield">
109 foreach (getSystem () as $item) {
112 if ($item["name"] == $system) {
113 print " selected=\"selected\"";
116 print ">$item[name]</option>";
122 <select name="mount" class="inputfield">
125 foreach (getMounts ($system) as $item) {
128 if ($item == $mount) {
129 print " selected=\"selected\"";
132 print ">$item</option>";
138 <select name="period" class="inputfield">
141 foreach (getPeriods () as $item) {
144 if ($item == $period) {
145 print " selected=\"selected\"";
148 print ">$item</option>";
154 <select name="scale" class="inputfield">
157 foreach (getScales () as $item) {
160 if ($item == $scale) {
161 print " selected=\"selected\"";
164 print ">$item</option>";
169 <input type="submit" value="Graph" /></form>
174 <img src="graphFS.php?system=$system&mount=$mount&period=$period&scale=$scale">
179 // displayReport ($system, $mount, $period, $scale);
182 function displayFilesystems ($system = "", $mount = "", $period = "daily", $scale = "gig") {
183 if (empty ($mount)) {
184 foreach (getMounts ($system) as $mount) {
185 displayMount ($system, $mount, $period, $scale);
189 displayMount ($system, $mount, $period, $scale);
191 } // displayFilesystems
193 function displayGraph ($system = "", $mount = "", $period = "daily", $scale = "gig") {
194 print createHeader ();
196 if (empty ($system)) {
197 foreach (getSystem () as $system) {
198 displayFilesystems ($system["name"], $mount, $period, $scale);
201 displayFilesystems ($system, $mount, $period, $scale);
207 if (empty ($system)) {
208 print createHeader ();
211 foreach (getSystem () as $system) {
212 print "<li><a href=$script?system=$system[name]>$system[name]</a></li>";
216 // $mounts = getMounts ($system["name"]);
218 // foreach ($mounts as $mount) {
219 // print "<li><a href=$script?system=$system[name]&mount=$mount>$mount</a></li>";
227 displayGraph ($system, $mount, $period, $scale);