-
Notifications
You must be signed in to change notification settings - Fork 66
/
jmx.php
173 lines (128 loc) · 6.36 KB
/
jmx.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
/*
Cassandra Cluster Admin
@author Sébastien Giroux
@copyright All rights reserved - 2011
*/
require('include/kernel.inc.php');
require('include/verify_login.inc.php');
$all_nodes = $cluster_helper->getArrayOfNodesForCurrentCluster();
$first_host = explode(':',$all_nodes[0]);
$first_host = $first_host[0];
if (isset($_GET['change_mx4j_node'])) $_SESSION['mx4j_node'] = $_GET['change_mx4j_node'];
elseif (!isset($_SESSION['mx4j_node'])) $_SESSION['mx4j_node'] = $first_host;
// If user come from another cluster, we need to refresh the node in the session
$found = false;
foreach ($all_nodes as $one_node) {
list($host,$port) = explode(':',$one_node);
if ($host == $_SESSION['mx4j_node']) {
$found = true;
break;
}
}
if (!$found) $_SESSION['mx4j_node'] = $first_host;
if (function_exists('curl_init')) {
$mx4j = new MX4J($_SESSION['mx4j_node']);
// Make sure MX4J is active
if ($mx4j->isActive()) {
if (isset($_GET['get_json_heap_memory_usage']) && $_GET['get_json_heap_memory_usage'] == 1) {
die(json_encode($mx4j->getHeapMemoryUsage()));
}
if (isset($_GET['get_json_non_heap_memory_usage']) && $_GET['get_json_non_heap_memory_usage'] == 1) {
die(json_encode($mx4j->getNonHeapMemoryUsage()));
}
if (isset($_GET['get_tp_stats']) && $_GET['get_tp_stats'] == 1) {
die(json_encode($mx4j->getTpStats()));
}
if (isset($_GET['columnfamily_details']) && isset($_GET['keyspace_name']) && isset($_GET['columnfamily_name'])) {
$keyspace_name = $_GET['keyspace_name'];
$columnfamily_name = $_GET['columnfamily_name'];
$details = array('details' => $mx4j->getColumnFamilyDetails($keyspace_name,$columnfamily_name),
'key_cache' => $mx4j->getColumnFamilyKeyCacheDetails($keyspace_name,$columnfamily_name),
'row_cache' => $mx4j->getColumnFamilyRowCacheDetails($keyspace_name,$columnfamily_name));
die(json_encode($details));
}
$vw_vars['heap_memory_usage'] = $mx4j->getHeapMemoryUsage();
$vw_vars['non_heap_memory_usage'] = $mx4j->getNonHeapMemoryUsage();
$vw_vars['nb_loaded_class'] = $mx4j->getLoadedClassCount();
$vw_vars['tp_stats'] = $mx4j->getTpStats();
$vw_vars['trigger_gc'] = null;
$vw_vars['trigger_force_major_compaction'] = null;
$vw_vars['trigger_invalidate_key_cache'] = null;
$vw_vars['trigger_invalidate_row_cache'] = null;
$vw_vars['trigger_force_flush'] = null;
$vw_vars['trigger_disable_auto_compaction'] = null;
$vw_vars['trigger_estimate_keys'] = null;
// Trigger the garbage collector
if (isset($_GET['trigger_gc']) && $_GET['trigger_gc'] == 1) {
$trigger_gc = $mx4j->triggerGarbageCollection();
$vw_vars['trigger_gc'] = $trigger_gc;
}
// Trigger a major compaction
if (isset($_GET['trigger_force_major_compaction']) && $_GET['trigger_force_major_compaction'] == 1 && isset($_GET['keyspace_name']) && isset($_GET['columnfamily_name'])) {
$keyspace_name = $_GET['keyspace_name'];
$columnfamily_name = $_GET['columnfamily_name'];
$trigger_force_major_compaction = $mx4j->forceMajorCompaction($keyspace_name,$columnfamily_name);
$vw_vars['trigger_force_major_compaction'] = $trigger_force_major_compaction;
}
// Trigger invalidate key cache
if (isset($_GET['trigger_invalidate_key_cache']) && $_GET['trigger_invalidate_key_cache'] == 1 && isset($_GET['keyspace_name']) && isset($_GET['columnfamily_name'])) {
$keyspace_name = $_GET['keyspace_name'];
$columnfamily_name = $_GET['columnfamily_name'];
$trigger_invalidate_key_cache = $mx4j->invalidateKeyCache($keyspace_name,$columnfamily_name);
$vw_vars['trigger_invalidate_key_cache'] = $trigger_invalidate_key_cache;
}
// Trigger invalidate row cache
if (isset($_GET['trigger_invalidate_row_cache']) && $_GET['trigger_invalidate_row_cache'] == 1 && isset($_GET['keyspace_name']) && isset($_GET['columnfamily_name'])) {
$keyspace_name = $_GET['keyspace_name'];
$columnfamily_name = $_GET['columnfamily_name'];
$trigger_invalidate_row_cache = $mx4j->invalidateRowCache($keyspace_name,$columnfamily_name);
$vw_vars['trigger_invalidate_row_cache'] = $trigger_invalidate_row_cache;
}
// Trigger force flush
if (isset($_GET['trigger_force_flush']) && $_GET['trigger_force_flush'] == 1 && isset($_GET['keyspace_name']) && isset($_GET['columnfamily_name'])) {
$keyspace_name = $_GET['keyspace_name'];
$columnfamily_name = $_GET['columnfamily_name'];
$trigger_force_flush = $mx4j->forceFlush($keyspace_name,$columnfamily_name);
$vw_vars['trigger_force_flush'] = $trigger_force_flush;
}
// Trigger disable auto compaction
if (isset($_GET['trigger_disable_auto_compaction']) && $_GET['trigger_disable_auto_compaction'] == 1 && isset($_GET['keyspace_name']) && isset($_GET['columnfamily_name'])) {
$keyspace_name = $_GET['keyspace_name'];
$columnfamily_name = $_GET['columnfamily_name'];
$trigger_disable_auto_compaction = $mx4j->disableAutoCompaction($keyspace_name,$columnfamily_name);
$vw_vars['trigger_disable_auto_compaction'] = $trigger_disable_auto_compaction;
}
// Trigger estimate keys
if (isset($_GET['trigger_estimate_keys']) && $_GET['trigger_estimate_keys'] == 1 && isset($_GET['keyspace_name']) && isset($_GET['columnfamily_name'])) {
$keyspace_name = $_GET['keyspace_name'];
$columnfamily_name = $_GET['columnfamily_name'];
$trigger_estimate_keys = $mx4j->estimateKeys($keyspace_name,$columnfamily_name);
$vw_vars['trigger_estimate_keys'] = $trigger_estimate_keys;
}
$vw_vars['cluster_name'] = $sys_manager->describe_cluster_name();
$vw_vars['all_nodes'] = $all_nodes;
/*
List of keyspaces and column families
*/
$ks_and_cf_details = ColumnFamilyHelper::getKeyspacesAndColumnFamiliesDetails();
$vw_vars['ks_and_cf_details'] = $ks_and_cf_details;
$vw_vars['jmx_host'] = $host;
echo getHTML('header.php');
echo getHTML('jmx.php',$vw_vars);
}
else {
$vw_vars['cluster_name'] = $sys_manager->describe_cluster_name();
$vw_vars['all_nodes'] = $all_nodes;
$vw_vars['jmx_host'] = $host;
echo getHTML('header.php');
echo getHTML('mx4j_not_active.php',$vw_vars);
}
}
// CURL is not installed
else {
echo getHTML('header.php');
echo getHTML('jmx_missing_dependencies.php');
}
echo getHTML('footer.php');
?>