forked from ganglia/ganglia-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
71 lines (58 loc) · 2.33 KB
/
search.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<script>
$( "#tabs" ).bind( "tabsshow", function(event, ui) {
jQuery('#jquery-live-search').slideUp(0);
});
</script>
<?php
require_once('./eval_conf.php');
require_once('./functions.php');
// Load the metric caching code
//$debug = 1;
retrieve_metrics_cache();
if ( isset($_GET['mobile']))
$mobile = 1;
else
$mobile = 0;
$results = "";
if ( isset($_GET['q']) && $_GET['q'] != "" ) {
$query = $_GET['q'];
// First we look for the hosts
foreach ( $index_array['hosts'] as $key => $host_name ) {
if ( preg_match("/$query/i", $host_name ) ) {
$clusters = $index_array['cluster'][$host_name];
foreach ($clusters AS $cluster_name) {
if ( $mobile )
$results .= '<a onclick="jQuery(\'#jquery-live-search\').slideUp(0)" href="mobile_helper.php?show_host_metrics=1&h=' . $host_name . '&c=' . $cluster_name . '&r=' . $conf['default_time_range'] . '&cs=&ce=">Host: ' . $host_name ." (" . $cluster_name . ')</a>';
else
$results .= "Host: <a target=\"_blank\" href=\"?c=" . $cluster_name . "&h=" . $host_name . "&m=cpu_report&r=" . $conf['default_time_range'] ."&s=descending&hc=4&mc=2\">" . $host_name . " ( " . $cluster_name . " )</a><br>";
}
}
}
// Now let's look through metrics.
foreach ( $index_array['metrics'] as $metric_name => $hosts ) {
if ( preg_match("/$query/i", $metric_name ) ) {
foreach ( $hosts as $key => $host_name ) {
$clusters = $index_array['cluster'][$host_name];
foreach ($clusters AS $cluster_name) {
if ( $mobile ) {
$results .= 'Metric: <a onclick="jQuery(\'#jquery-live-search\').slideUp(0)" href="mobile_helper.php?show_host_metrics=1&h=' . $host_name . '&c=' . $cluster_name . '&r=' . $conf['default_time_range'] . '&cs=&ce=">' . $host_name . " (" . $metric_name . ")</a><br>";
} else {
$results .= "Metric: <a target=\"_blank\" href=\"?c=" . $cluster_name . "&h=" . $host_name . "&m=cpu_report&r=hour&s=descending&hc=4&mc=2#metric_" . $metric_name . "\">" . $host_name . " @ " . $cluster_name . " (" . $metric_name . ")</a><br>";
}
}
}
}
}
} else {
$results .= "Empty query string";
}
if ( $results == "" ) {
print "No results. Try a different search term. One term only.";
} else {
if ( $mobile ) {
print $results;
} else {
print $results;
}
}
?>