2 # Parse the firewall log and rotate it
5 require './bandwidth-lib.pl';
8 # Detect firewall system if needed
9 if (!$config{'firewall_system'}) {
10 $sys = &detect_firewall_system();
12 $config{'firewall_system'} = $sys;
13 &save_module_config();
16 die "Failed to detect firewall system!";
20 # See if this process is already running
21 if ($pid = &check_pid_file($pid_file)) {
22 print STDERR "rotate.pl process $pid is already running\n";
25 open(PID, ">$pid_file");
30 @time_now = localtime($time_now);
33 # Scan the entries in the log file
35 open(LOG, $bandwidth_log);
37 if (&process_line($_, \@hours, $time_now)) {
41 elsif (/last\s+message\s+repeated\s+(\d+)/) {
42 # re-process the last line N-1 times
43 for($i=0; $i<$1-1; $i++) {
44 &process_line($lastline, \@hours, $time_now);
54 foreach $hour (@hours) {
58 # Truncate the file and notify syslog
59 open(LOG, ">$bandwidth_log");
61 &foreign_call($syslog_module, "signal_syslog");