1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
|
<?/*
+-------------------------------------------------------------------------+
| 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 Graphs"; include ('auth/include/auth.php');
header("Cache-control: no-cache");
include ('include/database.php');
include ('include/config.php');
include_once ('include/form.php');
switch ($action) {
case 'duplicate':
include_once ('include/utility_functions.php');
DuplicateGraph($id);
header ("Location: graphs.php");
break;
case 'save':
if ($lowerlimit==""){$lowerlimit=0;} /* no nulls; zeros */
if ($upperlimit==""){$upperlimit=0;} /* no nulls; zeros */
if ($id != 0) {
$sql_id = mysql_query("select grouping from rrd_graph where id=$id", $cnn_id);
if (mysql_result($sql_id, 0, "grouping") != $grouping) { /* the value has changed */
include_once ('include/utility_functions.php');
if ($grouping == "on") {
group_graph_items($id);
}else{
ungroup_graph_items($id);
}
}
}
$sql_id = mysql_query("replace into rrd_graph (id,imageformatid,title,height,width,
upperlimit,lowerlimit,verticallabel,autoscale,autopadding,autoscaleopts,rigid,
basevalue,grouping,export) values ($id,$imageformatid,\"$title\",$height,$width,
$upperlimit,$lowerlimit,\"$verticallabel\",\"$autoscale\",\"$autopadding\",
$autoscaleopts,\"$rigid\",$basevalue,\"$grouping\",\"$export\")",$cnn_id);
if ($id == 0) {
/* get graphid if this is a new save */
$sql_id = mysql_query("select LAST_INSERT_ID()",$cnn_id);
if (mysql_result($sql_id,"",0) != 0) {
$id = mysql_result($sql_id,"",0);
}
}
header ("Location: graphs.php");
break;
case 'remove':
mysql_query("delete from rrd_graph where id=$id",$cnn_id);
mysql_query("delete from rrd_graph_item where graphid=$id",$cnn_id);
mysql_query("delete from graph_hierarchy_items where graphid=$id",$cnn_id);
mysql_query("delete from auth_graph where graphid=$id",$cnn_id);
header ("Location: graphs.php");
break;
case 'edit':
include_once ('include/top_header.php');
if ($id != "") {
$sql_id = mysql_query("select * from rrd_graph where id=$id", $cnn_id);
}
DrawFormHeader("rrdtool Graph Configuration","",false);
DrawFormItem("Title","The name that is printed on the graph.");
DrawFormItemTextBox("title",$sql_id,"","");
DrawFormItem("Image Format","The type of graph that is generated; GIF or PNG.");
DrawFormItemDropdownFromSQL("imageformatid",$cnn_id,"select * from def_image_type order by name",
"name","id",$sql_id,"","1");
DrawFormItem("Height","The height (in pixels) that the graph is.");
DrawFormItemTextBox("height",$sql_id,"120","");
DrawFormItem("Width","The width (in pixels) that the graph is.");
DrawFormItemTextBox("width",$sql_id,"500","");
DrawFormItem("Auto Scale"," Auto scale vertical data instead of defining an upper and
lower limit. Note: if this is check both the Upper and Lower limit will be ignored.");
DrawFormItemCheckBox("rigid",$sql_id,"Use Rigid Boundaries Mode (--rigid)","");
DrawFormItemCheckBox("autoscale",$sql_id,"Auto Scale","on");
DrawFormItemRadioButton("autoscaleopts", $sql_id, "1", "Use --alt-autoscale","2");
DrawFormItemRadioButton("autoscaleopts", $sql_id, "2", "Use --alt-autoscale-max","2");
DrawFormItem("Auto Padding","Pad text so that legend and graph data always line up.
Note: this could cause graphs to take longer to render because of the larger overhead.
Also Auto Padding may not be accurate on all types of graphs, consistant labeling
usually helps.");
DrawFormItemCheckBox("autopadding",$sql_id,"Auto Padding","");
DrawFormItem("Allow Grouping","This will enable you to \"group\" items of your graph
together for eaier manipulation. Note when you check this box and save, cacti
will automatically group the items in your graph; you may have to re-group
part of the graph manually.");
DrawFormItemCheckBox("grouping",$sql_id,"Allow Grouping","on");
DrawFormItem("Allow Graph Export","Choose whether this graph will be included in the
static html/png export if you use cacti's export feature.");
DrawFormItemCheckBox("export",$sql_id,"Allow Graph Export","on");
DrawFormItem("Upper Limit","The maximum vertical value for the rrd graph.");
DrawFormItemTextBox("upperlimit",$sql_id,"0","");
DrawFormItem("Lower Limit","The minimum vertical value for the rrd graph.");
DrawFormItemTextBox("lowerlimit",$sql_id,"0","");
DrawFormItem("Base Value","Should be set to 1024 for memory and 1000 for traffic measurements.");
DrawFormItemTextBox("basevalue",$sql_id,"1000","");
DrawFormItem("Vertical Label","The label vertically printed to the left of the graph.");
DrawFormItemTextBox("verticallabel",$sql_id,"","");
DrawFormSaveButton();
DrawFormItemHiddenIDField("id",$id);
DrawFormFooter();
include_once ("include/bottom_footer.php");
break;
default:
include_once ('include/top_header.php');
DrawMatrixTableBegin("97%");
DrawMatrixRowBegin();
DrawMatrixHeaderTop("Currently Active rrdtool Graphs",$color_dark_bar,"","4");
DrawMatrixHeaderAdd($color_dark_bar,"","graphs.php?action=edit");
DrawMatrixRowEnd();
DrawMatrixRowBegin();
DrawMatrixHeaderItem("Graph Title",$color_panel,$color_panel_text);
DrawMatrixHeaderItem("Size",$color_panel,$color_panel_text);
DrawMatrixHeaderItem("Graph Subitems",$color_panel,$color_panel_text);
DrawMatrixHeaderItem("Duplicate",$color_panel,$color_panel_text);
DrawMatrixHeaderItem("",$color_panel,$color_panel_text);
DrawMatrixRowEnd();
$sql_id = mysql_query("select id,height,width,title from rrd_graph order by title", $cnn_id);
$rows = mysql_num_rows($sql_id); $i = 0;
while ($i < $rows) {
DrawMatrixRowAlternateColorBegin($color_alternate,$color_light,$i);
DrawMatrixLoopItem($sql_id,"title",$i,html_boolean($config["vis_main_column_bold"]["value"]),"graphs.php?action=edit&id=" . mysql_result($sql_id, $i, "id"));
DrawMatrixLoopItem(mysql_result($sql_id, $i, "height") . "x" . mysql_result($sql_id, $i, "width"),"",$i,false,"");
DrawMatrixLoopItem("Edit Graph Items","",$i,false,"graphs_items.php?id=" . mysql_result($sql_id, $i, "id"));
DrawMatrixLoopItem("Duplicate","",$i,false,"graphs.php?id=" . mysql_result($sql_id, $i, "id") . "&action=duplicate");
DrawMatrixLoopItemAction("Remove",$color_panel,"",false,"graphs.php?action=remove&id=" . mysql_result($sql_id, $i, "id"));
DrawMatrixRowEnd();
$i++;
}
DrawMatrixTableEnd();
include_once ("include/bottom_footer.php");
break;
} ?>
|