|
|
| Author |
Message |
oxo-oxo Cacti User
Joined: 30 Aug 2007 Posts: 106 Location: Silkeborg, Denmark
|
|
| Back to top |
|
 |
shull Cacti User
Joined: 24 Aug 2006 Posts: 54 Location: South Texas
|
Posted: Fri Sep 07, 2007 12:27 pm Post subject: |
|
|
So this one RRD file will possibly contain many sets of data within one (larger) RRA? If so, that's pretty cool. It would definitly help in the organization of the files.
-Stephen
|
|
| Back to top |
|
 |
oxo-oxo Cacti User
Joined: 30 Aug 2007 Posts: 106 Location: Silkeborg, Denmark
|
Posted: Fri Sep 07, 2007 12:31 pm Post subject: |
|
|
No, sorry.
| Code: |
"<path_rra>/$host_part$ds_part" . "/" . "$local_data_id.rrd";
|
a number of host_ds directories, each containing a number of rrd directories
But means the root of <path_rra> isn't as cluttered.
|
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Fri Sep 07, 2007 12:48 pm Post subject: |
|
|
Already been done. Look to add-on's and you will find it. I think it's something like "structured rrd path patch".
TheWitness
|
|
| Back to top |
|
 |
oxo-oxo Cacti User
Joined: 30 Aug 2007 Posts: 106 Location: Silkeborg, Denmark
|
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Fri Sep 07, 2007 4:44 pm Post subject: |
|
|
Ok, cool. 0.8.7. Hmm. That was the "other" 0.8.7
TheWitness
|
|
| Back to top |
|
 |
oxo-oxo Cacti User
Joined: 30 Aug 2007 Posts: 106 Location: Silkeborg, Denmark
|
Posted: Sat Sep 08, 2007 12:57 pm Post subject: |
|
|
functions for making dirs
POLLER_COMMAND for instructing the poller to make dirs via insert poller_command
Seperator $sep added for _ or /
"Hidden" $config["oxo_rrd_dir"] to control $sep and insert poller_command
| Code: |
Index: cacti.sql
===================================================================
--- cacti.sql (revision 4134)
+++ cacti.sql (working copy)
@@ -2041,11 +2041,12 @@
--
CREATE TABLE poller_command (
+ id mediumint(8) unsigned NOT NULL auto_increment,
poller_id smallint(5) unsigned NOT NULL default '0',
time datetime NOT NULL default '0000-00-00 00:00:00',
action tinyint(3) unsigned NOT NULL default '0',
command varchar(200) NOT NULL default '',
- PRIMARY KEY (poller_id,action,command)
+ PRIMARY KEY (id)
) TYPE=MyISAM;
--
@@ -2619,4 +2620,4 @@
-- Dumping data for table `version`
--
-INSERT INTO version VALUES ('new_install');
\ No newline at end of file
+INSERT INTO version VALUES ('new_install');
Index: lib/functions.php
===================================================================
--- lib/functions.php (revision 4134)
+++ lib/functions.php (working copy)
@@ -943,13 +943,25 @@
@arg $local_data_id - (int) the ID of the data source to generate a new path for
@returns - the new generated path */
function generate_data_source_path($local_data_id) {
+ global $config;
+
$host_part = ""; $ds_part = "";
+ if (isset($config["oxo_rrd_dir"])) {
+ if ($config["cacti_server_os"] == "unix") {
+ $sep = '/';
+ }else{
+ $sep = '\\'; //untested for Windows
+ }
+ }else{
+ $sep = '_';
+ }
+
/* try any prepend the name with the host description */
$host_name = db_fetch_cell("select host.description from (host,data_local) where data_local.host_id=host.id and data_local.id=$local_data_id");
if (!empty($host_name)) {
- $host_part = strtolower(clean_up_file_name($host_name)) . "_";
+ $host_part = strtolower(clean_up_file_name($host_name)) . $sep;
}
/* then try and use the internal DS name to identify it */
@@ -962,7 +974,7 @@
}
/* put it all together using the local_data_id at the end */
- $new_path = "<path_rra>/$host_part$ds_part" . "_" . "$local_data_id.rrd";
+ $new_path = "<path_rra>" . $sep . $host_part . $ds_part . $sep . $local_data_id . ".rrd";
/* update our changes to the db */
db_execute("update data_template_data set data_source_path='$new_path' where local_data_id=$local_data_id");
@@ -970,6 +982,31 @@
return $new_path;
}
+/* generate_data_source_dirs - creates data source directory path for a $rrc_path
+ @arg rrd_path - (string) the path of the rrd
+ @returns - true if OK (found or created */
+#OXO
+function generate_data_source_dirs($rrd_path) {
+ /* strip filename if there: however is it good enough just to test for . ? */
+ strstr($rrd_path, '.') ? $nextdir = dirname($rrd_path) : $nextdir = $rrd_path;
+ @mkdir($nextdir,0777,true);
+ return file_exists($nextdir);
+}
+
+/* makeDirs - takes a path (without filename) and makes the path
+ @arg $strPath - (string) the path without filename
+ @arg $mode - (int) mode for creation, default 0776
+ @returns - I hope. Not to good: could go forever : need test for stop... */
+function makeDirs($strPath, $mode = 0766) {
+ $pardir = dirname($strPath);
+ if (!(($strPath == '/') || ($strPath == '.'))){
+ makeDirs($pardir, $mode);
+ }
+ echo "$strPath\n";
+ chdir($pardir);
+ return @mkdir($strPath, $mode);
+}
+
/* generate_graph_def_name - takes a number and turns each digit into its letter-based
counterpart for RRDTool DEF names (ex 1 -> a, 2 -> b, etc)
@arg $graph_item_id - (int) the ID to generate a letter-based representation of
Index: lib/api_poller.php
===================================================================
--- lib/api_poller.php (revision 4134)
+++ lib/api_poller.php (working copy)
@@ -23,6 +23,8 @@
*/
function api_poller_cache_item_add($host_id, $host_field_override, $local_data_id, $rrd_step, $poller_action_id, $data_source_item_name, $num_rrd_items, $arg1 = "", $arg2 = "", $arg3 = "") {
+ global $config;
+
$host = db_fetch_row("select
host.id,
host.hostname,
@@ -75,7 +77,13 @@
}
$rrd_next_step = api_poller_get_rrd_next_step($rrd_step, $num_rrd_items);
+#OXO
+ $rrd_path = addslashes(clean_up_path(get_data_source_path($local_data_id, true)));
+ if (isset($config["oxo_rrd_dir"])) {
+ db_execute("insert into poller_command (poller_id, time, action, command) values (0, NOW(), " . POLLER_COMMAND_MAKE_RDD_DIRS . ",'" . $rrd_path . "')");
+ }
+
return db_execute("INSERT INTO poller_item (local_data_id, host_id, action,hostname,
snmp_community, snmp_version, snmp_timeout, snmp_username, snmp_password,
snmp_auth_protocol, snmp_priv_passphrase, snmp_priv_protocol, snmp_port, rrd_name, rrd_path,
@@ -85,7 +93,7 @@
'" . $host["snmp_community"] . "', '" . $host["snmp_version"] . "', '" . $host["snmp_timeout"] . "',
'" . $host["snmp_username"] . "', '" . $host["snmp_password"] . "', '" . $host["snmp_auth_protocol"] . "',
'" . $host["snmp_priv_passphrase"] . "', '" . $host["snmp_priv_protocol"] . "',
- '" . $host["snmp_port"] . "', '$data_source_item_name', '" . addslashes(clean_up_path(get_data_source_path($local_data_id, true))) . "',
+ '" . $host["snmp_port"] . "', '$data_source_item_name', '" . $rrd_path . "',
'$num_rrd_items', '$rrd_step', '$rrd_next_step', '$arg1', '$arg2', '$arg3')");
}
}
@@ -136,4 +144,4 @@
return $rrd_next_step;
}
-?>
\ No newline at end of file
+?>
Index: include/global_constants.php
===================================================================
--- include/global_constants.php (revision 4134)
+++ include/global_constants.php (working copy)
@@ -61,6 +61,7 @@
define("POLLER_COMMAND_REINDEX", 1);
define("POLLER_COMMAND_RRDPURGE", 2);
+define("POLLER_COMMAND_MAKE_RDD_DIRS", 3);
define("POLLER_VERBOSITY_NONE", 1);
define("POLLER_VERBOSITY_LOW", 2);
@@ -162,4 +163,4 @@
define("SNMP_CMDPHP", 1);
define("SNMP_WEBUI", 2);
-?>
\ No newline at end of file
+?>
Index: include/global.php
===================================================================
--- include/global.php (revision 4134)
+++ include/global.php (working copy)
@@ -180,4 +180,7 @@
/* current cacti version */
$config["cacti_version"] = "0.8.7";
+/* oxo hack */
+
+$config["oxo_rrd_dir"] = "1";
?>
Index: poller_commands.php
===================================================================
--- poller_commands.php (revision 4134)
+++ poller_commands.php (working copy)
@@ -37,21 +37,24 @@
include_once($config["base_path"] . "/lib/poller.php");
include_once($config["base_path"] . "/lib/data_query.php");
include_once($config["base_path"] . "/lib/rrd.php");
+include_once($config["base_path"] . "/lib/functions.php");
/* Record Start Time */
list($micro,$seconds) = split(" ", microtime());
$start = $seconds + $micro;
$poller_commands = db_fetch_assoc("select
+ poller_command.id,
poller_command.action,
poller_command.command
from poller_command
- where poller_command.poller_id=0");
+ where poller_command.poller_id=0 limit 0, 9");
$last_host_id = 0;
$first_host = true;
$recached_hosts = 0;
+#OXO
if (sizeof($poller_commands) > 0) {
foreach ($poller_commands as $command) {
switch ($command["action"]) {
@@ -79,6 +82,16 @@
cacti_log("Host[$host_id] RECACHE: Re-cache successful.", true, "PCOMMAND");
}
break;
+ case POLLER_COMMAND_MAKE_RDD_DIRS:
+ $rrd_path = $command["command"];
+ if (generate_data_source_dirs($rrd_path)) {
+ if (read_config_option("log_verbosity") == POLLER_VERBOSITY_DEBUG) {
+ cacti_log("$rrd_path MAKE_RDD_PATHS: Make dirs successful. MAYBE", true, "PCOMMAND");
+ }
+ } else {
+ cacti_log("ERROR: MAKE_RDD_DIRS " . $rrd_path, true, "PCOMMAND");
+ }
+ break;
default:
cacti_log("ERROR: Unknown poller command issued", true, "PCOMMAND");
}
@@ -92,9 +105,10 @@
cacti_log("ERROR: Poller Command processing timed out after processing '" . $command . "'",true,"PCOMMAND");
break;
}
+ db_execute("delete from poller_command where id=" . $command["id"]);
}
-
- db_execute("delete from poller_command where poller_id=0");
+
+ #db_execute("delete from poller_command where poller_id=0");
}
/* take time to log performance data */
|
Last edited by oxo-oxo on Mon Sep 10, 2007 2:21 pm; edited 12 times in total |
|
| Back to top |
|
 |
oxo-oxo Cacti User
Joined: 30 Aug 2007 Posts: 106 Location: Silkeborg, Denmark
|
Posted: Mon Sep 10, 2007 10:19 am Post subject: |
|
|
Suk ...
| Code: | Index: cacti.sql
===================================================================
--- cacti.sql (revision 4134)
+++ cacti.sql (working copy)
@@ -2041,11 +2041,12 @@
--
CREATE TABLE poller_command (
+ id mediumint(8) unsigned NOT NULL auto_increment,
poller_id smallint(5) unsigned NOT NULL default '0',
time datetime NOT NULL default '0000-00-00 00:00:00',
action tinyint(3) unsigned NOT NULL default '0',
command varchar(200) NOT NULL default '',
- PRIMARY KEY (poller_id,action,command)
+ PRIMARY KEY (id)
) TYPE=MyISAM;
--
@@ -2619,4 +2620,4 @@
-- Dumping data for table `version`
--
-INSERT INTO version VALUES ('new_install');
\ No newline at end of file
+INSERT INTO version VALUES ('new_install'); |
|
|
| Back to top |
|
 |
oxo-oxo Cacti User
Joined: 30 Aug 2007 Posts: 106 Location: Silkeborg, Denmark
|
Posted: Mon Sep 10, 2007 2:04 pm Post subject: |
|
|
Start of:
| Quote: | | Cacti Rebuild RRD DIR Script 1.0, Copyright 2007 - The Cacti Group |
| Code: | <?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2007 The Cacti Group |
?> |
But cut out here as it comes in a latter post...
Last edited by oxo-oxo on Mon Sep 10, 2007 3:33 pm; edited 1 time in total |
|
| Back to top |
|
 |
oxo-oxo Cacti User
Joined: 30 Aug 2007 Posts: 106 Location: Silkeborg, Denmark
|
Posted: Mon Sep 10, 2007 2:41 pm Post subject: |
|
|
For the masacistic (now I do need a txt file for the dirs):
| Quote: | -bash-3.1$ ls -R rra
rra:
2
rra/2:
173 174 175 177 179
rra/2/173:
59.rrd
rra/2/174:
60.rrd
rra/2/175:
61.rrd
rra/2/177:
62.rrd
rra/2/179:
63.rrd |
| Code: | Index: cacti.sql
===================================================================
--- cacti.sql (revision 4134)
+++ cacti.sql (working copy)
@@ -2041,11 +2041,12 @@
--
CREATE TABLE poller_command (
+ id mediumint(8) unsigned NOT NULL auto_increment,
poller_id smallint(5) unsigned NOT NULL default '0',
time datetime NOT NULL default '0000-00-00 00:00:00',
action tinyint(3) unsigned NOT NULL default '0',
command varchar(200) NOT NULL default '',
- PRIMARY KEY (poller_id,action,command)
+ PRIMARY KEY (id)
) TYPE=MyISAM;
--
@@ -2619,4 +2620,4 @@
-- Dumping data for table `version`
--
-INSERT INTO version VALUES ('new_install');
\ No newline at end of file
+INSERT INTO version VALUES ('new_install');
Index: lib/functions.php
===================================================================
--- lib/functions.php (revision 4134)
+++ lib/functions.php (working copy)
@@ -943,17 +943,29 @@
@arg $local_data_id - (int) the ID of the data source to generate a new path for
@returns - the new generated path */
function generate_data_source_path($local_data_id) {
+ global $config;
+
$host_part = ""; $ds_part = "";
+ if (isset($config["oxo_rrd_dir"])) {
+ if ($config["cacti_server_os"] == "unix") {
+ $sep = '/';
+ }else{
+ $sep = '\\'; //untested for Windows
+ }
+ }else{
+ $sep = '_';
+ }
+
/* try any prepend the name with the host description */
- $host_name = db_fetch_cell("select host.description from (host,data_local) where data_local.host_id=host.id and data_local.id=$local_data_id");
+ $host_name = db_fetch_cell("select host.id from (host,data_local) where data_local.host_id=host.id and data_local.id=$local_data_id");
if (!empty($host_name)) {
- $host_part = strtolower(clean_up_file_name($host_name)) . "_";
+ $host_part = strtolower(clean_up_file_name($host_name)) . $sep;
}
/* then try and use the internal DS name to identify it */
- $data_source_rrd_name = db_fetch_cell("select data_source_name from data_template_rrd where local_data_id=$local_data_id order by id");
+ $data_source_rrd_name = db_fetch_cell("select id from data_template_rrd where local_data_id=$local_data_id order by id");
if (!empty($data_source_rrd_name)) {
$ds_part = strtolower(clean_up_file_name($data_source_rrd_name));
@@ -962,7 +974,7 @@
}
/* put it all together using the local_data_id at the end */
- $new_path = "<path_rra>/$host_part$ds_part" . "_" . "$local_data_id.rrd";
+ $new_path = "<path_rra>" . $sep . $host_part . $ds_part . $sep . $local_data_id . ".rrd";
/* update our changes to the db */
db_execute("update data_template_data set data_source_path='$new_path' where local_data_id=$local_data_id");
@@ -970,6 +982,31 @@
return $new_path;
}
+/* generate_data_source_dirs - creates data source directory path for a $rrc_path
+ @arg rrd_path - (string) the path of the rrd
+ @returns - true if OK (found or created */
+#OXO
+function generate_data_source_dirs($rrd_path) {
+ /* strip filename if there: however is it good enough just to test for . ? */
+ strstr($rrd_path, '.') ? $nextdir = dirname($rrd_path) : $nextdir = $rrd_path;
+ @mkdir($nextdir,0777,true);
+ return file_exists($nextdir);
+}
+
+/* makeDirs - takes a path (without filename) and makes the path
+ @arg $strPath - (string) the path without filename
+ @arg $mode - (int) mode for creation, default 0776
+ @returns - I hope. Not to good: could go forever : need test for stop... */
+function makeDirs($strPath, $mode = 0766) {
+ $pardir = dirname($strPath);
+ if (!(($strPath == '/') || ($strPath == '.'))){
+ makeDirs($pardir, $mode);
+ }
+ echo "$strPath\n";
+ chdir($pardir);
+ return @mkdir($strPath, $mode);
+}
+
/* generate_graph_def_name - takes a number and turns each digit into its letter-based
counterpart for RRDTool DEF names (ex 1 -> a, 2 -> b, etc)
@arg $graph_item_id - (int) the ID to generate a letter-based representation of
Index: lib/api_poller.php
===================================================================
--- lib/api_poller.php (revision 4134)
+++ lib/api_poller.php (working copy)
@@ -23,6 +23,8 @@
*/
function api_poller_cache_item_add($host_id, $host_field_override, $local_data_id, $rrd_step, $poller_action_id, $data_source_item_name, $num_rrd_items, $arg1 = "", $arg2 = "", $arg3 = "") {
+ global $config;
+
$host = db_fetch_row("select
host.id,
host.hostname,
@@ -75,7 +77,13 @@
}
$rrd_next_step = api_poller_get_rrd_next_step($rrd_step, $num_rrd_items);
+#OXO
+ $rrd_path = addslashes(clean_up_path(get_data_source_path($local_data_id, true)));
+ if (isset($config["oxo_rrd_dir"])) {
+ db_execute("insert into poller_command (poller_id, time, action, command) values (0, NOW(), " . POLLER_COMMAND_MAKE_RDD_DIRS . ",'" . $rrd_path . "')");
+ }
+
return db_execute("INSERT INTO poller_item (local_data_id, host_id, action,hostname,
snmp_community, snmp_version, snmp_timeout, snmp_username, snmp_password,
snmp_auth_protocol, snmp_priv_passphrase, snmp_priv_protocol, snmp_port, rrd_name, rrd_path,
@@ -85,7 +93,7 @@
'" . $host["snmp_community"] . "', '" . $host["snmp_version"] . "', '" . $host["snmp_timeout"] . "',
'" . $host["snmp_username"] . "', '" . $host["snmp_password"] . "', '" . $host["snmp_auth_protocol"] . "',
'" . $host["snmp_priv_passphrase"] . "', '" . $host["snmp_priv_protocol"] . "',
- '" . $host["snmp_port"] . "', '$data_source_item_name', '" . addslashes(clean_up_path(get_data_source_path($local_data_id, true))) . "',
+ '" . $host["snmp_port"] . "', '$data_source_item_name', '" . $rrd_path . "',
'$num_rrd_items', '$rrd_step', '$rrd_next_step', '$arg1', '$arg2', '$arg3')");
}
}
@@ -136,4 +144,4 @@
return $rrd_next_step;
}
-?>
\ No newline at end of file
+?>
Index: include/global_constants.php
===================================================================
--- include/global_constants.php (revision 4134)
+++ include/global_constants.php (working copy)
@@ -61,6 +61,7 @@
define("POLLER_COMMAND_REINDEX", 1);
define("POLLER_COMMAND_RRDPURGE", 2);
+define("POLLER_COMMAND_MAKE_RDD_DIRS", 3);
define("POLLER_VERBOSITY_NONE", 1);
define("POLLER_VERBOSITY_LOW", 2);
@@ -162,4 +163,4 @@
define("SNMP_CMDPHP", 1);
define("SNMP_WEBUI", 2);
-?>
\ No newline at end of file
+?>
Index: include/global.php
===================================================================
--- include/global.php (revision 4134)
+++ include/global.php (working copy)
@@ -180,4 +180,7 @@
/* current cacti version */
$config["cacti_version"] = "0.8.7";
+/* oxo hack */
+
+$config["oxo_rrd_dir"] = "1";
?>
Index: poller_commands.php
===================================================================
--- poller_commands.php (revision 4134)
+++ poller_commands.php (working copy)
@@ -37,21 +37,24 @@
include_once($config["base_path"] . "/lib/poller.php");
include_once($config["base_path"] . "/lib/data_query.php");
include_once($config["base_path"] . "/lib/rrd.php");
+include_once($config["base_path"] . "/lib/functions.php");
/* Record Start Time */
list($micro,$seconds) = split(" ", microtime());
$start = $seconds + $micro;
$poller_commands = db_fetch_assoc("select
+ poller_command.id,
poller_command.action,
poller_command.command
from poller_command
- where poller_command.poller_id=0");
+ where poller_command.poller_id=0 limit 0, 9");
$last_host_id = 0;
$first_host = true;
$recached_hosts = 0;
+#OXO
if (sizeof($poller_commands) > 0) {
foreach ($poller_commands as $command) {
switch ($command["action"]) {
@@ -79,6 +82,16 @@
cacti_log("Host[$host_id] RECACHE: Re-cache successful.", true, "PCOMMAND");
}
break;
+ case POLLER_COMMAND_MAKE_RDD_DIRS:
+ $rrd_path = $command["command"];
+ if (generate_data_source_dirs($rrd_path)) {
+ if (read_config_option("log_verbosity") == POLLER_VERBOSITY_DEBUG) {
+ cacti_log("$rrd_path MAKE_RDD_PATHS: Make dirs successful. MAYBE", true, "PCOMMAND");
+ }
+ } else {
+ cacti_log("ERROR: MAKE_RDD_DIRS " . $rrd_path, true, "PCOMMAND");
+ }
+ break;
default:
cacti_log("ERROR: Unknown poller command issued", true, "PCOMMAND");
}
@@ -92,9 +105,10 @@
cacti_log("ERROR: Poller Command processing timed out after processing '" . $command . "'",true,"PCOMMAND");
break;
}
+ db_execute("delete from poller_command where id=" . $command["id"]);
}
-
- db_execute("delete from poller_command where poller_id=0");
+
+ #db_execute("delete from poller_command where poller_id=0");
}
/* take time to log performance data */ |
|
|
| Back to top |
|
 |
oxo-oxo Cacti User
Joined: 30 Aug 2007 Posts: 106 Location: Silkeborg, Denmark
|
Posted: Mon Sep 10, 2007 3:15 pm Post subject: |
|
|
Generating documentation in an rrd dir was ok so here it is with the rebuild rrd_paths
One may need to filter the info
| Quote: | -bash-3.1$ cat rra/2/173/59.rrd.txt
Array
(
[local_data_id] => 59
[poller_id] => 0
[host_id] => 2
[action] => 1
[hostname] => localhost
[snmp_community] => public
[snmp_version] => 2
[snmp_username] =>
[snmp_password] =>
[snmp_auth_protocol] => MD5
[snmp_priv_passphrase] =>
[snmp_priv_protocol] => DES
[snmp_port] => 161
[snmp_timeout] => 500
[rrd_name] => mem_buffers
[rrd_path] => /var/www/html/cacti/rra/2/173/59.rrd
[rrd_num] => 1
[rrd_step] => 300
[rrd_next_step] => 0
[arg1] => perl /var/www/html/cacti/scripts/linux_memory.pl MemFree:
[arg2] =>
[arg3] =>
) |
| Quote: | -bash-3.1$ ls -R rra
rra:
2
rra/2:
173 174 175 177 179
rra/2/173:
59.rrd 59.rrd.txt
rra/2/174:
60.rrd 60.rrd.txt
rra/2/175:
61.rrd 61.rrd.txt
rra/2/177:
62.rrd 62.rrd.txt
rra/2/179:
63.rrd 63.rrd.txt |
| Code: | -bash-3.1$ cat cli/rebuild_rrd_dir.php
<?php
/*
+-------------------------------------------------------------------------+
| Copyright (C) 2004-2007 The Cacti Group |
| |
| 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 Complete RRDTool-based Graphing Solution |
+-------------------------------------------------------------------------+
| This code is designed, written, and maintained by the Cacti Group. See |
| about.php and/or the AUTHORS file for specific developer information. |
+-------------------------------------------------------------------------+
| http://www.cacti.net/ |
+-------------------------------------------------------------------------+
*/
/* do NOT run this script through a web browser */
if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD']) || isset($_SERVER['REMOTE_ADDR'])) {
die("<br><strong>This script is only meant to run at the command line.</strong>");
}
$no_http_headers = true;
include(dirname(__FILE__) . "/../include/global.php");
include_once($config["base_path"] . "/lib/utility.php");
/* process calling arguments */
$parms = $_SERVER["argv"];
array_shift($parms);
$debug = FALSE;
foreach($parms as $parameter) {
@list($arg, $value) = @explode("=", $parameter);
switch ($arg) {
case "-d":
$debug = TRUE;
break;
case "-h":
display_help();
exit;
case "-v":
display_help();
exit;
case "--version":
display_help();
exit;
case "--help":
display_help();
exit;
default:
print "ERROR: Invalid Parameter " . $parameter . "\n\n";
display_help();
exit;
}
}
/* obtain timeout settings */
$max_execution = ini_get("max_execution_time");
$max_memory = ini_get("memory_limit");
/* set new timeout and memory settings */
ini_set("max_execution_time", "0");
ini_set("memory_limit", "64M");
/* get the poller items */
$poller_items = db_fetch_assoc("select * from poller_item");
/* issue warnings and start message if applicable */
print "WARNING: Do not interrupt this script. Rebuilding the RRD directories can take quite some time\n";
debug("There are '" . sizeof($poller_items) . "' poller items to update.");
if (sizeof($poller_items) > 0) {
foreach ($poller_items as $item) {
generate_data_source_dirs($item["rrd_path"]);
$rrd_txt_file = $item["rrd_path"] . ".txt";
$item_array = print_r($item, true);
file_put_contents($rrd_txt_file, $item_array);
}
}
if (!$debug) print "\n";
/* poller cache rebuilt, restore runtime parameters */
ini_set("max_execution_time", $max_execution);
ini_set("memory_limit", $max_memory);
/* display_help - displays the usage of the function */
function display_help () {
print "Cacti Rebuild RRD DIR Script 1.0, Copyright 2007 - The Cacti Group\n\n";
print "usage: rebuild_rrd_dir.php [-d] [-h] [--help] [-v] [--version]\n\n";
print "-d - Display verbose output during execution\n";
print "-v --version - Display this help message\n";
print "-h --help - Display this help message\n";
}
function debug($message) {
global $debug;
if ($debug) {
print("DEBUG: " . $message . "\n");
}
}
?> |
| Quote: | RRDTool Command:
/usr/bin/rrdtool graph - \
--imgformat=PNG \
--start=-86400 \
--end=-300 \
--title="localhost - Memory Usage" \
--rigid \
--base=1000 \
--height=120 \
--width=500 \
--alt-autoscale-max \
--lower-limit=0 \
--vertical-label="kilobytes" \
--slope-mode \
--font TITLE:12: \
--font AXIS:8: \
--font LEGEND:10: \
--font UNIT:8: \
DEF:a="/var/www/html/cacti/rra/2/173/59.rrd":mem_buffers:AVERAGE \
DEF:b="/var/www/html/cacti/rra/2/174/60.rrd":mem_swap:AVERAGE \
CDEF:cdefa=a,1024,* \
CDEF:cdefe=b,1024,* \
AREA:cdefa#FF4105:"Free" \
GPRINT:cdefa:LAST:"Current\:%8.2lf %s" \
GPRINT:cdefa:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:cdefa:MAX:"Maximum\:%8.2lf %s\n" \
AREA:cdefe#FFC73B:"Swap":STACK \
GPRINT:cdefe:LAST:"Current\:%8.2lf %s" \
GPRINT:cdefe:AVERAGE:"Average\:%8.2lf %s" \
GPRINT:cdefe:MAX:"Maximum\:%8.2lf %s"
RRDTool Says:
OK |
Well, if RRDTools says so: it must be so...
|
|
| Back to top |
|
 |
oxo-oxo Cacti User
Joined: 30 Aug 2007 Posts: 106 Location: Silkeborg, Denmark
|
Posted: Tue Sep 11, 2007 2:49 am Post subject: |
|
|
From "The Road Map" http://www.cacti.net/roadmap.php ( Last updated: 2007-09-09 )
Cacti 0.8.8
Release end of 1st Quarter 2008
Major Features
Structured host directories
So it must be coming ....
|
|
| Back to top |
|
 |
Howie Cacti Guru User
Joined: 16 Sep 2004 Posts: 2135 Location: United Kingdom
|
Posted: Wed Nov 21, 2007 3:58 pm Post subject: |
|
|
Just FYI - you can skip the path separator platform checks by using the constant that PHP itself defines: DIRECTORY_SEPARATOR
This is interesting stuff - especially the multiple poller possibilities. I don't have any use for it myself, but it does look interesting!
|
|
| Back to top |
|
 |
rony Developer/Forum Admin
Joined: 17 Nov 2003 Posts: 5448 Location: Wisconsin, USA
|
Posted: Wed Nov 21, 2007 4:01 pm Post subject: |
|
|
It's coming, been a long time waiting for it.
|
|
| Back to top |
|
 |
TheWitness Developer
Joined: 14 May 2002 Posts: 9671 Location: MI, USA
|
Posted: Thu Nov 22, 2007 8:34 am Post subject: |
|
|
Both Boost and Structured RRD paths are planned for 0.8.8. So, yes, coming.
TheWitness
|
|
| Back to top |
|
 |
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|