File: rra.php

package info (click to toggle)
cacti 0.6.7-2.2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,000 kB
  • ctags: 1,120
  • sloc: php: 5,059; sql: 922; sh: 302; perl: 81; makefile: 56
file content (125 lines) | stat: -rw-r--r-- 5,431 bytes parent folder | download
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
<?/* 
+-------------------------------------------------------------------------+
| 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 ('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 'save':
		$sql_id = mysql_query("replace into rrd_rra (id,name,xfilesfactor,steps,rows) 
			values ($id,\"$name\",$xfilesfactor,$steps,$rra_rows)",$cnn_id);
		
		if ($id == 0) {
			/* get rraid 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);
			}
		}
		
		$sql_id = mysql_query("delete from lnk_rra_cf where rraid=$id",$cnn_id); $i = 0;
		while ($i < count($consolidationfunctionid)) {
			mysql_query("insert into lnk_rra_cf (rraid,consolidationfunctionid) 
				values ($id,$consolidationfunctionid[$i])",$cnn_id);
			$i++;
		}
		 
		header ("Location: rra.php");
		break;
	case 'remove':
		mysql_query("delete from rrd_rra where id=$id",$cnn_id);
		mysql_query("delete from lnk_ds_rra where rraid=$id",$cnn_id);
		
		header ("Location: rra.php");
		break;
	case 'edit':
		include_once ('include/top_header.php');
		
		if ($id != "") {
			$sql_id = mysql_query("select * from rrd_rra where id=$id", $cnn_id);
			$rra_rows = mysql_result($sql_id, $i, "rows");
		}
		
		DrawFormHeader("rrdtool Round Robin Archive (RRA) Configuration","",false);
		
		DrawFormItem("Name","The name of the RRA, this name is not used by rrdtool.");
		DrawFormItemTextBox("name",$sql_id,"","");
		
		DrawFormItem("Consolidation Functions","How data is to be entered in RRA's.");
		DrawFormItemMultipleList("consolidationfunctionid",$cnn_id,"select * from def_cf","name","id",
			"select * from lnk_rra_cf where rraid=$id","consolidationfunctionid");
		
		DrawFormItem("X-Files Factor","The amount of unknown data that can still be regarded as known.");
		DrawFormItemTextBox("xfilesfactor",$sql_id,"0.5","");
		
		DrawFormItem("Steps","How many data points are needed to put data into the RRA.");
		DrawFormItemTextBox("steps",$sql_id,"","");
		
		DrawFormItem("Rows","How many generations data is kept in the RRA.");
		DrawFormItemTextBox("rra_rows",$rra_rows,"","");
		
		DrawFormSaveButton();
		DrawFormItemHiddenIDField("id",$id);
		DrawFormFooter();
		
		include_once ("include/bottom_footer.php");
		
		break;
	default:
		include_once ('include/top_header.php');
		
		DrawMatrixTableBegin("97%");
		DrawMatrixRowBegin();
			DrawMatrixHeaderTop("Current Round Robin Archives (RRA's)",$color_dark_bar,"","3");
			DrawMatrixHeaderAdd($color_dark_bar,"","rra.php?action=edit");
		DrawMatrixRowEnd();
		
		DrawMatrixRowBegin();
			DrawMatrixHeaderItem("Name",$color_panel,$color_panel_text);
			DrawMatrixHeaderItem("Steps",$color_panel,$color_panel_text);
			DrawMatrixHeaderItem("Rows",$color_panel,$color_panel_text);
			DrawMatrixHeaderItem("",$color_panel,$color_panel_text);
		DrawMatrixRowEnd();
		
		$sql_id = mysql_query("select id,name,rows,steps from rrd_rra order by steps", $cnn_id);
		$rows = mysql_num_rows($sql_id); $i = 0;
		
		while ($i < $rows) { 
			DrawMatrixRowAlternateColorBegin($color_alternate,$color_light,$i);
				DrawMatrixLoopItem($sql_id,"name",$i,html_boolean($config["vis_main_column_bold"]["value"]),"rra.php?action=edit&id=" . mysql_result($sql_id, $i, "id"));
				DrawMatrixLoopItem($sql_id,"steps",$i,false,"");
				DrawMatrixLoopItem($sql_id,"rows",$i,false,"");
				DrawMatrixLoopItemAction("Remove",$color_panel,"",false,"rra.php?action=remove&id=" . mysql_result($sql_id, $i, "id"));
			DrawMatrixRowEnd();
			$i++;
		}
		
		DrawMatrixTableEnd();
		include_once ("include/bottom_footer.php");
		
		break;
} ?>