Server IP : 195.201.23.43 / Your IP : 18.220.112.188 Web Server : Apache System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64 User : kdecoratie ( 1041) PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/share/webmin/syslog-ng/ |
Upload File : |
#!/usr/bin/perl # Show a log file require './syslog-ng-lib.pl'; &ReadParse(); &foreign_require("proc", "proc-lib.pl"); # Work out the file $conf = &get_config(); if ($in{'dest'}) { # From a destination @dests = &find("destination", $conf); ($dest) = grep { $_->{'value'} eq $in{'dest'} } @dests; $dest || &error($text{'destination_egone'}); $file = &find_value("file", $dest->{'members'}); } elsif ($in{'omod'}) { # From another module @others = &get_other_module_logs($in{'omod'}); ($other) = grep { $_->{'mindex'} == $in{'oidx'} } @others; if ($other->{'file'}) { $file = $other->{'file'}; } else { $cmd = $other->{'cmd'}; } } print "Refresh: $config{'refresh'}\r\n" if ($config{'refresh'}); &ui_print_header("<tt>".($file || $cmd)."</tt>", $text{'view_title'}, ""); $lines = $in{'lines'} ? int($in{'lines'}) : int($config{'lines'}); $filter = $in{'filter'} ? quotemeta($in{'filter'}) : ""; &filter_form(); $| = 1; print "<pre>"; local $tailcmd = $config{'tail_cmd'} || "tail -n LINES"; $tailcmd =~ s/LINES/$lines/g; if ($filter ne "") { # Are we supposed to filter anything? Then use grep. local @cats; if ($cmd) { push(@cats, $cmd); } elsif ($config{'compressed'}) { # All compressed versions foreach $l (&all_log_files($file)) { $c = &catter_command($l); push(@cats, $c) if ($c); } } else { # Just the one log @cats = ( "cat ".quotemeta($file) ); } $cat = "(".join(" ; ", @cats).")"; $got = &foreign_call("proc", "safe_process_exec", "$cat | grep -i $filter | $tailcmd", 0, 0, STDOUT, undef, 1, 0, undef, 1); } else { # Not filtering .. so cat the most recent non-empty file if ($cmd) { # Getting output from a command $fullcmd = $cmd." | ".$tailcmd; } elsif ($config{'compressed'}) { # Find the first non-empty file, newest first $catter = "cat ".quotemeta($file); if (!-s $file) { foreach $l (&all_log_files($file)) { next if (!-s $l); $c = &catter_command($l); if ($c) { $catter = $c; last; } } } $fullcmd = $catter." | ".$tailcmd; } else { # Just run tail on the file $fullcmd = $tailcmd." ".quotemeta($file); } $got = &foreign_call("proc", "safe_process_exec", $fullcmd, 0, 0, STDOUT, undef, 1, 0, undef, 1); } print "<i>$text{'view_empty'}</i>\n" if (!$got); print "</pre>\n"; &filter_form(); &ui_print_footer("list_destinations.cgi", $text{'destinations_return'}, "", $text{'index_return'}); sub filter_form { print "<form action=view_log.cgi style='margin-left:1em'>\n"; print &ui_hidden("dest", $in{'dest'}),"\n"; print &ui_hidden("oidx", $in{'oidx'}),"\n"; print &ui_hidden("omod", $in{'omod'}),"\n"; print &text('view_header', &ui_textbox("lines", $lines, 3), "<tt>".&html_escape($log->{'file'})."</tt>"),"\n"; print " \n"; print &text('view_filter', &ui_textbox("filter", $in{'filter'}, 25)),"\n"; print " \n"; print "<input type=submit value='$text{'view_refresh'}'></form>\n"; }Private