Files
cacti/rra.php
T
Ian Berry fe1c475bad converted files to new format
git-svn-id: svn+ssh://repo.cacti.net/var/data/svnroot/cacti/trunk/cacti@187 860744bd-22fc-0310-8c96-e9fe5004b5ca
2002-08-12 02:40:11 +00:00

216 lines
6.9 KiB
PHP

<?/*
+-------------------------------------------------------------------------+
| Copyright (C) 2002 Ian Berry |
| |
| This program is free software; you can redistribute it and/or |
| modify it under the terms of the GNU General Public License |
| as published by the Free Software Foundation; either version 2 |
| of the License, or (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
+-------------------------------------------------------------------------+
| cacti: the rrdtool frontend [php-auth, php-tree, php-form] |
+-------------------------------------------------------------------------+
| This code is currently maintained and debugged by Ian Berry, any |
| questions or comments regarding this code should be directed to: |
| - iberry@raxnet.net |
+-------------------------------------------------------------------------+
| - raXnet - http://www.raxnet.net/ |
+-------------------------------------------------------------------------+
*/?>
<?
$section = "Add/Edit Round Robin Archives"; include ('include/auth.php');
header("Cache-control: no-cache");
include_once ('include/form.php');
if (isset($form[action])) { $action = $form[action]; } else { $action = $args[action]; }
if (isset($form[ID])) { $id = $form[ID]; } else { $id = $args[id]; }
switch ($action) {
case 'save':
$redirect_location = form_save();
header ("Location: $redirect_location"); exit;
break;
case 'remove':
rra_remove();
header ("Location: rra.php");
break;
case 'edit':
include_once ("include/top_header.php");
rra_edit();
include_once ("include/bottom_footer.php");
break;
default:
include_once ("include/top_header.php");
rra();
include_once ("include/bottom_footer.php");
break;
}
/* --------------------------
The Save Function
-------------------------- */
function form_save() {
global $form;
if (isset($form[save_component_rra])) {
rra_save();
return "rra.php";
}
}
/* -------------------
RRA Functions
------------------- */
function rra_save() {
global $form;
$save["ID"] = $form["ID"];
$save["Name"] = $form["Name"];
$save["XFilesFactor"] = $form["XFilesFactor"];
$save["Steps"] = $form["Steps"];
$save["Rows"] = $form["RRA_Rows"];
$save["Name"] = $form["Hex"];
$rra_id = sql_save($save, "rrd_rra");
db_execute("delete from lnk_rra_cf where rraid=$rra_id");
for ($i=0; ($i < count($form[ConsolidationFunctionID])); $i++) {
db_execute("insert into lnk_rra_cf (rraid,consolidationfunctionid)
values ($rra_id,".$form[ConsolidationFunctionID][$i].")");
}
}
function rra_remove() {
global $args;
if (($config["remove_verification"]["value"] == "on") && ($args[confirm] != "yes")) {
include_once ('include/top_header.php');
DrawConfirmForm("Are You Sure?", "Are you sure you want to delete this round robin archive?", getenv("HTTP_REFERER"), "rra.php?action=remove&id=$args[id]");
exit;
}
if (($config["remove_verification"]["value"] == "") || ($args[confirm] == "yes")) {
db_execute("delete from rrd_rra where id=$args[id]");
db_execute("delete from lnk_ds_rra where rraid=$args[id]");
}
}
function rra_edit() {
global $args, $colors;
start_box("<strong>Round Robin Archive Management [edit]</strong>", "", "");
if (isset($args[id])) {
$rra = db_fetch_row("select * from rrd_rra where id=$args[id]");
}else{
unset($rra);
}
?>
<form method="post" action="rra.php">
<?DrawMatrixRowAlternateColorBegin($colors[form_alternate1],$colors[form_alternate2],0); ?>
<td width="50%">
<font class="textEditTitle">Name</font><br>
How data is to be entered in RRA's.
</td>
<?DrawFormItemTextBox("Hex",$rra[Name],"","100", "40");?>
</tr>
<?DrawMatrixRowAlternateColorBegin($colors[form_alternate1],$colors[form_alternate2],1); ?>
<td width="50%">
<font class="textEditTitle">Consolidation Functions</font><br>
How data is to be entered in RRA's.
</td>
<?DrawFormItemMultipleList("ConsolidationFunctionID","select * from def_cf","Name","ID","select * from lnk_rra_cf where rraid=$args[id]","ConsolidationFunctionID","");?>
</tr>
<?DrawMatrixRowAlternateColorBegin($colors[form_alternate1],$colors[form_alternate2],0); ?>
<td width="50%">
<font class="textEditTitle">X-Files Factor</font><br>
The amount of unknown data that can still be regarded as known.
</td>
<?DrawFormItemTextBox("XFilesFactor",$rra[XFilesFactor],"","100", "40");?>
</tr>
<?DrawMatrixRowAlternateColorBegin($colors[form_alternate1],$colors[form_alternate2],1); ?>
<td width="50%">
<font class="textEditTitle">Steps</font><br>
How many data points are needed to put data into the RRA.
</td>
<?DrawFormItemTextBox("Steps",$rra[Steps],"","100", "40");?>
</tr>
<?DrawMatrixRowAlternateColorBegin($colors[form_alternate1],$colors[form_alternate2],0); ?>
<td width="50%">
<font class="textEditTitle">Rows</font><br>
How many generations data is kept in the RRA.
</td>
<?DrawFormItemTextBox("Rows",$rra[Rows],"","100", "40");?>
</tr>
<?
DrawFormItemHiddenIDField("ID",$args[id]);
DrawFormItemHiddenTextBox("save_component_rra","1","");
?>
<tr bgcolor="#FFFFFF">
<td colspan="2" align="right" background="images/blue_line.gif">
<?DrawFormSaveButton("save", "rra.php");?>
</form>
</td>
</tr>
<?
end_box();
}
function rra() {
global $colors;
start_box("<strong>Round Robin Archive Management</strong>", "", "rra.php?action=edit");
print "<tr bgcolor='#$colors[header_panel]'>";
DrawMatrixHeaderItem("Name",$colors[header_text],1);
DrawMatrixHeaderItem("Steps",$colors[header_text],1);
DrawMatrixHeaderItem("Rows",$colors[header_text],2);
print "</tr>";
$rra_list = db_fetch_assoc("select ID,Name,Rows,Steps from rrd_rra order by steps");
$rows = sizeof($color_list);
foreach ($rra_list as $rra) {
DrawMatrixRowAlternateColorBegin($colors[alternate],$colors[light],$i);
?>
<td>
<a class="linkEditMain" href="rra.php?action=edit&id=<?print $rra[ID];?>"><?print $rra[Name];?></a>
</td>
<td>
<?print $rra[Steps];?>
</td>
<td>
<?print $rra[Rows];?>
</td>
<td width="1%" align="right">
<a href="rra.php?action=remove&id=<?print $rra[ID];?>"><img src="images/delete_icon.gif" width="10" height="10" border="0" alt="Delete"></a>&nbsp;
</td>
</tr>
<?
$i++;
}
end_box();
}
?>