%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 49.231.201.246 / Your IP : 216.73.216.149 Web Server : Apache/2.4.18 (Ubuntu) System : User : root ( 0) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : exec,passthru,mail,shell_exec,system,proc_open,popen,ini_alter,dl,proc_close,curl_exec,curl_multi_exec,readfile,parse_ini_file,escapeshellarg,escapeshellcmd,show_source,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,pcntl_unshare,mail,php_uname,phpinfo MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/webmin/bandwidth/ |
Upload File : |
#!/usr/bin/perl # Parse the firewall log and rotate it $no_acl_check++; use Time::Local; require './bandwidth-lib.pl'; our (%config, $module_config_file, $module_var_directory, $pid_file, $syslog_module, $syslog_journald, $bandwidth_log); my ($logfh, $timestamp_file, $lastline); # Detect firewall system if needed if (!$config{'firewall_system'}) { my $sys = &detect_firewall_system(); if ($sys) { $config{'firewall_system'} = $sys; &lock_file($module_config_file); &save_module_config(); &unlock_file($module_config_file); } else { die("Failed to detect firewall system!\n"); } } # See if this process is already running if (my $pid = &check_pid_file($pid_file)) { print STDERR "rotate.pl process $pid is already running\n"; exit(1); } open(my $pid, ">$pid_file"); print $pid $$,"\n"; close($pid); # Get the current time my $time_now = time(); my @time_now = localtime($time_now); my @hours = ( ); # Pre-process command &pre_process(); # Open the log file or pipe to journalctl if ($syslog_journald) { $timestamp_file = "$module_var_directory/last-processed"; my $last_processed = 0; if (-r $timestamp_file) { $last_processed = &read_file_contents($timestamp_file); chomp($last_processed); $last_processed = int($last_processed) || 0; } my $journal_cmd = &has_command("journalctl"); $journal_cmd = "$journal_cmd -k --since=\@$last_processed ". "--until=\@$time_now --grep=\"BANDWIDTH_(IN|OUT):\""; open($logfh, '-|', $journal_cmd) || die("Cannot open $journal_cmd pipe: $!\n"); } else { open($logfh, "<".$bandwidth_log) || die("Cannot open $bandwidth_log: $!\n"); } # Scan the entries in the log file while(<$logfh>) { if (&process_line($_, \@hours, $time_now)) { # Found a valid line $lastline = $_; } elsif (/last\s+message\s+repeated\s+(\d+)/) { # re-process the last line N-1 times for(my $i=0; $i<$1-1; $i++) { &process_line($lastline, \@hours, $time_now); } } else { #print "skipping $_"; } } close($logfh); # Save all hours foreach my $hour (@hours) { &save_hour($hour); } # Truncate the file (if it exists) and notify syslog if (-r $bandwidth_log) { open(my $log, ">".$bandwidth_log); close($log); } &foreign_call($syslog_module, "signal_syslog") if (!$syslog_journald); # Save last collection time to start from here next time if ($syslog_journald && @hours) { &lock_file($timestamp_file); &write_file_contents($timestamp_file, $time_now); &unlock_file($timestamp_file); } # Remove PID file unlink($pid_file); # Exit with success exit(0);