2004-06-09 19:15:57 +00:00
|
|
|
<?php
|
2003-07-02 22:33:18 +00:00
|
|
|
|
|
|
|
// grep logs for a particular string
|
|
|
|
|
2004-02-02 23:34:39 +00:00
|
|
|
require_once("../inc/util_ops.inc");
|
2003-07-02 22:33:18 +00:00
|
|
|
|
2004-08-20 18:45:43 +00:00
|
|
|
$log_dir = parse_config(get_config(), "<log_dir>");
|
2003-07-02 22:33:18 +00:00
|
|
|
if (!$log_dir) {
|
|
|
|
exit("Error: couldn't get log_dir from config file.");
|
|
|
|
}
|
|
|
|
|
2003-07-15 21:37:04 +00:00
|
|
|
$f = $_GET["f"];
|
|
|
|
$s = $_GET["s"];
|
2003-07-22 20:52:25 +00:00
|
|
|
$l = (int)$_GET["l"];
|
2003-07-15 21:37:04 +00:00
|
|
|
|
2004-12-01 22:44:47 +00:00
|
|
|
//if (!$f || !preg_match("/^ *([a-z_*]+[.](log|out) *)+$/", $f)) {
|
|
|
|
// $f = 'log_*/*.log';
|
|
|
|
//}
|
2003-07-02 22:33:18 +00:00
|
|
|
|
|
|
|
if ($s) {
|
|
|
|
page_head("Grep logs for \"$s\"");
|
|
|
|
} else {
|
|
|
|
page_head("Show logs");
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "<form action=show_log.php>";
|
2003-07-02 22:52:53 +00:00
|
|
|
echo " Regexp: <input name=s value='$s'>";
|
2003-07-02 22:33:18 +00:00
|
|
|
echo " Files: <input name=f value='$f'>";
|
2003-07-22 20:52:25 +00:00
|
|
|
echo " Lines: <input name=l value='$l'> (positive for head, negative for tail)";
|
2003-07-02 22:33:18 +00:00
|
|
|
echo " <input type=submit value=Grep></form>";
|
|
|
|
|
2003-07-15 21:28:42 +00:00
|
|
|
echo 'Hint: Example greps: "RESULT#106876", "26fe99aa_25636_00119.wu_1", "WU#8152", "too many errors", "2003-07-17", "CRITICAL" <br>';
|
2003-07-02 22:52:53 +00:00
|
|
|
|
2004-12-31 01:15:50 +00:00
|
|
|
if (strlen($f))
|
|
|
|
$f = "../log*/". $f;
|
|
|
|
else
|
2004-12-31 01:27:50 +00:00
|
|
|
$f = "../log*/*.log";
|
2004-12-31 01:15:50 +00:00
|
|
|
|
2003-07-22 20:52:25 +00:00
|
|
|
passthru("cd $log_dir && ../bin/grep_logs -html -l $l '$s' $f 2>&1 $lines");
|
2003-07-02 22:33:18 +00:00
|
|
|
|
|
|
|
page_tail();
|
2004-06-09 19:15:57 +00:00
|
|
|
?>
|