Permalink
Browse files

Added some more stats in JMX page, will organize it better later

  • Loading branch information...
1 parent a94a8f7 commit 112fb5de296dceb3a59add79b71c734108a9aa92 @sebgiroux committed Jul 23, 2011
Showing with 209 additions and 22 deletions.
  1. +3 −14 cluster_info.php
  2. +25 −0 helper/ColumnFamilyHelper.php
  3. +45 −0 helper/MX4J.php
  4. +18 −0 jmx.php
  5. +64 −0 js/cassandra_cluster_admin.js
  6. +2 −2 views/cluster_info.php
  7. +52 −6 views/jmx.php
View
@@ -17,21 +17,10 @@
$vw_vars['cluster_helper'] = $cluster_helper;
- $keyspaces = $sys_manager->describe_keyspaces();
- $keyspaces_name = array();
- $keyspaces_details = array();
+ $ks_and_cf_details = ColumnFamilyHelper::getKeyspacesAndColumnFamiliesDetails();
- foreach ($keyspaces as $keyspace) {
- $keyspaces_name[] = $keyspace->name;
-
- $columnfamilys_name = array();
-
- foreach ($keyspace->cf_defs as $columnfamily) {
- $columnfamilys_name[] = $columnfamily->name;
- }
-
- $keyspaces_details[] = array('columnfamilys_name' => $columnfamilys_name);
- }
+ $keyspaces_name = $ks_and_cf_details['keyspaces_name'];
+ $keyspaces_details = $ks_and_cf_details['keyspaces_details'];
$vw_vars['keyspaces_name'] = $keyspaces_name;
$vw_vars['keyspaces_details'] = $keyspaces_details;
@@ -33,6 +33,31 @@ public static function getCFInKeyspace($keyspace_name,$columnfamily_name) {
if ($found) return $one_cf;
}
+
+ /*
+ Return an array with the name of all keyspaces and column family in current cluster.
+ */
+ public static function getKeyspacesAndColumnFamiliesDetails() {
+ global $sys_manager;
+
+ $keyspaces = $sys_manager->describe_keyspaces();
+ $keyspaces_name = array();
+ $keyspaces_details = array();
+
+ foreach ($keyspaces as $keyspace) {
+ $keyspaces_name[] = $keyspace->name;
+
+ $columnfamilies_name = array();
+
+ foreach ($keyspace->cf_defs as $columnfamily) {
+ $columnfamilies_name[] = $columnfamily->name;
+ }
+
+ $keyspaces_details[] = array('columnfamilies_name' => $columnfamilies_name);
+ }
+
+ return array('keyspaces_name' => $keyspaces_name, 'keyspaces_details' => $keyspaces_details);
+ }
/*
Display a row out of a column family
View
@@ -222,5 +222,50 @@ public function triggerGarbageCollection() {
return $result == 'success';
}
}
+
+ public function getColumnFamilyDetails($keyspace_name,$columnfamily_name) {
+ $data = $this->doCall($this->getUrl().'/mbean?objectname=org.apache.cassandra.db:type=ColumnFamilies,keyspace='.$keyspace_name.',columnfamily='.$columnfamily_name.'&template=identity');
+
+ $return = array();
+
+ foreach ($data['Attribute'] as $one_attribute) {
+ $name = $one_attribute['@attributes']['name'];
+ $value = $one_attribute['@attributes']['value'];
+
+ $return[] = array('name' => $name,'value' => $value);
+ }
+
+ return $return;
+ }
+
+ public function getColumnFamilyKeyCacheDetails($keyspace_name,$columnfamily_name) {
+ $data = $this->doCall($this->getUrl().'/mbean?objectname=org.apache.cassandra.db:type=Caches,keyspace='.$keyspace_name.',cache='.$columnfamily_name.'KeyCache&template=identity');
+
+ $return = array();
+
+ foreach ($data['Attribute'] as $one_attribute) {
+ $name = $one_attribute['@attributes']['name'];
+ $value = $one_attribute['@attributes']['value'];
+
+ $return[] = array('name' => $name,'value' => $value);
+ }
+
+ return $return;
+ }
+
+ public function getColumnFamilyRowCacheDetails($keyspace_name,$columnfamily_name) {
+ $data = $this->doCall($this->getUrl().'/mbean?objectname=org.apache.cassandra.db:type=Caches,keyspace='.$keyspace_name.',cache='.$columnfamily_name.'RowCache&template=identity');
+
+ $return = array();
+
+ foreach ($data['Attribute'] as $one_attribute) {
+ $name = $one_attribute['@attributes']['name'];
+ $value = $one_attribute['@attributes']['value'];
+
+ $return[] = array('name' => $name,'value' => $value);
+ }
+
+ return $return;
+ }
}
?>
View
18 jmx.php
@@ -40,6 +40,17 @@
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['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();
@@ -61,6 +72,13 @@
$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;
+
echo getHTML('header.php');
echo getHTML('jmx.php',$vw_vars);
}
@@ -139,6 +139,70 @@ function getNonHeapMemoryUsage() {
}, $('#data_refresh_interval').val());
}
+function buildDropDownOfKeyspaces() {
+ var dropdown = $('#keyspace_list');
+
+ $('#keyspace_list > option').remove();
+
+ $.each(keyspaces_name,function(index_keyspace) {
+ dropdown.append($('<option />').val(index_keyspace).text(keyspaces_name[index_keyspace]));
+ });
+
+ buildDropDownOfColumnFamilies();
+}
+
+function buildDropDownOfColumnFamilies() {
+ var index_keyspace = $('#keyspace_list').val();
+ var dropdown = $('#columnfamily_list');
+
+ $('#columnfamily_list > option').remove();
+
+ $.each(keyspaces_details[index_keyspace],function(index_columnfamily) {
+ dropdown.append($("<option />").val(index_columnfamily).text(keyspaces_details[index_keyspace][index_columnfamily]));
+ });
+
+ changeColumnFamily();
+}
+
+function changeColumnFamily() {
+ var index_keyspace = $('#keyspace_list').val();
+ var index_columnfamily = $('#columnfamily_list').val();
+
+ var keyspace_name = keyspaces_name[index_keyspace];
+ var columnfamily_name = keyspaces_details[index_keyspace][index_columnfamily];
+
+ $.getJSON('jmx.php?columnfamily_details=1&keyspace_name=' + keyspace_name + '&columnfamily_name=' + columnfamily_name, function(data) {
+ $('#columnfamily_details').find('tr').remove();
+ $('#column_family_key_cache_details').find('tr').remove();
+ $('#column_family_row_cache_details').find('tr').remove();
+
+ $('#columnfamily_details').append('<tr><td>Name</td><td>Value</td></tr>');
+ $('#column_family_key_cache_details').append('<tr><td>Name</td><td>Value</td></tr>');
+ $('#column_family_row_cache_details').append('<tr><td>Name</td><td>Value</td></tr>');
+
+ $.each(data.details,function(item) {
+ var name = data.details[item].name;
+ var value = data.details[item].value;
+
+ $('#columnfamily_details').append('<tr><td>' + name + '</td><td>' + value + '</td></tr>');
+ });
+
+ $.each(data.key_cache,function(item) {
+ var name = data.key_cache[item].name;
+ var value = data.key_cache[item].value;
+
+ $('#column_family_key_cache_details').append('<tr><td>' + name + '</td><td>' + value + '</td></tr>');
+ });
+
+ $.each(data.row_cache,function(item) {
+ var name = data.row_cache[item].name;
+ var value = data.row_cache[item].value;
+
+ $('#column_family_row_cache_details').append('<tr><td>' + name + '</td><td>' + value + '</td></tr>');
+ });
+ });
+}
+
function registerCFFormTooltips() {
$('#read_repair_chance_tooltip').simpletip({
content: '<p>Before 0.7, read_repair was either invoked on every read request or on none of them. This is now tunable as a double between 0 and 1 (inclusive on both ends) for the chance of invoking the repair.</p><p>Default is: "1.0", read repair on every read request.</p>',
View
@@ -45,9 +45,9 @@
echo '<li><a href="describe_keyspace.php?keyspace_name='.$keyspace_name.'">'.$keyspace_name.'</a>';
echo '<ul>';
- $nb_cf = count($keyspaces_details[$i]['columnfamilys_name']);
+ $nb_cf = count($keyspaces_details[$i]['columnfamilies_name']);
for ($j = 0; $j < $nb_cf; $j++):
- $columnfamily_name = $keyspaces_details[$i]['columnfamilys_name'][$j];
+ $columnfamily_name = $keyspaces_details[$i]['columnfamilies_name'][$j];
echo '<li><a href="describe_columnfamily.php?keyspace_name='.$keyspace_name.'&amp;columnfamily_name='.$columnfamily_name.'">'.$columnfamily_name.'</a></li>';
endfor;
echo '</ul>';
View
@@ -15,6 +15,22 @@
non_heap_memory_states.push([d.getTime() - $('#data_refresh_interval').val(),"<?=$non_heap_memory_usage['used']?>"]);
non_heap_memory_states.push([d.getTime(),"<?=$non_heap_memory_usage['used']?>"]);
+ // Build array of keyspaces and column families
+ var keyspaces_name = ['<?php echo implode('\',\'',$ks_and_cf_details['keyspaces_name']); ?>'];
+
+ var keyspaces_details = [];
+
+ <?php
+ foreach ($ks_and_cf_details['keyspaces_details'] as $key => $one_keyspace):
+ echo 'keyspaces_details['.$key.'] = [];';
+ foreach ($one_keyspace['columnfamilies_name'] as $cf_key => $cf_name):
+ ?>
+ keyspaces_details[<?=$key?>][<?=$cf_key?>] = '<?=$cf_name?>';
+ <?php
+ endforeach;
+ endforeach;
+ ?>
+
$(document).ready(function() {
// Heap Memory Usage Graph
doPlotHeapMemory('right');
@@ -23,6 +39,10 @@
// Non Heap Memory Usage Graph
doPlotNonHeapMemory('right');
getNonHeapMemoryUsage();
+
+ buildDropDownOfKeyspaces();
+
+ changeColumnFamily();
});
</script>
@@ -113,11 +133,14 @@
<td>Completed Tasks</td>
<td>Pending Tasks</td>
</tr>
- <?php
- foreach ($tp_stats as $one_tp_stat):
- echo '<tr><td>'.$one_tp_stat['name'].'</td><td>'.$one_tp_stat['active_count'].'</td><td>'.$one_tp_stat['completed_tasks'].'</td><td>'.$one_tp_stat['pending_tasks'].'</td>';
- endforeach;
- ?>
+ <?php foreach ($tp_stats as $one_tp_stat): ?>
+ <tr>
+ <td><?=$one_tp_stat['name']?></td>
+ <td><?=$one_tp_stat['active_count']?></td>
+ <td><?=$one_tp_stat['completed_tasks']?></td>
+ <td><?=$one_tp_stat['pending_tasks']?></td>
+ </tr>
+ <?php endforeach; ?>
</table>
<p>Number of loaded class: <?=$nb_loaded_class?></p>
@@ -129,4 +152,27 @@
echo displayErrorMessage('invoke_garbage_collector');
endif;
?>
-<div><input type="button" value="Trigger Garbage Collector" onclick="triggerGarbageCollector();"/></div>
+<div><input type="button" value="Trigger Garbage Collector" onclick="triggerGarbageCollector();"/></div>
+
+<h3>Column Families Stats</h3>
+
+<form>
+ <div><label for="keyspace_list">Select a Keyspace:</label> <select id="keyspace_list" onchange="buildDropDownOfColumnFamilies();"></select></div>
+
+ <div><label for="columnfamily_list">Select a Column Family:</label> <select id="columnfamily_list" onchange="changeColumnFamily();"></select></div>
+</form>
+
+<h3>Details</h3>
+
+<!-- Column Family Details -->
+<table id="columnfamily_details"></table>
+
+<h3>Key Cache</h3>
+
+<!-- Column Family Key Cache Details -->
+<table id="column_family_key_cache_details"></table>
+
+<h3>Row Cache</h3>
+
+<!-- Column Family Row Cache Details -->
+<table id="column_family_row_cache_details"></table>

0 comments on commit 112fb5d

Please sign in to comment.