diff -NaurbB cacti_orig/cmd.php cacti_patch/cmd.php --- cacti_orig/cmd.php 2004-02-24 22:10:04.000000000 +0100 +++ cacti_patch/cmd.php 2004-02-24 22:09:59.000000000 +0100 @@ -34,10 +34,20 @@ include_once($config["base_path"] . "/lib/functions.php"); include_once($config["base_path"] . "/lib/graph_export.php"); +/* FREQ_CMD (in seconds) +depends on crontab : +x/1 * * * * cactiuser php /var/www/html/cacti/cmd.php ===> $FREQ_CMD=60 +x/5 * * * * cactiuser php /var/www/html/cacti/cmd.php ===> $FREQ_CMD=300 +*/ +$FREQ_CMD=60; /* we launch cmd.php every minute */ + $polling_items = db_fetch_assoc("select * from data_input_data_cache"); if (sizeof($polling_items) > 0) { foreach ($polling_items as $item) { + if ($item["next_step"] <= $FREQ_CMD) { + $next_step=$item["rrd_step"] ; + switch ($item["action"]) { case '0': /* snmp */ $output = cacti_snmp_get($item["hostname"], $item["snmp_community"], $item["arg1"], $item["snmp_version"], $item["snmp_username"], $item["snmp_password"], $item["snmp_port"], $item["snmp_timeout"]); @@ -91,7 +101,15 @@ } rrdtool_function_create($item["local_data_id"], false); -} + } else { + $next_step=$item["next_step"] - $FREQ_CMD; + } + /* Update data_input_data_cache for next execution of cmd.php */ + if ($item["rrd_step"] != $FREQ_CMD) { + db_execute("update data_input_data_cache set next_step=" . $next_step . " where local_data_id=" . $item["local_data_id"]); + print "Update poller cache : next_step= " . $next_step . " for " . $item["local_data_id"] ."\n"; + } +} //foreach } if (isset($update_cache_array)) { diff -NaurbB cacti_orig/lib/utility.php cacti_patch/lib/utility.php --- cacti_orig/lib/utility.php 2004-02-24 22:10:04.000000000 +0100 +++ cacti_patch/lib/utility.php 2004-02-24 22:10:00.000000000 +0100 @@ -46,7 +46,8 @@ data_input.type_id, data_template_data.id as data_template_data_id, data_template_data.data_template_id, - data_template_data.active + data_template_data.active, + data_template_data.rrd_step from data_template_data,data_input where data_template_data.data_input_id=data_input.id and data_template_data.local_data_id=$local_data_id"); @@ -131,11 +132,11 @@ if ($action_type) { db_execute("insert into data_input_data_cache (local_data_id,host_id,data_input_id,action,hostname, snmp_community,snmp_version,snmp_timeout,snmp_username,snmp_password,snmp_port,rrd_name,rrd_path, - command,rrd_num) values ($local_data_id," . (empty($host["id"]) ? 0 : $host["id"]) . "," . $data_input["id"] . ",$action_type,'" . $host["hostname"] . "', + command,rrd_num,rrd_step,next_step) values ($local_data_id," . (empty($host["id"]) ? 0 : $host["id"]) . "," . $data_input["id"] . ",$action_type,'" . $host["hostname"] . "', '" . $host["snmp_community"] . "','" . $host["snmp_version"] . "','" . $host["snmp_timeout"] . "', '" . $host["snmp_username"] . "','" . $host["snmp_password"] . "','" . $host["snmp_port"] . "', '" . get_data_source_name($data_template_rrd_id) . "', - '" . addslashes(clean_up_path(get_data_source_path($local_data_id,true))) . "','" . addslashes($command) . "',1)"); + '" . addslashes(clean_up_path(get_data_source_path($local_data_id,true))) . "','" . addslashes($command) . "',1,". $data_input["rrd_step"] . "," . $data_input["rrd_step"] . ")"); } break; @@ -152,11 +153,11 @@ db_execute("insert into data_input_data_cache (local_data_id,host_id,data_input_id,action,hostname, snmp_community,snmp_version,snmp_timeout,snmp_username,snmp_password,snmp_port,rrd_name,rrd_path, - arg1,rrd_num) values ($local_data_id," . (empty($host["id"]) ? 0 : $host["id"]) . "," . $data_input["id"]. ",0,'" . $host["hostname"] . "', + arg1,rrd_num,rrd_step,next_step) values ($local_data_id," . (empty($host["id"]) ? 0 : $host["id"]) . "," . $data_input["id"]. ",0,'" . $host["hostname"] . "', '" . $host["snmp_community"] . "','" . $host["snmp_version"] . "','" . $host["snmp_timeout"] . "', '" . $host["snmp_username"] . "','" . $host["snmp_password"] . "','" . $host["snmp_port"] . "', '" . get_data_source_name($data_template_rrd_id) . "', - '" . addslashes(clean_up_path(get_data_source_path($local_data_id,true,1))) . "','" . $field["snmp_oid"] . "',1)"); + '" . addslashes(clean_up_path(get_data_source_path($local_data_id,true,1))) . "','" . $field["snmp_oid"] . "',1" . $data_input["rrd_step"] . "," . $data_input["rrd_step"] . ")"); break; case '3': /* snmp query */ @@ -171,11 +172,11 @@ if (!empty($oid)) { db_execute("insert into data_input_data_cache (local_data_id,host_id,data_input_id,action,hostname, snmp_community,snmp_version,snmp_timeout,snmp_username,snmp_password,snmp_port,rrd_name,rrd_path, - arg1,rrd_num) values ($local_data_id," . (empty($host["id"]) ? 0 : $host["id"]) . "," . $data_input["id"]. ",0,'" . $host["hostname"] . "', + arg1,rrd_num,rrd_step,next_step) values ($local_data_id," . (empty($host["id"]) ? 0 : $host["id"]) . "," . $data_input["id"]. ",0,'" . $host["hostname"] . "', '" . $host["snmp_community"] . "','" . $host["snmp_version"] . "','" . $host["snmp_timeout"] . "', '" . $host["snmp_username"] . "','" . $host["snmp_password"] . "','" . $host["snmp_port"] . "', '" . get_data_source_name($output["data_template_rrd_id"]) . "', - '" . addslashes(clean_up_path(get_data_source_path($local_data_id,true))) . "','$oid'," . sizeof($outputs) . ")"); + '" . addslashes(clean_up_path(get_data_source_path($local_data_id,true))) . "','$oid'," . sizeof($outputs) . $data_input["rrd_step"] . "," . $data_input["rrd_step"] . ")"); } } } @@ -203,12 +204,12 @@ if (isset($script_path)) { db_execute("insert into data_input_data_cache (local_data_id,host_id,data_input_id,action,hostname, - snmp_community,snmp_version,snmp_timeout,snmp_username,snmp_password,snmp_port,rrd_name,rrd_path,command,rrd_num) values + snmp_community,snmp_version,snmp_timeout,snmp_username,snmp_password,snmp_port,rrd_name,rrd_path,command,rrd_num,rrd_step,next_step) values ($local_data_id," . (empty($host["id"]) ? 0 : $host["id"]) . "," . $data_input["id"]. ",1,'" . $host["hostname"] . "', '" . $host["snmp_community"] . "','" . $host["snmp_version"] . "','" . $host["snmp_timeout"] . "', '" . $host["snmp_username"] . "','" . $host["snmp_password"] . "','" . $host["snmp_port"] . "', '" . get_data_source_name($output["data_template_rrd_id"]) . "', - '" . addslashes(clean_up_path(get_data_source_path($local_data_id,true))) . "','" . addslashes($script_path) . "'," . sizeof($outputs) . ")"); + '" . addslashes(clean_up_path(get_data_source_path($local_data_id,true))) . "','" . addslashes($script_path) . "'," . sizeof($outputs) . $data_input["rrd_step"] . "," . $data_input["rrd_step"] . ")"); } } } diff -NaurbB cacti_orig/utilities.php cacti_patch/utilities.php --- cacti_orig/utilities.php 2004-02-24 22:10:04.000000000 +0100 +++ cacti_patch/utilities.php 2004-02-24 22:09:59.000000000 +0100 @@ -143,6 +143,13 @@ +