Cacti (home)ForumsDocumentation
Cacti: offical forums and support
It is currently Thu Mar 23, 2017 7:05 pm

All times are UTC - 5 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Enhance Structured path setting
PostPosted: Tue Oct 20, 2015 3:52 am 
Cacti Guru User
User avatar

Joined: Thu Jan 31, 2008 6:39 am
Posts: 2564
Location: Kressbronn, Germany
Can we change the structured path setting to be more flexible i.e. by providing a template ?

Or at least add the poller_id to the structured path ( example shown below ).

This would allow us to have different storages (iSCSI, harddisks, NFS) for each poller so it scales a lot better.

lib/functions.php ( around line 2237 ):
/* generate_data_source_path - creates a new data source path from scratch using the first data source
     item name and updates the database with the new value
   @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 = "";

        $extended_paths = read_config_option("extended_paths");

        /* try any prepend the name with the host description */
        $host = db_fetch_row("SELECT
                FROM (host, data_local)
                LIMIT 1");

        $host_name = $host["description"];
        $host_id   = $host["id"];
        $host_poller_id = $host["poller_id"];

        /* put it all together using the local_data_id at the end */
        if ($extended_paths == "on") {
                $new_path = "<path_rra>/$host_poller_id/$host_id/$local_data_id.rrd";
                if (!empty($host_name)) {
                        $host_part = strtolower(clean_up_file_name($host_name)) . "_";

                /* 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");

                if (!empty($data_source_rrd_name)) {
                        $ds_part = strtolower(clean_up_file_name($data_source_rrd_name));
                        $ds_part = "ds";

                $new_path = "<path_rra>/$host_part$ds_part" . "_" . "$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");

        return $new_path;

cli/structure_rra_paths.php ( from line 92: )
/* fetch all DS having wrong path */
$data_sources = db_fetch_assoc("SELECT
                                CONCAT('<path_rra>/', poller_id, '/', host_id,'/', local_data_id, '.rrd') AS new_data_source_path,
                                REPLACE(data_source_path, '<path_rra>', '$base_rra_path') AS rrd_path,
                                REPLACE(CONCAT('<path_rra>/', poller_id, '/', host_id, '/', local_data_id, '.rrd'), '<path_rra>', '$base_rra_path') AS new_rrd_path
                                        FROM data_template_data
                                        INNER JOIN data_local ON
                                        INNER JOIN host ON
                                WHERE data_source_path != CONCAT('<path_rra>/', poller_id, '/', host_id, '/', local_data_id, '.rrd')"
                                 . ($hostId === NULL ? "" : " AND host_id=$hostId"));

/* setup some counters */
$done_count   = 0;
$warn_count   = 0;

/* scan all data sources */
foreach ($data_sources as $info) {
        $new_base_path = "$base_rra_path" . "/" . $info["poller_id"] . '/' . $info["host_id"];
        $new_rrd_path  = $info["new_rrd_path"];
        $old_rrd_path  = $info["rrd_path"];

        /* create one subfolder for every host */
        if (!is_dir($new_base_path)) {
                /* see if we can create the dirctory for the new file */
                if (mkdir($new_base_path, 0775, true)) {
                        echo "NOTE: New Directory '$new_base_path' Created for RRD Files\n";

Need more help ? Read the Cacti documentation or my new Cacti Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
Plugins : CereusTransporter | CereusReporting | nmidWebService | nmidSmokeping | nmidWeb2 |

CereusServer Master:  SYSTEM STATS: Time:2.5621 Method:spine Processes:1 Threads:16 Hosts:446 HostsPerProcess:446 DataSources:14683 RRDsProcessed:7573
CereusServer Agent:   SYSTEM STATS: Time:27.4840 Method:spine Processes:1 Threads:8 Hosts:16 HostsPerProcess:16 DataSources:114576 RRDsProcessed:48061

 Post subject: Re: Enhance Structured path setting
PostPosted: Wed Nov 18, 2015 3:32 am 
Cacti User

Joined: Mon Jul 24, 2006 7:20 am
Posts: 50
Location: Braunschweig, Germany
Hi phalek,

now is winter in germany and I will have a look to my plugin. :D
The idea with the structured path setting for the rrd files is good, so i think. I will test to build this in the plugin as an option to use. The idea with the plugin was basic a feature only for local cluster so the rrd files were good reversed to only one NFS storage :roll:
But the other idea is to connect the poller over VPN so the location for the rrd files were better on local poller.

Unhappily I´am not longer works as network admin in a big network infrastructur (switches with snmp), in this time, the plugin work on one real server with 3-4 virtual server and a snmp simulation over java. :oops: In this case the development is not so system near as in last times.

But i will have a look to integrate the structured path setting for the rrd files in one of the next updates.

Best Regards,


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 5 hours

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Protected by Anti-Spam ACP Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group