Skip to content

Commit

Permalink
added filters for mutexstatus2 and stacktrace files (fixes #10)
Browse files Browse the repository at this point in the history
  • Loading branch information
gavin committed Sep 24, 2012
1 parent 39b2d1a commit ed8abff
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
collected/*
!collected/index.html
*~
conf/config2.inc.php
index2.php
21 changes: 21 additions & 0 deletions lib/RainGauge.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,27 @@ function ($i, $x, $y) {
$data['file_data'] .= "\n";

}
else if ($file_type == 'stacktrace')
{
$data['file_data'] = htmlspecialchars($this->model->pmp_summary($data['sample'],$data['file']));
$data['file_data'] .= "<br/><hr>";
}
else if ($file_type == 'mutex-status2')
{
$this_ts = substr($data['data'][0]['name'], 0, 19);
$mutexes = $this->model->get_mutex_deltas($data['server'],$data['sample'], $this_ts);
/*
print "<pre>";
print_r($mutexes);
print "</pre>";
*/

arsort($mutexes);

$data['file_data'] = "MUTEX DELTAS\n";
$data['file_data'] .= join("\n", array_map(function ($x,$y) { return "$x = $y"; } , array_keys($mutexes), array_values($mutexes)));
$data['file_data'] .= "<hr>";
}
} else {
$data['file_lines'] = $this->model->sift($data['server'], $data['sample'], get_var('sift'));
}
Expand Down
50 changes: 50 additions & 0 deletions lib/RainGaugeModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ function get_sample($hostname, $filename) {

return $result;
}


/**
* Given a sample for a server, return it's position in the list of all
Expand Down Expand Up @@ -151,6 +152,37 @@ public function get_sample_percent($hostname, $sample) {

return $n / count($samples) * 100;
}

public function get_mutex_deltas($hostname, $sample, $ts)
{
//print "$hostname / $sample / $ts ";
$mutex1 = $this->get_file($hostname, $sample, $ts.'-mutex-status1');
$mutex2 = $this->get_file($hostname, $sample, $ts.'-mutex-status2');

$result = array();
for ($i=0; $i < count($mutex1); $i++)
{

$m1_parts = explode("\t", $mutex1[$i]);
$m2_parts = explode("\t", $mutex2[$i]);

$mutex_name = $m1_parts[1];

list($none, $m1_value) = explode("=", $m1_parts[2]);
list($none, $m2_value) = explode("=", $m2_parts[2]);

//print "$mutex_name: $m1_value, $m2_value<br>";
if (!array_key_exists($mutex_name, $value))
{
$result[$mutex_name] = $m2_value - $m1_value;
}
else
{
$result[$mutex_name] += $m2_value - $m1_value;
}
}
return $result;
}

/**
* given a server and filename, get a valid full path to a collection archive file.
Expand Down Expand Up @@ -489,6 +521,24 @@ public function get_type($name) {
//print "$name<br>\n";
return substr($name, 20);
}

public function pmp_summary($sample, $file)
{
$file = $this->tmp_dir() . '/' . $sample . '/' . $file;

$cmd = "cat {$file} | awk '
BEGIN { s = \"\"; }
/^Thread/ { print s; s = \"\"; }
/^\#/ { if (s != \"\" ) { s = s \",\" $4} else { s = $4 } }
END { print s }' | sort | uniq -c | sort -r -n -k 1,1";

$output = array();
exec($cmd,$output);
//print "<pre>";
//print_r($output);
//print "</pre>";
return join("\n", $output);
}

}

Expand Down
2 changes: 1 addition & 1 deletion views/sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ function update_graph()
<pre class="prettyprint">
<a class="close" href="<?php echo site_url().'?action=server&server='. urlencode($server) ?>" >&times;</a>
<?php echo $file_data; ?>
<?php echo join('', $file_lines); ?>
<?php echo join('', array_map(function ($x) { return htmlspecialchars($x); }, $file_lines)); ?>
</pre>
<?php } ?>

Expand Down

0 comments on commit ed8abff

Please sign in to comment.