N/A"; function dbError ($msg, $statement) { $errno = mysql_errno (); $errmsg = mysql_error (); print <<ERROR: $msg Error #$errno:
$errmsg
SQL Statement:
$statement
END; exit ($errno); } // dbError function openDB () { global $dbserver, $userid, $password, $dbname; $db = mysql_connect ($dbserver, $userid, $password) or dbError (__FUNCTION__ . ": Unable to connect to database server $dbserver", "Connect"); mysql_select_db ($dbname) or dbError (__FUNCTION__ . ": Unable to select the $dbname database", "$dbname"); } // openDB function getFSInfo ($system = "", $mount = "", $period = "daily") { $sysCondition = (isset ($system)) ? "where sysname = \"$system\"" : ""; $mountCondition = (isset ($mount)) ? " and mount = \"$mount\"" : ""; if (!($period == "hourly" or $period == "daily" or $period == "weekly" or $period == "monthly")) { error ("Invalid period - $period - specified", 1); } // if $statement = << $maxUsed) { $maxUsed = $row["used"]; $line["size"] = $row["size"]; $line["used"] = $row["used"]; $line["free"] = $row["free"]; $line["reserve"] = $row["reserve"]; } else { continue; } // if } elseif ($period == "weekly") { error ("Weekly not handled yet", 1); } elseif ($period == "monthly") { $thisPeriod = substr ($row["timestamp"], 0, 7); if ($lastPeriod == "") { $lastPeriod = $thisPeriod; } elseif ($lastPeriod == $thisPeriod) { continue; } // if if ($row["used"] > $maxUsed) { $maxUsed = $row["used"]; $line["size"] = $row["size"]; $line["used"] = $row["used"]; $line["free"] = $row["free"]; $line["reserve"] = $row["reserve"]; } else { continue; } // if } // if array_push ($data, $line); } // while return $data; } // getFSInfo function getSystem ($system = "") { $statement = "select * from system"; if (isset ($system) and $system != "") { $statement .= " where name = \"$system\""; } // if $result = mysql_query ($statement) or DBError ("Unable to execute query: ", $statement); $data = array (); while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) { array_push ($data, $row); } // while return $data; } // getSystem function getMounts ($system) { $statement = "select mount from filesystems where sysname = \"$system\" order by mount"; $result = mysql_query ($statement) or DBError ("Unable to execute query: ", $statement); $data = array (); while ($row = mysql_fetch_array ($result)) { array_push ($data, $row["mount"]); } // while return $data; } // getMounts ?>