Skip to content

Commit 5a7fdaa

Browse files
committed
Fix dynamicdashboard with multidatadir
1 parent a94e605 commit 5a7fdaa

1 file changed

Lines changed: 35 additions & 35 deletions

File tree

html/dashboard/dynamic/r_dynamic.php

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
if ($_GET['f_id_config_dynamic_dashboard']) {
1212

13-
14-
$lib='SELECT
15-
cddg.*
16-
FROM
13+
14+
$lib='SELECT
15+
cddg.*
16+
FROM
1717
config_dynamic_dashboard cdd
1818
LEFT JOIN config_dynamic_dashboard_group cddg
1919
ON cdd.id_config_dynamic_dashboard=cddg.id_config_dynamic_dashboard
@@ -26,12 +26,12 @@
2626
WHERE aug.id_auth_user=:s_id_user
2727
AND cdd.id_config_dynamic_dashboard=:f_id_config_dynamic_dashboard
2828
ORDER BY dash_ordering';
29-
29+
3030
$connSQL=new DB();
3131
$connSQL->bind('s_id_user',$s_id_user);
3232
$connSQL->bind('f_id_config_dynamic_dashboard',$f_id_config_dynamic_dashboard);
3333
$cur_dashboard=$connSQL->row($lib);
34-
34+
3535
if ($cur_dashboard->id_auth_group) {
3636
$lib='SELECT
3737
cddc.*
@@ -40,29 +40,29 @@
4040
WHERE
4141
cddc.id_config_dynamic_dashboard=:f_id_config_dynamic_dashboard
4242
ORDER BY dash_ordering';
43-
43+
4444
$connSQL=new DB();
4545
$connSQL->bind('f_id_config_dynamic_dashboard',$f_id_config_dynamic_dashboard);
4646
$all_content=$connSQL->query($lib);
4747
$cpt_content=count($all_content);
48-
49-
48+
49+
5050
for ($i=0; $i<$cpt_content; $i++) {
5151
$cpt_p=0;
52-
52+
5353
$lib='
54-
SELECT
55-
cs.id_config_server,
54+
SELECT
55+
cs.id_config_server,
5656
cs.server_name,
5757
COALESCE(cs.collectd_version,"'.COLLECTD_DEFAULT_VERSION.'") as collectd_version
5858
FROM config_server cs
59-
LEFT JOIN config_server_project csp
59+
LEFT JOIN config_server_project csp
6060
ON cs.id_config_server=csp.id_config_server
61-
LEFT JOIN perm_project_group ppg
61+
LEFT JOIN perm_project_group ppg
6262
ON ppg.id_config_project=csp.id_config_project
63-
LEFT JOIN auth_group ag
63+
LEFT JOIN auth_group ag
6464
ON ag.id_auth_group=ppg.id_auth_group
65-
LEFT JOIN auth_user_group aug
65+
LEFT JOIN auth_user_group aug
6666
ON aug.id_auth_group=ag.id_auth_group
6767
WHERE aug.id_auth_user=:s_id_user
6868
AND cs.server_name REGEXP :regex_srv
@@ -73,8 +73,8 @@
7373
$connSQL->bind('s_id_user',$s_id_user);
7474
$connSQL->bind('regex_srv',$all_content[$i]->regex_srv);
7575
$all_server=$connSQL->query($lib);
76-
$cpt_server=count($all_server);
77-
76+
$cpt_server=count($all_server);
77+
7878
if (isset($time_start) && isset($time_end)) {
7979
$zoom='onclick="Show_Popup($(this).attr(\'src\').split(\'?\')[1],\'\',\''.$time_start.'\',\''.$time_end.'\')"';
8080
} else {
@@ -84,7 +84,7 @@
8484
for ($j=0; $j<$cpt_server; $j++) {
8585
$allDatadir=getAllDatadir();
8686
foreach($allDatadir as $key => $datadir){
87-
if(!is_dir($datadir.'/'.$all_server[$j]->server_name.'/')) unset($allDatadir[$key]);
87+
if(!is_dir($datadir.'/'.$all_server[$j]->server_name.'/')) unset($allDatadir[$key]);
8888
}
8989
if (!empty($allDatadir)) {
9090
$myregex='#^(('.implode('|',$allDatadir).')/'.$all_server[$j]->server_name.'/)('.$all_content[$i]->regex_p_filter.')(?:\-('.$all_content[$i]->regex_pi_filter.'))?/('.$all_content[$i]->regex_t_filter.')(?:\-('.$all_content[$i]->regex_ti_filter.'))?\.rrd#';
@@ -94,14 +94,14 @@
9494
$tplugins = preg_find($myregex, $datadir.'/'.$all_server[$j]->server_name, PREG_FIND_RECURSIVE|PREG_FIND_FULLPATH|PREG_FIND_SORTBASENAME);
9595
$plugins=array_merge($plugins, $tplugins);
9696
}
97-
97+
9898
foreach ($plugins as $plugin) {
9999
$plugin_array[$cpt_p]['servername']=$all_server[$j]->server_name;
100100
$plugin_array[$cpt_p]['collectd_version']=$all_server[$j]->collectd_version;
101101

102102
preg_match($myregex, $plugin, $matches);
103-
$plugin_datadir = getDatadirEntry($matches[1]);
104-
103+
$plugin_array[$cpt_p]['datadir'] = getDatadirEntry($matches[1]);
104+
105105
if (isset($matches[3])) {
106106
$plugin_array[$cpt_p]['p']=$matches[3];
107107
} else {
@@ -121,7 +121,7 @@
121121
} else {
122122
$plugin_array[$cpt_p]['pc']=null;
123123
$plugin_array[$cpt_p]['pi']=null;
124-
}
124+
}
125125
if (isset($matches[5])) {
126126
$plugin_array[$cpt_p]['t']=$matches[5];
127127
} else {
@@ -134,12 +134,12 @@
134134
$tmp=explode('-',$plugin_array[$cpt_p]['ti']);
135135
$plugin_array[$cpt_p]['tc']=$tmp[0];
136136
$ti=null;
137-
}
137+
}
138138
} else {
139139
$plugin_array[$cpt_p]['tc']=null;
140140
$plugin_array[$cpt_p]['ti']=null;
141141
}
142-
142+
143143
$cpt_p++;
144144
}
145145
}
@@ -170,12 +170,12 @@
170170
$old_pi=null;
171171
$old_p=null;
172172
$old_servername=null;
173-
173+
174174
//$final_array=array_merge_recursive($plugin_array, $final_array);
175175
foreach ($plugin_array as $plugin) {
176176
if (! isset(${$plugin['servername'].$plugin['p'].$plugin['pc'].$plugin['pi'].$plugin['t'].$plugin['tc'].$plugin['ti']}) ) {
177177
${$plugin['servername'].$plugin['p'].$plugin['pc'].$plugin['pi'].$plugin['t'].$plugin['tc'].$plugin['ti']}=true;
178-
178+
179179
if ($all_content[$i]->rrd_ordering=='S') {
180180
if ($old_servername!=$plugin['servername']) {
181181
echo '<h1>'.$plugin['servername'].'</h1>';
@@ -234,7 +234,7 @@
234234
}
235235

236236
if ($CONFIG['no_break'] == true) { echo '<span style="white-space:nowrap">'; }
237-
if (!preg_match('/^(df|interface|oracle|snmp)$/', $plugin['p']) ||
237+
if (!preg_match('/^(df|interface|oracle|snmp)$/', $plugin['p']) ||
238238
(((preg_replace('/[^0-9\.]/','',$plugin['collectd_version']) >= 5)
239239
&& !preg_match('/^(oracle|snmp)$/', $plugin['p']) && $plugin['t']!='df'))
240240
|| ($plugin['p'] == 'snmp' && $plugin['t'] == 'memory')
@@ -250,16 +250,16 @@
250250
$_GET['t'] = $plugin['t'];
251251
$_GET['tc'] = $plugin['tc'];
252252
$_GET['ti'] = $plugin['ti'];
253-
253+
254254
chdir(DIR_FSROOT);
255255
include DIR_FSROOT.'/plugin/'.$plugin['p'].'.php';
256256
} else {
257257
$graph_title=gen_title($plugin['servername'],$plugin['p'],$plugin['pc'],$plugin['pi'],$plugin['t'],$plugin['tc'],$plugin['ti']);
258258
if (GRAPH_TITLE=='text') { echo '<figure><figcaption style="max-width:'.($CONFIG['width']+100).'px" title="'.$graph_title.'">'.$graph_title.'</figcaption>'; }
259259
if ($time_range!=null) {
260-
echo '<img class="imggraph" '.$zoom.' title="'.CLICK_ZOOM.' : &#13;'.$graph_title.'" src="'.DIR_WEBROOT.'/graph.php?datadir='.$plugin_datadir.'&amp;h='.urlencode($plugin['servername']).'&amp;p='.urlencode($plugin['p']).'&amp;pc='.urlencode($plugin['pc']).'&amp;pi='.urlencode($plugin['pi']).'&amp;t='.urlencode($plugin['t']).'&amp;tc='.urlencode($plugin['tc']).'&amp;ti='.urlencode($plugin['ti']).'&amp;s='.$time_range.'" />'."\n";
260+
echo '<img class="imggraph" '.$zoom.' title="'.CLICK_ZOOM.' : &#13;'.$graph_title.'" src="'.DIR_WEBROOT.'/graph.php?datadir='.$plugin['datadir'].'&amp;h='.urlencode($plugin['servername']).'&amp;p='.urlencode($plugin['p']).'&amp;pc='.urlencode($plugin['pc']).'&amp;pi='.urlencode($plugin['pi']).'&amp;t='.urlencode($plugin['t']).'&amp;tc='.urlencode($plugin['tc']).'&amp;ti='.urlencode($plugin['ti']).'&amp;s='.$time_range.'" />'."\n";
261261
} else {
262-
echo '<img class="imggraph" '.$zoom.' title="'.CLICK_ZOOM.' : &#13;'.$graph_title.'" src="'.DIR_WEBROOT.'/graph.php?datadir='.$plugin_datadir.'&amp;h='.urlencode($plugin['servername']).'&amp;p='.urlencode($plugin['p']).'&amp;pc='.urlencode($plugin['pc']).'&amp;pi='.urlencode($plugin['pi']).'&amp;t='.urlencode($plugin['t']).'&amp;tc='.urlencode($plugin['tc']).'&amp;ti='.urlencode($plugin['ti']).'&amp;s='.$time_start.'&amp;e='.$time_end.'" />'."\n";
262+
echo '<img class="imggraph" '.$zoom.' title="'.CLICK_ZOOM.' : &#13;'.$graph_title.'" src="'.DIR_WEBROOT.'/graph.php?datadir='.$plugin['datadir'].'&amp;h='.urlencode($plugin['servername']).'&amp;p='.urlencode($plugin['p']).'&amp;pc='.urlencode($plugin['pc']).'&amp;pi='.urlencode($plugin['pi']).'&amp;t='.urlencode($plugin['t']).'&amp;tc='.urlencode($plugin['tc']).'&amp;ti='.urlencode($plugin['ti']).'&amp;s='.$time_start.'&amp;e='.$time_end.'" />'."\n";
263263
}
264264
if(GRAPH_TITLE=='text') { echo '</figure>'; }
265265
}
@@ -273,22 +273,22 @@
273273
$_GET['t'] = $plugin['t'];
274274
$_GET['tc'] = $plugin['tc'];
275275
$_GET['ti'] = $plugin['ti'];
276-
276+
277277
chdir(DIR_FSROOT);
278278
include DIR_FSROOT.'/plugin/'.$plugin['p'].'.php';
279279
} else {
280280
$graph_title=gen_title($plugin['servername'],$plugin['p'],$plugin['pc'],$plugin['pi'],$plugin['t'],$plugin['tc'],$plugin['ti']);
281281
if (GRAPH_TITLE=='text') { echo '<figure><figcaption style="max-width:'.($CONFIG['width']+100).'px" title="'.$graph_title.'">'.$graph_title.'</figcaption>'; }
282282
if ($time_range!=null) {
283-
echo '<img class="imggraph" '.$zoom.' title="'.CLICK_ZOOM.' : &#13;'.$graph_title.'" src="'.DIR_WEBROOT.'/graph.php?datadir='.$plugin_datadir.'&amp;h='.urlencode($plugin['servername']).'&amp;p='.urlencode($plugin['p']).'&amp;pc='.urlencode($plugin['pc']).'&amp;pi='.urlencode($plugin['pi']).'&amp;t='.urlencode($plugin['t']).'&amp;tc='.urlencode($plugin['tc']).'&amp;ti='.urlencode($plugin['ti']).'&amp;s='.$time_range.'" />'."\n";
283+
echo '<img class="imggraph" '.$zoom.' title="'.CLICK_ZOOM.' : &#13;'.$graph_title.'" src="'.DIR_WEBROOT.'/graph.php?datadir='.$plugin['datadir'].'&amp;h='.urlencode($plugin['servername']).'&amp;p='.urlencode($plugin['p']).'&amp;pc='.urlencode($plugin['pc']).'&amp;pi='.urlencode($plugin['pi']).'&amp;t='.urlencode($plugin['t']).'&amp;tc='.urlencode($plugin['tc']).'&amp;ti='.urlencode($plugin['ti']).'&amp;s='.$time_range.'" />'."\n";
284284
} else {
285-
echo '<img class="imggraph" '.$zoom.' title="'.CLICK_ZOOM.' : &#13;'.$graph_title.'" src="'.DIR_WEBROOT.'/graph.php?datadir='.$plugin_datadir.'&amp;h='.urlencode($plugin['servername']).'&amp;p='.urlencode($plugin['p']).'&amp;pc='.urlencode($plugin['pc']).'&amp;pi='.urlencode($plugin['pi']).'&amp;t='.urlencode($plugin['t']).'&amp;tc='.urlencode($plugin['tc']).'&amp;ti='.urlencode($plugin['ti']).'&amp;s='.$time_start.'&amp;e='.$time_end.'" />'."\n";
285+
echo '<img class="imggraph" '.$zoom.' title="'.CLICK_ZOOM.' : &#13;'.$graph_title.'" src="'.DIR_WEBROOT.'/graph.php?datadir='.$plugin['datadir'].'&amp;h='.urlencode($plugin['servername']).'&amp;p='.urlencode($plugin['p']).'&amp;pc='.urlencode($plugin['pc']).'&amp;pi='.urlencode($plugin['pi']).'&amp;t='.urlencode($plugin['t']).'&amp;tc='.urlencode($plugin['tc']).'&amp;ti='.urlencode($plugin['ti']).'&amp;s='.$time_start.'&amp;e='.$time_end.'" />'."\n";
286286
}
287287
if(GRAPH_TITLE=='text') { echo '</figure>'; }
288288
}
289289
}
290290
if ($CONFIG['no_break'] == true) { echo '</span>'; }
291-
291+
292292
$old_t=$plugin['t'];
293293
$old_tc=$plugin['tc'];
294294
$old_ti=$plugin['ti'];

0 commit comments

Comments
 (0)