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";
121 @@ -430,29 +430,28 @@
122 $poller_runs_completed++;
124 /* record the start time for this loop */
125 - list($micro,$seconds) = split(" ", microtime());
126 + list($micro,$seconds) = explode(" ", microtime());
127 $loop_end = $seconds + $micro;
128 + $loop_time = $loop_end - $loop_start;
130 - if (($loop_end - $loop_start) < $poller_interval) {
131 + if ($loop_time < $poller_interval) {
132 if ($poller_runs_completed == 1) {
133 - $sleep_time = ($poller_interval - ($loop_end - $loop_start) - $overhead_time);
135 - $sleep_time = ($poller_interval - ($loop_end - $loop_start));
138 + $sleep_time = $poller_interval - $loop_time - $overhead_time;
140 + $sleep_time = $poller_interval - $loop_time;
143 /* log some nice debug information */
144 - if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_DEBUG) {
145 - echo "Loop Time is: " . ($loop_end - $loop_start) . "\n";
146 - echo "Sleep Time is: " . $sleep_time . "\n";
147 - echo "Total Time is: " . ($loop_end - $poller_start) . "\n";
148 + if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_DEBUG || $debug) {
149 + echo "Loop Time is: " . round($loop_time, 2) . "\n";
150 + echo "Sleep Time is: " . round($sleep_time, 2) . "\n";
151 + echo "Total Time is: " . round($loop_end - $poller_start, 2) . "\n";
154 /* sleep the appripriate amount of time */
155 if ($poller_runs_completed < $poller_runs) {
156 api_plugin_hook('poller_bottom');
158 usleep($sleep_time * 1000000);
159 - db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
160 api_plugin_hook('poller_top');
162 }else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM || $debug) {
165 $hosts_per_process, $num_polling_items, $rrds_processed) {
167 /* take time and log performance data */
168 - list($micro,$seconds) = split(" ", microtime());
169 + list($micro,$seconds) = explode(" ", microtime());
170 $loop_end = $seconds + $micro;
172 $cacti_stats = sprintf(