aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/collectd.inc.php
diff options
context:
space:
mode:
authorPim van den Berg2014-05-03 10:14:49 +0200
committerPim van den Berg2014-05-03 10:14:49 +0200
commitd91e5d3cd62e599b24e13b41a6bb54a2b4afd095 (patch)
tree57df5872a872be89ca1c96427e583eeb4d70521d /inc/collectd.inc.php
parentinc/collectd: consistently return false instead of an empty array or false (diff)
downloadapt-panopticon_cgp-d91e5d3cd62e599b24e13b41a6bb54a2b4afd095.zip
apt-panopticon_cgp-d91e5d3cd62e599b24e13b41a6bb54a2b4afd095.tar.gz
apt-panopticon_cgp-d91e5d3cd62e599b24e13b41a6bb54a2b4afd095.tar.bz2
apt-panopticon_cgp-d91e5d3cd62e599b24e13b41a6bb54a2b4afd095.tar.xz
inc: mv graphs_from_plugin, build_url functions to html.inc.php
They generate html.
Diffstat (limited to '')
-rw-r--r--inc/collectd.inc.php69
1 files changed, 0 insertions, 69 deletions
diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php
index 5927bf6..74595aa 100644
--- a/inc/collectd.inc.php
+++ b/inc/collectd.inc.php
@@ -168,75 +168,6 @@ function plugin_sort($data) {
168 return $data; 168 return $data;
169} 169}
170 170
171# generate graph url's for a plugin of a host
172function graphs_from_plugin($host, $plugin, $overview=false) {
173 global $CONFIG;
174
175 if (!$plugindata = collectd_plugindata($host, $plugin))
176 return false;
177 if (!$plugindata = group_plugindata($plugindata))
178 return false;
179 if (!$plugindata = plugin_sort($plugindata))
180 return false;
181
182 foreach ($plugindata as $items) {
183
184 if (
185 $overview && isset($CONFIG['overview_filter'][$plugin]) &&
186 $CONFIG['overview_filter'][$plugin] !== array_intersect_assoc($CONFIG['overview_filter'][$plugin], $items)
187 ) {
188 continue;
189 }
190
191 $items['h'] = $host;
192
193 $time = array_key_exists($plugin, $CONFIG['time_range'])
194 ? $CONFIG['time_range'][$plugin]
195 : $CONFIG['time_range']['default'];
196
197 if ($CONFIG['graph_type'] == 'canvas') {
198 chdir($CONFIG['webdir']);
199 isset($items['p']) ? $_GET['p'] = $items['p'] : $_GET['p'] = '';
200 isset($items['pi']) ? $_GET['pi'] = $items['pi'] : $_GET['pi'] = '';
201 isset($items['t']) ? $_GET['t'] = $items['t'] : $_GET['t'] = '';
202 isset($items['ti']) ? $_GET['ti'] = $items['ti'] : $_GET['ti'] = '';
203 include $CONFIG['webdir'].'/plugin/'.$plugin.'.php';
204 } else {
205 printf('<a href="%s%s"><img src="%s%s"></a>'."\n",
206 $CONFIG['weburl'],
207 build_url('detail.php', $items, $time),
208 $CONFIG['weburl'],
209 build_url('graph.php', $items, $time)
210 );
211 }
212 }
213}
214
215# generate an url with GET values from $items
216function build_url($base, $items, $s=NULL) {
217 global $CONFIG;
218
219 if (!is_array($items))
220 return false;
221
222 if (!is_numeric($s))
223 $s = $CONFIG['time_range']['default'];
224
225 $i=0;
226 foreach ($items as $key => $value) {
227 # don't include empty values
228 if ($value == 'NULL')
229 continue;
230
231 $base .= sprintf('%s%s=%s', $i==0 ? '?' : '&amp;', $key, $value);
232 $i++;
233 }
234 if (!isset($items['s']))
235 $base .= '&amp;s='.$s;
236
237 return $base;
238}
239
240function socket_cmd($socket, $cmd) { 171function socket_cmd($socket, $cmd) {
241 $r = fwrite($socket, $cmd, strlen($cmd)); 172 $r = fwrite($socket, $cmd, strlen($cmd));
242 if ($r === false || $r != strlen($cmd)) { 173 if ($r === false || $r != strlen($cmd)) {