forked from ganglia/ganglia-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasseo.php
137 lines (122 loc) · 4.28 KB
/
tasseo.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
include_once("./eval_conf.php");
include_once("./functions.php");
//////////////////////////////////////////////////////////////////////////////////////////
// Print out
//////////////////////////////////////////////////////////////////////////////////////////
if ( ! isset($_REQUEST['view_name']) ) {
$available_views = get_available_views();
print "<form action='tasseo.php'><select onchange='this.form.submit();' name=view_name><option value=none>Please choose...</option>";
foreach ( $available_views as $id => $view ) {
print "<option value='" . $view['view_name'] . "'>" . $view['view_name'] . "</option>";
}
print "</form>";
} else {
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// We need metrics cache in order to derive cluster name particular host
// belongs to
retrieve_metrics_cache();
$available_views = get_available_views();
$view_found = 0;
$user['view_name'] = $_REQUEST['view_name'];
// I am not quite sure at this point whether I should cache view info so
// for now I will have to do this
foreach ( $available_views as $id => $view ) {
# Find view settings
if ( $user['view_name'] == $view['view_name'] ) {
$view_found = 1;
break;
}
}
unset($available_views);
if ( $view_found == 0 || sizeof($view['items']) == 0 ) {
die ("<font color=red size=4>There are no graphs in view you supplied or view does not exist.</font>");
}
// Let's get all View graph elements
$view_elements = get_view_graph_elements($view);
?>
<html>
<head>
<title>Live Dashboard for <?php print $user['view_name']; ?></title>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/tasseo.css" />
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/d3.v2.min.js"></script>
<script type="text/javascript" src="js/rickshaw.min.js"></script>
</head>
<body>
<div id='title'>
<span><?php print $user['view_name']; ?></span>
<div id='toolbar'>
<ul class='timepanel'>
<li class='timepanel live selected'>
<a class='play' href='#'>live</a>
</li>
<li class='timepanel'>
<a class='range' href='#' title='60'>1h</a>
</li>
<li class='timepanel'>
<a class='range' href='#' title='180'>3h</a>
</li>
<li class='timepanel'>
<a class='range' href='#' title='1440'>1d</a>
</li>
<li class='timepanel'>
<a class='range' href='#' title='10080'>1w</a>
</li>
</ul>
<ul class='toggle'>
<li class='toggle-nonum'>
<a href='#'>
<img src='img/toggle-number.png' />
</a>
</li>
<li class='toggle-night'>
<a href='#'>
<img src='img/toggle-night.png' />
</a>
</li>
</ul>
</div>
</div>
<div id="main">
</div>
<script>
var ganglia_url = "<?php
$proto = "//";
$path_parts = pathinfo($_SERVER['SCRIPT_NAME']);
print $proto . $_SERVER['HTTP_HOST'] . $path_parts['dirname']; ?>";
</script>
<script>
var metrics =
<?php
foreach ( $view_elements as $index => $element ) {
# Avoid optional reports and Aggregate graphs until we implement them
if ( ! preg_match("/_report&/", $element['graph_args']) and ! isset($element['aggregate_graph']) ) {
$tasseo_e['graph_args'] = $element['graph_args'];
# $tasseo_e['hostname'] = $element['hostname'];
# $tasseo_e['clustername'] = $element['cluster'];
# $tasseo_e['metricname'] = $element['name'];
if ( isset($element['aggregate_graph'])) {
$tasseo_e['name'] = "Aggr " . $element['name'];
} else {
$tasseo_e['name'] = $element['hostname'] . " " . $element['name'];
}
if ( isset($element['warning']))
$tasseo_e['warning'] = $element['warning'];
if ( isset($element['critical']))
$tasseo_e['critical'] = $element['critical'];
$tasseo_element[] = $tasseo_e;
unset($tasseo_e);
}
}
print json_encode($tasseo_element)
?>;
</script>
<script type="text/javascript" src="js/tasseo.js"></script>
<?php
} // end of if (!isset($_GET['view_name']
?>
</body>
</html>