]> git.pld-linux.org Git - packages/cacti.git/blame - poller_interval.patch
- Add patch from date 2010/07/27 more info http://www.cacti.net/download_patches.php
[packages/cacti.git] / poller_interval.patch
CommitLineData
a60f27b1
JS
1diff -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
4@@ -38,14 +38,14 @@
5 $cnn = NewADOConnection($db_type);
6 $class = get_class($cnn);
7
8- if (!is_a($cnn_id, $class)) {
9- $cnn_id = $cnn;
10- }
11-
12 $hostport = $host . ":" . $port;
13
14 while ($i <= $retries) {
15 if ($cnn->PConnect($hostport,$user,$pass,$db_name)) {
16+ if (!is_a($cnn_id, $class)) {
17+ $cnn_id = $cnn;
18+ }
19+
20 return($cnn);
21 }
22
23@@ -92,7 +92,7 @@
24 while (1) {
25 $query = $db_conn->Execute($sql);
26
27- if (($query) || ($db_conn->ErrorNo() == 1032)) {
28+ if (($db_conn->ErrorNo() == 0) || ($db_conn->ErrorNo() == 1032)) {
29 return(1);
30 }else if (($db_conn->ErrorNo() == 1049) || ($db_conn->ErrorNo() == 1051)) {
31 printf("FATAL: Database or Table does not exist");
32@@ -143,7 +143,7 @@
33
34 $query = $db_conn->Execute($sql);
35
36- if (($query) || ($db_conn->ErrorNo() == 1032)) {
37+ if (($db_conn->ErrorNo() == 0) || ($db_conn->ErrorNo() == 1032)) {
38 if (!$query->EOF) {
39 if ($col_name != '') {
40 $column = $query->fields[$col_name];
41@@ -184,7 +184,7 @@
42 $db_conn->SetFetchMode(ADODB_FETCH_ASSOC);
43 $query = $db_conn->Execute($sql);
44
45- if (($query) || ($db_conn->ErrorNo() == 1032)) {
46+ if (($db_conn->ErrorNo() == 0) || ($db_conn->ErrorNo() == 1032)) {
47 if (!$query->EOF) {
48 $fields = $query->fields;
49
50@@ -222,7 +222,7 @@
51 $db_conn->SetFetchMode(ADODB_FETCH_ASSOC);
52 $query = $db_conn->Execute($sql);
53
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;
58 $query->MoveNext();
59diff -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
62@@ -109,7 +109,7 @@
63 }
64
65 /* record the start time */
66-list($micro,$seconds) = split(" ", microtime());
67+list($micro,$seconds) = explode(" ", microtime());
68 $poller_start = $seconds + $micro;
69 $overhead_time = 0;
70
71@@ -140,7 +140,7 @@
72 WHERE rrd_next_step<=0
73 GROUP BY host_id
74 ORDER BY host_id"), "host_id", "data_sources");
75- $poller_runs = $cron_interval / $poller_interval;
76+ $poller_runs = intval($cron_interval / $poller_interval);
77
78 define("MAX_POLLER_RUNTIME", $poller_runs * $poller_interval - 2);
79 }else{
80@@ -211,10 +211,11 @@
81
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"));
85
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;
91
92 /* calculate overhead time */
93@@ -222,8 +223,6 @@
94 $overhead_time = $loop_start - $poller_start;
95 }
96
97- $polling_hosts = array_merge(array(0 => array("id" => "0")), db_fetch_assoc("SELECT id FROM host WHERE disabled = '' ORDER BY id"));
98-
99 /* initialize counters for script file handling */
100 $host_count = 1;
101
102@@ -375,7 +374,7 @@
103
104 break;
105 }else {
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";
109 }
110
111@@ -390,7 +389,7 @@
112
113 break;
114 }else{
115- sleep(1);
116+ usleep(500);
117 }
118 }
119 }
e79e3b18
JS
120
121@@ -430,29 +430,28 @@
a60f27b1
JS
122 $poller_runs_completed++;
123
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;
129
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);
134- }else{
135- $sleep_time = ($poller_interval - ($loop_end - $loop_start));
e79e3b18
JS
136- }
137-
138+ $sleep_time = $poller_interval - $loop_time - $overhead_time;
139+ } else {
140+ $sleep_time = $poller_interval - $loop_time;
141+ }
142+
a60f27b1
JS
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";
e79e3b18
JS
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";
a60f27b1
JS
152 }
153
154 /* sleep the appripriate amount of time */
155 if ($poller_runs_completed < $poller_runs) {
e79e3b18 156 api_plugin_hook('poller_bottom');
a60f27b1
JS
157- db_close();
158 usleep($sleep_time * 1000000);
159- db_connect_real($database_hostname, $database_username, $database_password, $database_default, $database_type, $database_port);
e79e3b18 160 api_plugin_hook('poller_top');
a60f27b1
JS
161 }
162 }else if (read_config_option('log_verbosity') >= POLLER_VERBOSITY_MEDIUM || $debug) {
e79e3b18 163
a60f27b1
JS
164@@ -459,7 +457,7 @@
165 $hosts_per_process, $num_polling_items, $rrds_processed) {
166
167 /* take time and log performance data */
168- list($micro,$seconds) = split(" ", microtime());
169+ list($micro,$seconds) = explode(" ", microtime());
170 $loop_end = $seconds + $micro;
171
172 $cacti_stats = sprintf(
173
This page took 0.056818 seconds and 4 git commands to generate.