4 require './syslog-ng-lib.pl';
6 &foreign_require("proc", "proc-lib.pl");
12 @dests = &find("destination", $conf);
13 ($dest) = grep { $_->{'value'} eq $in{'dest'} } @dests;
14 $dest || &error($text{'destination_egone'});
15 $file = &find_value("file", $dest->{'members'});
19 @others = &get_other_module_logs($in{'omod'});
20 ($other) = grep { $_->{'mindex'} == $in{'oidx'} } @others;
21 if ($other->{'file'}) {
22 $file = $other->{'file'};
25 $cmd = $other->{'cmd'};
29 print "Refresh: $config{'refresh'}\r\n"
30 if ($config{'refresh'});
31 &ui_print_header("<tt>".($file || $cmd)."</tt>", $text{'view_title'}, "");
33 $lines = $in{'lines'} ? int($in{'lines'}) : $config{'lines'};
34 $filter = $in{'filter'} ? quotemeta($in{'filter'}) : "";
40 local $tailcmd = $config{'tail_cmd'} || "tail -n LINES";
41 $tailcmd =~ s/LINES/$lines/g;
43 # Are we supposed to filter anything? Then use grep.
48 elsif ($config{'compressed'}) {
49 # All compressed versions
50 foreach $l (&all_log_files($file)) {
51 $c = &catter_command($l);
52 push(@cats, $c) if ($c);
57 @cats = ( "cat ".quotemeta($file) );
59 $cat = "(".join(" ; ", @cats).")";
60 $got = &foreign_call("proc", "safe_process_exec",
61 "$cat | grep -i $filter | $tailcmd",
62 0, 0, STDOUT, undef, 1, 0, undef, 1);
65 # Not filtering .. so cat the most recent non-empty file
67 # Getting output from a command
68 $fullcmd = $cmd." | ".$tailcmd;
70 elsif ($config{'compressed'}) {
71 # Find the first non-empty file, newest first
72 $catter = "cat ".quotemeta($file);
74 foreach $l (&all_log_files($file)) {
76 $c = &catter_command($l);
83 $fullcmd = $catter." | ".$tailcmd;
86 # Just run tail on the file
87 $fullcmd = $tailcmd." ".quotemeta($file);
89 $got = &foreign_call("proc", "safe_process_exec",
90 $fullcmd, 0, 0, STDOUT, undef, 1, 0, undef, 1);
92 print "<i>$text{'view_empty'}</i>\n" if (!$got);
96 &ui_print_footer("list_destinations.cgi", $text{'destinations_return'},
97 "", $text{'index_return'});
101 print "<form action=view_log.cgi style='margin-left:1em'>\n";
102 print &ui_hidden("dest", $in{'dest'}),"\n";
103 print &ui_hidden("oidx", $in{'oidx'}),"\n";
104 print &ui_hidden("omod", $in{'omod'}),"\n";
106 print &text('view_header', &ui_textbox("lines", $lines, 3),
107 "<tt>".&html_escape($log->{'file'})."</tt>"),"\n";
108 print " \n";
109 print &text('view_filter', &ui_textbox("filter", $in{'filter'}, 25)),"\n";
110 print " \n";
111 print "<input type=submit value='$text{'view_refresh'}'></form>\n";