root/tags/omega-1.0.0-rc3/engine/traffic/ispcp-vrl-traff-SUSE

Revision 784, 18.9 KB (checked in by raphael, 17 months ago)

Fixed some drawn backs in previous revisions
Added support for multiple anti-rootkit tools (including colouring for chkrootkit-like logs)
Correctly fixed #619
Fixed #621: database name being escaped with single quote in include/i18n.php
Fixed an error where mount points with special characters where converted to IDN format
Removed cron.d/ispcp.phptemp (merged into cron.d/ispcp)
Fixed error when restarting ispCP services when they were not already running
Awstats entry in cron.d/ispcp is not built into ispcp-setup anymore
Partially updated fedora's, redhat's and suse10's config files
Updated cs_CS translation (thanks to Josef Pinc)

Line 
1#!/usr/bin/perl
2
3# ispCP ω (OMEGA) a Virtual Hosting Control Panel
4# Copyright (c) 2001-2006 by moleSoftware GmbH
5# http://www.molesoftware.com
6# Copyright (c) 2006-2007 by isp Control Panel
7# http://isp-control.net
8#
9#
10# License:
11#    This program is free software; you can redistribute it and/or
12#    modify it under the terms of the MPL Mozilla Public License
13#    as published by the Free Software Foundation; either version 1.1
14#    of the License, or (at your option) any later version.
15#
16#    This program is distributed in the hope that it will be useful,
17#    but WITHOUT ANY WARRANTY; without even the implied warranty of
18#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19#    MPL Mozilla Public License for more details.
20#
21#    You may have received a copy of the MPL Mozilla Public License
22#    along with this program.
23#
24#    An on-line copy of the MPL Mozilla Public License can be found
25#    http://www.mozilla.org/MPL/MPL-1.1.html
26#
27#
28# The ispCP ω Home Page is at:
29#
30#    http://isp-control.net
31#
32
33use FindBin;
34use lib "$FindBin::Bin/..";
35require 'ispcp_common_code.pl';
36
37%main::ftp_traffic = ();
38
39%main::smtp_traffic = ();
40
41%main::po_traffic = ();
42
43
44use strict;
45
46use warnings;
47
48use File::Basename;
49
50
51sub zero_traffic_entries {
52
53    my ($key, $value) = (undef, undef);
54
55    push_el(\@main::el, 'zero_traffic_entries()', 'Starting...');
56
57    while (($key, $value) = each %main::domain_name_id) {
58
59        $main::ftp_traffic{$key} = 0;
60
61        $main::smtp_traffic{$key} = 0;
62
63        $main::po_traffic{$key} = 0;
64
65    }
66
67#    while (($key, $value) = each %main::sub_name_id) {
68
69#        $main::ftp_traffic{$key} = 0;
70
71#        $main::smtp_traffic{$key} = 0;
72
73#        $main::po_traffic{$key} = 0;
74
75#    }
76
77        # Added by Erik Lehmann 22.08.2005
78        #---------------
79    while (($key, $value) = each %main::als_name_id) {
80
81        $main::ftp_traffic{$key} = 0;
82
83        $main::smtp_traffic{$key} = 0;
84
85        $main::po_traffic{$key} = 0;
86
87    }
88        #---------------
89
90    push_el(\@main::el, 'zero_traffic_entries()', 'Ending...');
91
92    return 0;
93
94}
95
96sub diff_command {
97
98    my ($cmd) = @_;
99
100    push_el(\@main::el, 'diff_command()', 'Starting...');
101
102    my $result = system($cmd);
103
104    my $exit_value  = $? >> 8;
105
106    my $signal_num  = $? & 127;
107
108    my $dumped_core = $? & 128;
109
110    if ($exit_value == 2) {
111
112        push_el(\@main::el, 'diff_command()', "ERORR: '$cmd' returned '$exit_value' !");
113
114        return $exit_value;
115
116    }
117
118    push_el(\@main::el, 'diff_command()', 'Ending...');
119
120    return $exit_value;
121
122}
123
124sub gen_log_file {
125
126    my ($fname, $src_dir, $dest_dir) = @_;
127
128    push_el(\@main::el, 'gen_log_file()', 'Starting...');
129
130    my $rs = undef;
131
132    # Changed by Erik Lehmann 02.06.2005
133        #-----------------------
134    $fname =~ s/\/*//i;
135
136    my $src_file = "$src_dir/$fname";
137
138    my $dest_file = "$dest_dir/".basename($fname);
139
140    my $dest_file_prev = "$dest_dir/".basename($fname).".perv";
141        #-----------------------
142
143    my $log_file = $dest_file;
144
145    $rs = sys_command("$main::cfg{'CMD_CP'} $src_file $dest_file");
146
147    return ($rs, '') if ($rs != 0);
148
149        if (-e $dest_file_prev) {
150
151                my $prev_size = -s $dest_file_prev;
152
153                if ($prev_size > $main::cfg{'PREV_TRAFF_LOG_MAX_SIZE'}) {
154
155                        $rs = del_file($dest_file_prev);
156
157                        return ($rs, "del_file($dest_file_prev)") if ($rs != 0);
158
159                }
160
161        }
162
163    if (-e $dest_file_prev) {
164
165        if (diff_command("$main::cfg{'CMD_DIFF'} -a -q $dest_file $dest_file_prev") == 0) {
166
167            $rs = del_file($dest_file);
168
169            return ($rs, '') if ($rs != 0);
170
171            return (0, '_no_');
172
173        }
174
175        $log_file = $dest_file.".diff";
176
177        diff_command("$main::cfg{'CMD_DIFF'} -a $dest_file $dest_file_prev | grep '<' 1> $log_file");
178
179        my $diff_data = get_file($log_file);
180
181        $diff_data =~ s/^\< //gim;
182
183        $rs = store_file($log_file, $diff_data, 'root', 'root', 0644);
184
185        return ($rs, '') if ($rs != 0);
186
187        $rs = sys_command("$main::cfg{'CMD_MV'} $dest_file $dest_file_prev");
188
189        return ($rs, '') if ($rs != 0);
190
191    } else {
192
193        $rs = sys_command("$main::cfg{'CMD_CP'} $dest_file $dest_file_prev");
194
195        return ($rs, '') if ($rs != 0);
196
197    }
198
199    push_el(\@main::el, 'gen_log_file()', 'Ending...');
200
201    return (0, $log_file);
202}
203
204sub collect_http_traffic {
205
206    my ($key, $value, $timestamp, $sum) = (undef, undef, time(), 0);
207
208    # timestamp has floor down for the last half'n our to make timestamps in
209        # server_traffic and domain_traffic the same
210    $timestamp = $timestamp - ($timestamp % 1800);
211
212    my ($rs, $rdata) = (undef, undef);
213
214    push_el(\@main::el, 'collect_http_traffic()', 'Starting...');
215
216    while (($key,$value) = each %main::domain_name_id) {
217
218        my $domain_log = "$key-traf.log";
219
220        ($rs, $rdata) = gen_log_file($domain_log, $main::cfg{'APACHE_LOG_DIR'}, $main::cfg{'APACHE_BACKUP_LOG_DIR'});
221
222        return ($rs, '') if ($rs != 0);
223
224        $sum = 0;
225
226        if ($rdata ne '_no_') {
227
228            my $rlog = $rdata;
229
230            ($rs, $rdata) = get_file($rlog);
231
232            return ($rs, '') if ($rs != 0);
233
234            my @rows = split(/\n/, $rdata);
235
236            foreach (@rows) {
237
238                my $line = "$_\n";
239
240                $sum += $1 if ($line =~ /(\d+)\n$/);
241
242            }
243
244            $rs = del_file($rlog);
245
246            return ($rs, '') if ($rs != 0);
247
248        }
249
250        my $sql = undef;
251
252        $sql = "insert into domain_traffic (domain_id, dtraff_time, dtraff_web, dtraff_ftp, dtraff_mail, dtraff_pop) values ('$value', '$timestamp', '$sum', '0', '0', '0');";
253
254        ($rs, $rdata) = doSQL($sql);
255
256        return ($rs, '') if ($rs != 0);
257
258    }
259
260    push_el(\@main::el, 'collect_http_traffic()', 'Ending...');
261
262    return (0, $timestamp);
263}
264
265sub collect_ftp_traffic {
266
267    my ($timestamp) = @_;
268
269    my ($key, $value, $id) = (undef, undef, undef);
270
271    my ($rs, $rdata, $rlog) = (undef, undef, undef);
272
273        # Added by Erik Lehmann 22.08.2005
274        my $traffic_size = undef;
275        my $traffic_domain = undef;
276
277    ($rs, $rlog) = gen_log_file($main::cfg{'FTP_TRAFF_LOG'}, $main::cfg{'TRAFF_LOG_DIR'}, $main::cfg{'APACHE_BACKUP_LOG_DIR'});
278
279    return $rs if ($rs != 0);
280
281    if ($rlog ne '_no_') {
282
283        ($rs, $rdata) = get_file($rlog);
284
285        return $rs if ($rs != 0);
286
287        my @rows = split(/\n/, $rdata);
288
289        foreach (@rows) {
290
291            my $line = "$_\n";
292
293            if ($line =~ /^(\d+) [^\@]+\@([^\n]+)\n$/) {
294
295                                # Added by Erik Lehmann 22.08.2005
296                                #---------------
297                                $traffic_size = $1;
298                                $traffic_domain = $2;
299
300                                if($traffic_domain =~ /(.*)(\.)(.*\.)(.*)$/ && !exists $main::ftp_traffic{$traffic_domain}) {
301                                        $main::ftp_traffic{$3.$4} += $traffic_size;
302                                }
303                                else {
304                                        $main::ftp_traffic{$traffic_domain} += $traffic_size;
305                                }
306                                #---------------
307
308            }
309
310        }
311
312        while (($key, $value) = each %main::ftp_traffic) {
313
314                        # Added by Erik Lehmann 22.08.2005
315                        #---------------
316            if ($id = $main::als_name_id{$key}) {
317                $main::ftp_traffic{
318                    $main::domain_id_name {
319                        $main::als_id_parentid{$id}
320                    }
321                } += $value;
322            }
323                        #---------------
324
325        }
326
327        $rs = del_file($rlog);
328
329        return $rs if ($rs != 0);
330    }
331
332    while (($key, $value) = each %main::ftp_traffic) {
333
334        if ($id = $main::domain_name_id{$key}) {
335
336            my $sql = undef;
337
338            $sql = "update domain_traffic set dtraff_ftp = $value where dtraff_time = $timestamp and domain_id = $id;";
339
340            ($rs, $rdata) = doSQL($sql);
341
342            return $rs if ($rs != 0);
343
344        }
345    }
346}
347
348sub collect_mail_traffic {
349
350    my ($timestamp) = @_;
351
352
353    my ($key, $value, $id) = (undef, undef, undef);
354
355    my ($rs, $rdata, $rlog) = (undef, undef);
356
357        # Added by Erik Lehmann 22.08.2005
358        my $traffic_size = undef;
359    my $traffic_domain = undef;
360        my $smtp_from_domain = undef;
361        my $smtp_to_domain = undef;
362
363    ($rs, $rlog) = gen_log_file($main::cfg{'MAIL_TRAFF_LOG'}, $main::cfg{'TRAFF_LOG_DIR'}, $main::cfg{'APACHE_BACKUP_LOG_DIR'});
364
365    return $rs if ($rs != 0);
366
367
368    if ($rlog ne '_no_') {
369
370        my $smtp_log = "$main::cfg{'APACHE_BACKUP_LOG_DIR'}/smtp.log";
371
372        my $smtp_delivery_log = "$main::cfg{'APACHE_BACKUP_LOG_DIR'}/smtp_delivery.log";
373
374        my $imap_log = "$main::cfg{'APACHE_BACKUP_LOG_DIR'}/imap.log";
375
376        my $pop3_log = "$main::cfg{'APACHE_BACKUP_LOG_DIR'}/pop3.log";
377
378
379        # Changed by Erik Lehmann 07.06.2005
380        my $cmd = "$main::cfg{'CMD_CAT'} $rlog | $main::cfg{'CMD_GREP'} 'postfix' | $main::cfg{'CMD_PFLOGSUM'} standard 1>$smtp_delivery_log";
381
382        $rs = sys_command($cmd);
383
384        return $rs if ($rs != 0);
385
386        # Changed by Erik Lehmann 22.08.2005
387        # bugfix by Erik Lehmann 23.10.2005
388                if(exists  $main::cfg{'MAIL_LOG_INC_AMAVIS'} && $main::cfg{'MAIL_LOG_INC_AMAVIS'}) {
389                        # Logs including AMAVIS/SPAMASSASSIN/CLAMAV entries
390                $cmd = "$main::cfg{'CMD_CAT'} $smtp_delivery_log | $main::cfg{'CMD_AWK'} '{if (\$5 != \"localhost\" && \$6 != \"virtual\" && \$6 != \"localhost\" && \$10 != \"?\") print substr(\$3, index(\$3, \"@\")+1, length(\$3)),substr(\$4, index(\$4, \"@\")+1, length(\$4)),\$10;}' 1>$smtp_log";
391                }
392                else {
393                        # Logs not including AMAVIS/SPAMASSASSIN/CLAMAV entries
394            $cmd = "$main::cfg{'CMD_CAT'} $smtp_delivery_log | $main::cfg{'CMD_AWK'} '{if (\$5 != \"localhost\" && \$6 != \"localhost\" && \$10 != \"?\") print substr(\$3, index(\$3, \"@\")+1, length(\$3)),substr(\$4, index(\$4, \"@\")+1, length(\$4)),\$10;}' 1>$smtp_log";
395                }
396
397        $rs = sys_command($cmd);
398
399        return $rs if ($rs != 0);
400
401        $rs = del_file($smtp_delivery_log);
402
403        return $rs if ($rs != 0);
404
405        ($rs, $rdata) = get_file($smtp_log);
406
407        return $rs if ($rs != 0);
408
409
410        my @rows = split(/\n/, $rdata);
411
412        foreach (@rows) {
413
414            my $line = "$_\n";
415
416                # Changed by Erik Lehmann 07.06.2005
417            if ($line =~ /^([^\,]+)\ ([^\,]+)\ (\d+)\n$/) {
418
419                                # Added by Erik Lehmann 22.08.2005
420                                #---------------
421                                $smtp_from_domain = $1;
422                                $smtp_to_domain = $2;
423                                $traffic_size = $3;
424
425                                if($smtp_from_domain =~ /(.*)(\.)(.*\.)(.*)$/ && !exists $main::smtp_traffic{$smtp_from_domain}) {
426                                        $smtp_from_domain = $3.$4;
427                                }
428                                if($smtp_to_domain =~ /(.*)(\.)(.*\.)(.*)$/ && !exists $main::smtp_traffic{$smtp_to_domain}) {
429                                        $smtp_to_domain = $3.$4;
430                                }
431                                #---------------
432
433                        # Changed by Erik Lehmann 22.08.2005
434                                #---------------
435                if(exists $main::smtp_traffic{$smtp_from_domain}) {
436                        $main::smtp_traffic{$smtp_from_domain} += $traffic_size;
437                                }
438                                else {
439                        $main::smtp_traffic{$smtp_to_domain} += $traffic_size;
440                }
441
442            }
443
444        }
445
446        while (($key, $value) = each %main::smtp_traffic) {
447
448                        # Added by Erik Lehmann 22.08.2005
449                        #---------------
450            if ($id = $main::als_name_id{$key}) {
451                $main::smtp_traffic{
452                    $main::domain_id_name {
453                        $main::als_id_parentid{$id}
454                    }
455                } += $value;
456            }
457                        #---------------
458
459        }
460
461        $rs = del_file($smtp_log);
462
463        return $rs if ($rs != 0);
464
465
466                # IMAP
467                $rs = sys_command("$main::cfg{'CMD_CAT'} $rlog|$main::cfg{'CMD_GREP'} 'imapd'|$main::cfg{'CMD_GREP'} 'user='|$main::cfg{'CMD_GREP'} 'body='|$main::cfg{'CMD_GREP'} -v 'ip=\\[::ffff:127.0.0.1\\]'|$main::cfg{'CMD_AWK'} '{print \$7,\$9,substr(\$10,1,length(\$10)-1);}' 1>$imap_log");
468
469        return $rs if ($rs != 0);
470
471        ($rs, $rdata) = get_file($imap_log);
472
473        return $rs if ($rs != 0);
474
475
476        @rows = split(/\n/, $rdata);
477
478        foreach (@rows) {
479
480            my $line = "$_\n";
481
482            if ($line =~ /^user=([^\,]+)\, headers=(\d+), body=(\d+)\n$/) {
483
484                my ($ma, $sum) = ("$1\n", $2 + $3);
485
486                $ma =~ /^([^\@]+)\@([^\n]+)\n$/;
487
488                                # Added by Erik Lehmann 22.08.2005
489                                #---------------
490                                $traffic_domain = $2;
491
492                                if($traffic_domain =~ /(.*)(\.)(.*\.)(.*)$/ && !exists $main::po_traffic{$traffic_domain}) {
493                                        $main::po_traffic{$3.$4} += $sum;
494                                }
495                                else {
496                                        $main::po_traffic{$traffic_domain} += $sum;
497                                }
498                                #---------------
499
500            }
501
502        }
503
504
505        $rs = del_file($imap_log);
506
507        return $rs if ($rs != 0);
508
509
510                # IMAP-SSL
511                $rs = sys_command("$main::cfg{'CMD_CAT'} $rlog|$main::cfg{'CMD_GREP'} 'imapd-ssl'|$main::cfg{'CMD_GREP'} 'user='|$main::cfg{'CMD_GREP'} 'body='|$main::cfg{'CMD_GREP'} -v 'ip=\\[::ffff:127.0.0.1\\]'|$main::cfg{'CMD_AWK'} '{print \$7,\$9,substr(\$10,1,length(\$10)-1);}' 1>$imap_log");
512
513        return $rs if ($rs != 0);
514
515
516        ($rs, $rdata) = get_file($imap_log);
517
518        return $rs if ($rs != 0);
519
520
521        @rows = split(/\n/, $rdata);
522
523        foreach (@rows) {
524
525            my $line = "$_\n";
526
527            if ($line =~ /^user=([^\,]+)\, headers=(\d+), body=(\d+)\n$/) {
528
529                my ($ma, $sum) = ("$1\n", $2 + $3);
530
531                $ma =~ /^([^\@]+)\@([^\n]+)\n$/;
532
533                                # Added by Erik Lehmann 22.08.2005
534                                #---------------
535                                $traffic_domain = $2;
536
537                                if($traffic_domain =~ /(.*)(\.)(.*\.)(.*)$/ && !exists $main::po_traffic{$traffic_domain}) {
538                                        $main::po_traffic{$3.$4} += $sum;
539                                }
540                                else {
541                                        $main::po_traffic{$traffic_domain} += $sum;
542                                }
543                                #---------------
544
545            }
546
547        }
548
549
550        $rs = del_file($imap_log);
551
552        return $rs if ($rs != 0);
553
554
555                # POP3
556        $rs = sys_command("$main::cfg{'CMD_CAT'} $rlog|$main::cfg{'CMD_GREP'} 'pop3d'|$main::cfg{'CMD_GREP'} 'user='|$main::cfg{'CMD_GREP'} 'top='|$main::cfg{'CMD_GREP'} -v 'ip=\\[::ffff:127.0.0.1\\]'|$main::cfg{'CMD_AWK'} '{print \$7,\$9,substr(\$10,1,length(\$10)-1);}' 1>$pop3_log");
557
558        return $rs if ($rs != 0);
559
560        ($rs, $rdata) = get_file($pop3_log);
561
562        return $rs if ($rs != 0);
563
564
565        @rows = split(/\n/, $rdata);
566
567        foreach (@rows) {
568
569            my $line = "$_\n";
570
571            if ($line =~ /^user=([^\,]+)\, top=(\d+), retr=(\d+)\n$/) {
572
573                my ($ma, $sum) = ("$1\n", $2 + $3);
574
575                $ma =~ /^([^\@]+)\@([^\n]+)\n$/;
576
577                                # Added by Erik Lehmann 22.08.2005
578                                #---------------
579                                $traffic_domain = $2;
580
581                                if($traffic_domain =~ /(.*)(\.)(.*\.)(.*)$/ && !exists $main::po_traffic{$traffic_domain}) {
582                                        $main::po_traffic{$3.$4} += $sum;
583                                }
584                                else {
585                                        $main::po_traffic{$traffic_domain} += $sum;
586                                }
587                                #---------------
588
589            }
590
591        }
592
593        $rs = del_file($pop3_log);
594
595        return $rs if ($rs != 0);
596
597
598        # POP3-SSL
599        $rs = sys_command("$main::cfg{'CMD_CAT'} $rlog|$main::cfg{'CMD_GREP'} 'pop3d-ssl'|$main::cfg{'CMD_GREP'} 'user='|$main::cfg{'CMD_GREP'} 'retr='|$main::cfg{'CMD_GREP'} -v 'ip=\\[::ffff:127.0.0.1\\]'|$main::cfg{'CMD_AWK'} '{print \$7,\$9,substr(\$10,1,length(\$10)-1);}' 1>$pop3_log");
600
601        return $rs if ($rs != 0);
602
603        ($rs, $rdata) = get_file($pop3_log);
604
605        return $rs if ($rs != 0);
606
607
608        @rows = split(/\n/, $rdata);
609
610        foreach (@rows) {
611
612            my $line = "$_\n";
613
614            if ($line =~ /^user=([^\,]+)\, top=(\d+), retr=(\d+)\n$/) {
615
616                my ($ma, $sum) = ("$1\n", $2 + $3);
617
618                $ma =~ /^([^\@]+)\@([^\n]+)\n$/;
619
620                                # Added by Erik Lehmann 22.08.2005
621                                #---------------
622                                $traffic_domain = $2;
623
624                                if($traffic_domain =~ /(.*)(\.)(.*\.)(.*)$/ && !exists $main::po_traffic{$traffic_domain}) {
625                                        $main::po_traffic{$3.$4} += $sum;
626                                }
627                                else {
628                                        $main::po_traffic{$traffic_domain} += $sum;
629                                }
630                                #---------------
631
632            }
633
634        }
635
636        while (($key, $value) = each %main::po_traffic) {
637
638                        # Added by Erik Lehmann 22.08.2005
639                        #---------------
640            if ($id = $main::als_name_id{$key}) {
641                $main::po_traffic {
642                    $main::domain_id_name {
643                        $main::als_id_parentid{$id}
644                    }
645                } += $value;
646
647            }
648                        #---------------
649
650        }
651
652        $rs = del_file($pop3_log);
653
654        return $rs if ($rs != 0);
655
656        $rs = del_file($rlog);
657
658        return $rs if ($rs != 0);
659
660
661    }
662
663    while (($key, $value) = each %main::smtp_traffic) {
664
665        if ($id = $main::domain_name_id{$key}) {
666
667            my $sql = undef;
668
669            $sql = "update domain_traffic set dtraff_mail = $value where dtraff_time = $timestamp and domain_id = $id;";
670
671            ($rs, $rdata) = doSQL($sql);
672
673            return $rs if ($rs != 0);
674
675        }
676    }
677
678    while (($key, $value) = each %main::po_traffic) {
679
680        if ($id = $main::domain_name_id{$key}) {
681
682            my $sql = undef;
683
684            $sql = "update domain_traffic set dtraff_pop = $value where dtraff_time = $timestamp and domain_id = $id;";
685
686            ($rs, $rdata) = doSQL($sql);
687
688            return $rs if ($rs != 0);
689
690        }
691    }
692
693    return 0;
694
695}
696
697
698sub vrl_traff_start_up {
699
700    my ($rs, $rdata) = (undef, undef);
701
702    push_el(\@main::el, 'vrl_traff_start_up()', 'Starting...');
703
704    # Let's clear Execution Logs, if any.
705
706    if (-e $main::ispcp_vrl_traff_el) {
707
708        $rs = del_file($main::ispcp_vrl_traff_el);
709
710        return $rs if ($rs != 0);
711
712    }
713
714    # config check;
715
716    $rs = get_conf();
717
718    return $rs if ($rs != 0);
719
720    #
721    # getting initial data also must be done here;
722    #
723
724    my $sql = "
725        SELECT
726                domain_id,
727                domain_name,
728                domain_gid,
729                domain_uid,
730                domain_admin_id,
731                domain_created_id,
732                domain_created,
733                domain_last_modified,
734                domain_mailacc_limit,
735                domain_ftpacc_limit,
736                domain_traffic_limit,
737                domain_sqld_limit,
738                domain_sqlu_limit,
739                domain_status,
740                domain_alias_limit,
741                domain_ip_id,
742                domain_disk_limit,
743                domain_disk_usage,
744                domain_php,
745                domain_cgi
746        FROM
747                domain
748    ";
749
750    ($rs, $rdata) = doSQL($sql);
751
752    return $rs if ($rs != 0);
753
754    $rs = get_domain_ids();
755
756    return $rs if ($rs != 0);
757
758#    $rs = get_subdom_ids();
759
760#    return $rs if ($rs != 0);
761
762        # Added by Erik Lehmann 22.08.2005
763        #---------------
764    $rs = get_alias_ids();
765
766    return $rs if ($rs != 0);
767        #---------------
768
769    $rs = zero_traffic_entries();
770
771    return $rs if ($rs != 0);
772
773    push_el(\@main::el, 'vrl_traff_start_up()', 'Ending...');
774
775    return 0;
776
777}
778
779
780sub vrl_traff_shut_down {
781
782    my $rs = undef;
783
784    push_el(\@main::el, 'vrl_traff_shut_down()', 'Starting...');
785
786    push_el(\@main::el, 'vrl_traff_shut_down()', 'Ending...');
787
788    return 0;
789
790}
791
792sub vrl_traff_engine {
793
794    my ($rs, $timestamp) = (undef, undef);
795
796    push_el(\@main::el, 'vrl_traff_engine()', 'Starting...');
797
798    ($rs, $timestamp) = collect_http_traffic();
799
800    return $rs if ($rs != 0);
801
802    $rs = collect_ftp_traffic($timestamp);
803
804    return $rs if ($rs != 0);
805
806    $rs = collect_mail_traffic($timestamp);
807
808    return $rs if ($rs != 0);
809
810    push_el(\@main::el, 'vrl_traff_engine()', 'Ending...');
811
812    return 0;
813
814}
815
816
817my $rs = undef;
818
819
820$rs = vrl_traff_start_up();
821
822if ($rs != 0) {
823
824    dump_el(\@main::el, $main::ispcp_vrl_traff_el);
825
826    vrl_traff_shut_down();
827
828    exit 1;
829
830}
831
832
833$rs = vrl_traff_engine();
834
835if ($rs != 0) {
836
837    dump_el(\@main::el, $main::ispcp_vrl_traff_el);
838
839    vrl_traff_shut_down();
840
841    exit 1;
842
843}
844
845
846$rs = vrl_traff_shut_down();
847
848if ($rs != 0) {
849
850    dump_el(\@main::el, $main::ispcp_vrl_traff_el);
851
852    exit 1;
853
854}
855
856exit 0;
Note: See TracBrowser for help on using the browser.