1 diff -ruBbd cacti-0.8.7g/lib/database.php cacti-0.8.7g-patched/lib/database.php
2 --- cacti-0.8.7g/lib/database.php 2010-07-09 18:33:46.000000000 -0400
3 +++ cacti-0.8.7g-patched/lib/database.php 2010-08-31 20:31:22.000000000 -0400
5 $cnn = NewADOConnection($db_type);
6 $class = get_class($cnn);
8 - if (!is_a($cnn_id, $class)) {
12 $hostport = $host . ":" . $port;
14 while ($i <= $retries) {
15 if ($cnn->PConnect($hostport,$user,$pass,$db_name)) {
16 + if (!is_a($cnn_id, $class)) {
25 $query = $db_conn->Execute($sql);
27 - if (($query) || ($db_conn->ErrorNo() == 1032)) {
28 + if (($db_conn->ErrorNo() == 0) || ($db_conn->ErrorNo() == 1032)) {
30 }else if (($db_conn->ErrorNo() == 1049) || ($db_conn->ErrorNo() == 1051)) {
31 printf("FATAL: Database or Table does not exist");
34 $query = $db_conn->Execute($sql);
36 - if (($query) || ($db_conn->ErrorNo() == 1032)) {
37 + if (($db_conn->ErrorNo() == 0) || ($db_conn->ErrorNo() == 1032)) {
39 if ($col_name != '') {
40 $column = $query->fields[$col_name];
42 $db_conn->SetFetchMode(ADODB_FETCH_ASSOC);
43 $query = $db_conn->Execute($sql);
45 - if (($query) || ($db_conn->ErrorNo() == 1032)) {
46 + if (($db_conn->ErrorNo() == 0) || ($db_conn->ErrorNo() == 1032)) {
48 $fields = $query->fields;
51 $db_conn->SetFetchMode(ADODB_FETCH_ASSOC);
52 $query = $db_conn->Execute($sql);
54 - if (($query) || ($db_conn->ErrorNo() == 1032)) {
55 + if (($db_conn->ErrorNo() == 0) || ($db_conn->ErrorNo() == 1032)) {
56 while ((!$query->EOF) && ($query)) {
57 $data{sizeof($data)} = $query->fields;
59 diff -ruBbd cacti-0.8.7g/poller.php cacti-0.8.7g-patched/poller.php
60 --- cacti-0.8.7g/poller.php 2010-07-09 18:33:46.000000000 -0400
61 +++ cacti-0.8.7g-patched/poller.php 2010-08-31 20:31:22.000000000 -0400
65 /* record the start time */
66 -list($micro,$seconds) = split(" ", microtime());
67 +list($micro,$seconds) = explode(" ", microtime());
68 $poller_start = $seconds + $micro;
72 WHERE rrd_next_step<=0
74 ORDER BY host_id"), "host_id", "data_sources");
75 - $poller_runs = $cron_interval / $poller_interval;
76 + $poller_runs = intval($cron_interval / $poller_interval);
78 define("MAX_POLLER_RUNTIME", $poller_runs * $poller_interval - 2);
82 $poller_runs_completed = 0;
83 $poller_items_total = 0;
84 +$polling_hosts = array_merge(array(0 => array("id" => "0")), db_fetch_assoc("SELECT id FROM host WHERE disabled='' ORDER BY id"));
86 while ($poller_runs_completed < $poller_runs) {
87 /* record the start time for this loop */
88 - list($micro,$seconds) = split(" ", microtime());
89 + list($micro,$seconds) = explode(" ", microtime());
90 $loop_start = $seconds + $micro;
92 /* calculate overhead time */
94 $overhead_time = $loop_start - $poller_start;
97 - $polling_hosts = array_merge(array(0 => array("id" => "0")), db_fetch_assoc("SELECT id FROM host WHERE disabled = '' ORDER BY id"));
99 /* initialize counters for script file handling */
106 - if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_MEDIUM) {
107 + if (read_config_option("log_verbosity") >= POLLER_VERBOSITY_MEDIUM || $debug) {
108 print "Waiting on " . ($started_processes - $finished_processes) . " of " . $started_processes . " pollers.\n";
120 @@ -427,28 +426,27 @@
121 $poller_runs_completed++;
123 /* record the start time for this loop */
124 - list($micro,$seconds) = split(" ", microtime());
125 + list($micro,$seconds) = explode(" ", microtime());
126 $loop_end = $seconds + $micro;
127 + $loop_time = $loop_end - $loop_start;
129 - if (($loop_end - $loop_start) < $poller_interval) {
130 + if ($loop_time < $poller_interval) {
131 if ($poller_runs_completed == 1) {
132 - $sleep_time = ($poller_interval - ($loop_end - $loop_start) - $overhead_time);
134 - $sleep_time = ($poller_interval - ($loop_end - $loop_start));
135 + $sleep_time = $poller_interval - $loop_time - $overhead_time;
137 + $sleep_time = $poller_interval - $loop_time;
140 /* log some nice debug information */
141 - if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_DEBUG) {
142 - echo "Loop Time is: " . ($loop_end - $loop_start) . "\n";
143 - echo "Sleep Time is: " . $sleep_time . "\n";
144 - echo "Total Time is: " . ($loop_end - $poller_start) . "\n";
145 + if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_DEBUG || $debug) {
146 + echo "Loop Time is: " . round($loop_time, 2) . "\n";
147 + echo "Sleep Time is: " . round($sleep_time, 2) . "\n";
148 + echo "Total Time is: " . round($loop_end - $poller_start, 2) . "\n";
151 /* sleep the appripriate amount of time */
152 if ($poller_runs_completed < $poller_runs) {
154 usleep($sleep_time * 1000000);
155 - db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
157 }else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM || $debug) {
158 cacti_log("WARNING: Cacti Polling Cycle Exceeded Poller Interval by " . $loop_end-$loop_start-$poller_interval . " seconds", TRUE, "POLLER");
160 $hosts_per_process, $num_polling_items, $rrds_processed) {
162 /* take time and log performance data */
163 - list($micro,$seconds) = split(" ", microtime());
164 + list($micro,$seconds) = explode(" ", microtime());
165 $loop_end = $seconds + $micro;
167 $cacti_stats = sprintf(