]>
git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - src/scripts/qosd
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
24 # Configuration options:
26 my $device = "$ARGV[0]";
28 our %mainsettings = ();
29 require '/var/ipfire/general-functions.pl';
30 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
32 our $rrd_datadir = $mainsettings{'RRDLOG'}."/";
33 our $event_datadir = $mainsettings{'RRDLOG'};
35 our $tc_command = "/sbin/tc";
37 # A trick is to set the environment PERL5LIB to include $GRAPHDIR
38 # This is done by the init-script
39 # ($GRAPHDIR is obtained from /usr/local/etc/ADSL-optimizer.conf)
40 my $include_dir = '/var/ipfire/qos/bin';
43 # Create the $mainsettings{'RRDLOG'} if it doesn't exists
44 if ( ! -d
$mainsettings{'RRDLOG'} ) {
45 print "RRD-datadir not found, creating it: $mainsettings{'RRDLOG'} \n";
46 my $status = system("mkdir $mainsettings{'RRDLOG'}");
47 die "\nERROR cannot create \"$mainsettings{'RRDLOG'}\"\n" unless $status == 0;
53 # or die "Can't become a daemon: $!";
55 # The init scripts will do the right "daemon" thing...
57 print "Becoming a daemon...\n";
60 die "Couldn't fork: $!" unless defined($pid);
67 $SIG{INT
} = $SIG{TERM
} = $SIG{HUP
} = \
&signal_handler
;
68 $SIG{PIPE
} = 'IGNORE';
72 require "$include_dir/parse-func.pl";
73 require "$include_dir/event-func.pl";
74 require "$include_dir/RRD-func.pl";
76 until ($time_to_die) {
78 #print "Parsing tc statistics on $device\n";
79 my $res = parse_class
($device);
81 print " Error when parsing classes on $device\n";
84 #print "Updating RRD data-files\n";
87 # print " Error updating RRDs: \"$res\"\n";
90 # my $timestamp = time;
91 # print "$timestamp\n";
96 print "tc-collector daemon exiting ... bye bye!\n";