Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
HOWTO: Bandwidth limiting
View unanswered posts
View posts from last 24 hours

Goto page Previous  1, 2, 3, 4  Next  
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
tnt
Veteran
Veteran


Joined: 27 Feb 2004
Posts: 1222

PostPosted: Tue Jun 14, 2005 11:17 am    Post subject: Reply with quote

This one creates p2p.rrd database:
Code:
#!/usr/bin/perl -w
#

use RRDs;

# define location of rrdtool databases
my $rrd = '/var/lib/rrd';

if (! -e "$rrd/p2p.rrd")
{
        print "creating rrd database for p2p...\n";
        RRDs::create "$rrd/p2p.rrd",
                "-s 300",
                "DS:eth0_in_ft:DERIVE:600:0:12500000",
                "DS:eth0_in_dc:DERIVE:600:0:12500000",
                "DS:eth0_in_gnu:DERIVE:600:0:12500000",
                "DS:eth0_in_bittor:DERIVE:600:0:12500000",
                "DS:eth0_in_oft:DERIVE:600:0:12500000",
                "DS:eth0_in_edonk:DERIVE:600:0:12500000",
                "DS:eth0_in_rest:DERIVE:600:0:12500000",
                "DS:eth0_out_ft:DERIVE:600:0:12500000",
                "DS:eth0_out_dc:DERIVE:600:0:12500000",
                "DS:eth0_out_gnu:DERIVE:600:0:12500000",
                "DS:eth0_out_bittor:DERIVE:600:0:12500000",
                "DS:eth0_out_oft:DERIVE:600:0:12500000",
                "DS:eth0_out_edonk:DERIVE:600:0:12500000",
                "DS:eth0_out_rest:DERIVE:600:0:12500000",
                "DS:eth1_in_ft:DERIVE:600:0:12500000",
                "DS:eth1_in_dc:DERIVE:600:0:12500000",
                "DS:eth1_in_gnu:DERIVE:600:0:12500000",
                "DS:eth1_in_bittor:DERIVE:600:0:12500000",
                "DS:eth1_in_oft:DERIVE:600:0:12500000",
                "DS:eth1_in_edonk:DERIVE:600:0:12500000",
                "DS:eth1_in_rest:DERIVE:600:0:12500000",
                "DS:eth1_out_ft:DERIVE:600:0:12500000",
                "DS:eth1_out_dc:DERIVE:600:0:12500000",
                "DS:eth1_out_gnu:DERIVE:600:0:12500000",
                "DS:eth1_out_bittor:DERIVE:600:0:12500000",
                "DS:eth1_out_oft:DERIVE:600:0:12500000",
                "DS:eth1_out_edonk:DERIVE:600:0:12500000",
                "DS:eth1_out_rest:DERIVE:600:0:12500000",
                "DS:eth2_in_ft:DERIVE:600:0:12500000",
                "DS:eth2_in_dc:DERIVE:600:0:12500000",
                "DS:eth2_in_gnu:DERIVE:600:0:12500000",
                "DS:eth2_in_bittor:DERIVE:600:0:12500000",
                "DS:eth2_in_oft:DERIVE:600:0:12500000",
                "DS:eth2_in_edonk:DERIVE:600:0:12500000",
                "DS:eth2_in_rest:DERIVE:600:0:12500000",
                "DS:eth2_out_ft:DERIVE:600:0:12500000",
                "DS:eth2_out_dc:DERIVE:600:0:12500000",
                "DS:eth2_out_gnu:DERIVE:600:0:12500000",
                "DS:eth2_out_bittor:DERIVE:600:0:12500000",
                "DS:eth2_out_oft:DERIVE:600:0:12500000",
                "DS:eth2_out_edonk:DERIVE:600:0:12500000",
                "DS:eth2_out_rest:DERIVE:600:0:12500000",
                "DS:eth3_in_ft:DERIVE:600:0:12500000",
                "DS:eth3_in_dc:DERIVE:600:0:12500000",
                "DS:eth3_in_gnu:DERIVE:600:0:12500000",
                "DS:eth3_in_bittor:DERIVE:600:0:12500000",
                "DS:eth3_in_oft:DERIVE:600:0:12500000",
                "DS:eth3_in_edonk:DERIVE:600:0:12500000",
                "DS:eth3_in_rest:DERIVE:600:0:12500000",
                "DS:eth3_out_ft:DERIVE:600:0:12500000",
                "DS:eth3_out_dc:DERIVE:600:0:12500000",
                "DS:eth3_out_gnu:DERIVE:600:0:12500000",
                "DS:eth3_out_bittor:DERIVE:600:0:12500000",
                "DS:eth3_out_oft:DERIVE:600:0:12500000",
                "DS:eth3_out_edonk:DERIVE:600:0:12500000",
                "DS:eth3_out_rest:DERIVE:600:0:12500000",
                "RRA:AVERAGE:0.5:1:576",
                "RRA:AVERAGE:0.9:6:672",
                "RRA:AVERAGE:0.9:24:744",
                "RRA:AVERAGE:0.9:288:730",
                "RRA:AVERAGE:0.9:2016:522";
        if ($ERROR = RRDs::error) { print "unable to generate database: $ERROR\n"; }
}


And this one is for system-5m.rrd:
Code:
#!/usr/bin/perl -w
#

use RRDs;

# define location of rrdtool databases
my $rrd = '/var/lib/rrd';

if (! -e "$rrd/system-5min.rrd")
{
        print "creating rrd database for system-5min...\n";
        RRDs::create "$rrd/system-5min.rrd",
                "-s 300",
                "DS:temp_cpu:GAUGE:600:-20:200",
                "DS:temp_sys:GAUGE:600:-20:200",
                "DS:temp_sda:GAUGE:600:-20:200",
                "DS:temp_sdb:GAUGE:600:-20:200",
                "DS:temp_sdc:GAUGE:600:-20:200",
                "DS:temp_sdd:GAUGE:600:-20:200",
                "DS:fan1:GAUGE:600:0:10000",
                "DS:fan2:GAUGE:600:0:10000",
                "DS:fan3:GAUGE:600:0:10000",
                "DS:voltage_cpu:GAUGE:600:0:5",
                "DS:voltage_ram:GAUGE:600:0:5",
                "DS:voltage_33v:GAUGE:600:0:7",
                "DS:voltage_5v:GAUGE:600:0:10",
                "DS:voltage_12v:GAUGE:600:0:20",
                "DS:voltage_bat:GAUGE:600:0:50",
                "DS:cpu0_user:COUNTER:600:0:100",
                "DS:cpu0_nice:COUNTER:600:0:100",
                "DS:cpu0_system:COUNTER:600:0:100",
                "DS:cpu0_iowait:COUNTER:600:0:100",
                "DS:cpu0_irq:COUNTER:600:0:100",
                "DS:cpu0_softirq:COUNTER:600:0:100",
                "DS:cpu1_user:COUNTER:600:0:100",
                "DS:cpu1_nice:COUNTER:600:0:100",
                "DS:cpu1_system:COUNTER:600:0:100",
                "DS:cpu1_iowait:COUNTER:600:0:100",
                "DS:cpu1_irq:COUNTER:600:0:100",
                "DS:cpu1_softirq:COUNTER:600:0:100",
                "DS:time_1000:COUNTER:600:0:300000",
                "DS:time_1800:COUNTER:600:0:300000",
                "DS:load:GAUGE:600:0:U",
                "DS:ip_conntrack_count:GAUGE:600:0:U",
                "DS:uptime:GAUGE:600:0:U",
                "DS:mem_buffers:GAUGE:600:0:U",
                "DS:mem_cache:GAUGE:600:0:U",
                "DS:mem_app:GAUGE:600:0:U",
                "DS:mem_active:GAUGE:600:0:U",
                "DS:mem_inactive:GAUGE:600:0:U",
                "DS:swap_total:GAUGE:600:0:U",
                "DS:swap_cached:GAUGE:600:0:U",
                "DS:swaped_in:COUNTER:600:0:U",
                "DS:swaped_out:COUNTER:600:0:U",
                "DS:dirty_pages:GAUGE:600:0:U",
                "DS:eth0_in:COUNTER:600:0:12500000",
                "DS:eth0_out:COUNTER:600:0:12500000",
                "DS:eth1_in:COUNTER:600:0:12500000",
                "DS:eth1_out:COUNTER:600:0:12500000",
                "DS:eth2_in:COUNTER:600:0:12500000",
                "DS:eth2_out:COUNTER:600:0:12500000",
                "DS:eth3_in:COUNTER:600:0:12500000",
                "DS:eth3_out:COUNTER:600:0:12500000",
                "DS:sda_read:COUNTER:600:0:U",
                "DS:sda_write:COUNTER:600:0:U",
                "DS:sdb_read:COUNTER:600:0:U",
                "DS:sdb_write:COUNTER:600:0:U",
                "DS:sdc_read:COUNTER:600:0:U",
                "DS:sdc_write:COUNTER:600:0:U",
                "DS:sdd_read:COUNTER:600:0:U",
                "DS:sdd_write:COUNTER:600:0:U",
                "DS:blanko_counter_01:COUNTER:600:0:U",
                "DS:blanko_counter_02:COUNTER:600:0:U",
                "DS:blanko_counter_03:COUNTER:600:0:U",
                "DS:blanko_counter_04:COUNTER:600:0:U",
                "DS:blanko_counter_05:COUNTER:600:0:U",
                "DS:blanko_counter_06:COUNTER:600:0:U",
                "DS:blanko_counter_07:COUNTER:600:0:U",
                "DS:blanko_counter_08:COUNTER:600:0:U",
                "DS:blanko_counter_09:COUNTER:600:0:U",
                "DS:blanko_counter_10:COUNTER:600:0:U",
                "DS:blanko_gauge_01:GAUGE:600:0:U",
                "DS:blanko_gauge_02:GAUGE:600:0:U",
                "DS:blanko_gauge_03:GAUGE:600:0:U",
                "DS:blanko_gauge_04:GAUGE:600:0:U",
                "DS:blanko_gauge_05:GAUGE:600:0:U",
                "DS:blanko_gauge_06:GAUGE:600:0:U",
                "DS:blanko_gauge_07:GAUGE:600:0:U",
                "DS:blanko_gauge_08:GAUGE:600:0:U",
                "DS:blanko_gauge_09:GAUGE:600:0:U",
                "DS:blanko_gauge_10:GAUGE:600:0:U",
                "DS:blanko_derive_01:DERIVE:600:0:U",
                "DS:blanko_derive_02:DERIVE:600:0:U",
                "DS:blanko_derive_03:DERIVE:600:0:U",
                "DS:blanko_derive_04:DERIVE:600:0:U",
                "DS:blanko_derive_05:DERIVE:600:0:U",
                "DS:blanko_absolute_01:ABSOLUTE:600:0:U",
                "DS:blanko_absolute_02:ABSOLUTE:600:0:U",
                "DS:blanko_absolute_03:ABSOLUTE:600:0:U",
                "DS:blanko_absolute_04:ABSOLUTE:600:0:U",
                "DS:blanko_absolute_05:ABSOLUTE:600:0:U",
                "RRA:AVERAGE:0.5:1:576",
                "RRA:AVERAGE:0.9:6:672",
                "RRA:AVERAGE:0.9:24:744",
                "RRA:AVERAGE:0.9:288:730",
                "RRA:AVERAGE:0.9:2016:522";
        if ($ERROR = RRDs::error) { print "unable to generate database: $ERROR\n"; }
}

if (! -e "$rrd/system-procs.rrd")
{
        print "creating rrd database for system-procs...\n";
        RRDs::create "$rrd/system-procs.rrd",
                "-s 300",
                "DS:processes_active:GAUGE:600:0:U",
                "DS:processes_total:GAUGE:600:0:U",
                "RRA:AVERAGE:0.5:1:576",
                "RRA:AVERAGE:0.9:6:672",
                "RRA:AVERAGE:0.9:24:744",
                "RRA:AVERAGE:0.9:288:730",
                "RRA:AVERAGE:0.9:2016:522";
        if ($ERROR = RRDs::error) { print "unable to generate database: $ERROR\n"; }
}

_________________
gentoo user
Back to top
View user's profile Send private message
kaksi
Tux's lil' helper
Tux's lil' helper


Joined: 21 May 2004
Posts: 125

PostPosted: Tue Jun 14, 2005 1:21 pm    Post subject: Reply with quote

Anyone that can see what is wrong with my script?

I have two nics. One is eth0 and is connected to internet and one is eth1 and is connected to my internal lan. These two are brdiged as br0 (maybe that what is wrong?)

Anyway here is the script:
Code:

#!/bin/bash

#INTERFACE
INET_IFACE=eth0
WIFI_IFACE=eth1
IPTABLES=/sbin/iptables

#Flushing all tables
iptables -F INPUT
iptables -F FORWARD
iptables -F OUTPUT
iptables -t mangle -F
iptables -t mangle -F INPUT
iptables -t mangle -F FORWARD
iptables -t mangle -F OUTPUT
iptables -t mangle -F POSTROUTING

tc qdisc del dev $WIFI_IFACE root
tc qdisc del dev $INET_IFACE root

# MANGLE table

##DC
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m layer7 --l7proto directconnect -j MARK --set-mark 0x102
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p TCP --sport ! 5444:5453 --dport ! 5444:5453 -m mark --mark 0x102 -j MARK --set-mark 0x602
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p TCP -m multiport --source-port 411,412,4012 -m mark --mark 0x602 -j MARK --set-mark 0x102
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p TCP -m multiport --destination-port 411,412,4012 -m mark --mark 0x602 -j MARK --set-mark 0x102
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x602 -m limit --limit 3/minute --limit-burst 3 -j LOG --log-level DEBUG --log-prefix "directconnect (input): "
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x102 -j RETURN
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x602 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m layer7 --l7proto directconnect -j MARK --set-mark 0x202
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p TCP --sport ! 5444:5453 --dport ! 5444:5453 -m mark --mark 0x112 -j MARK --set-mark 0x702
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p TCP -m multiport --source-port 411,412,4012 -m mark --mark 0x702 -j MARK --set-mark 0x202
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p TCP -m multiport --destination-port 411,412,4012 -m mark --mark 0x702 -j MARK --set-mark 0x202
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x702 -m limit --limit 3/minute --limit-burst 3 -j LOG --log-level DEBUG --log-prefix "directconnec (output):"
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x202 -j RETURN
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x702 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m layer7 --l7proto directconnect -j MARK --set-mark 0x302
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x302 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m layer7 --l7proto directconnect -j MARK --set-mark 0x402
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x402 -j RETURN
##END DC

##FASTTRACK
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m layer7 --l7proto fasttrack -j MARK --set-mark 0x101
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x101 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m layer7 --l7proto fasttrack -j MARK --set-mark 0x201
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x201 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m layer7 --l7proto fasttrack -j MARK --set-mark 0x301
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x301 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m layer7 --l7proto fasttrack -j MARK --set-mark 0x401
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x401 -j RETURN
##END FASTTRACK

##GNUTELLA
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m layer7 --l7proto gnutella -j MARK --set-mark 0x103
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x103 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m layer7 --l7proto gnutella -j MARK --set-mark 0x203
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x203 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m layer7 --l7proto gnutella -j MARK --set-mark 0x303
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x303 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m layer7 --l7proto gnutella -j MARK --set-mark 0x403
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x403 -j RETURN
#END GNUTELLA

##BITTORRENT
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m layer7 --l7proto bittorrent -j MARK --set-mark 0x104
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x104 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m layer7 --l7proto bittorrent -j MARK --set-mark 0x204
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x204 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m layer7 --l7proto bittorrent -j MARK --set-mark 0x304
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x304 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m layer7 --l7proto bittorrent -j MARK --set-mark 0x404
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x404 -j RETURN
##END BITTORRENT

##OPENTFT
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m layer7 --l7proto openft -j MARK --set-mark 0x105
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x105 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m layer7 --l7proto openft -j MARK --set-mark 0x205
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x205 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m layer7 --l7proto openft -j MARK --set-mark 0x305
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x305 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m layer7 --l7proto openft -j MARK --set-mark 0x405
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x405 -j RETURN
#END OPENFT

##EDONKEY
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p TCP --sport 4200:4700 -m layer7 --l7proto edonkey -j MARK --set-mark 0x106
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x106 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p TCP --dport 4200:4700 -m layer7 --l7proto edonkey -j MARK --set-mark 0x206
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x206 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p TCP --sport 4200:4700 -m layer7 --l7proto edonkey -j MARK --set-mark 0x306
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x306 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p TCP --dport 4200:4700 -m layer7 --l7proto edonkey -j MARK --set-mark 0x406
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x406 -j RETURN
##END EDONKEY

##SMTP
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m layer7 --l7proto smtp -j MARK --set-mark 0x107
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x107 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m layer7 --l7proto smtp -j MARK --set-mark 0x207
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x207 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m layer7 --l7proto smtp -j MARK --set-mark 0x307
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x307 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m layer7 --l7proto smtp -j MARK --set-mark 0x407
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x407 -j RETURN
##END SMTP

##POP3
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m layer7 --l7proto pop3 -j MARK --set-mark 0x108
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x108 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m layer7 --l7proto pop3 -j MARK --set-mark 0x208
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x208 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m layer7 --l7proto pop3 -j MARK --set-mark 0x308
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x308 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m layer7 --l7proto pop3 -j MARK --set-mark 0x408
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x408 -j RETURN
##END POP3

##IMAP
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m layer7 --l7proto imap -j MARK --set-mark 0x109
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x109 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m layer7 --l7proto imap -j MARK --set-mark 0x209
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x209 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m layer7 --l7proto imap -j MARK --set-mark 0x309
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x309 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m layer7 --l7proto imap -j MARK --set-mark 0x409
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x409 -j RETURN
##END IMAP

##FTP
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m layer7 --l7proto ftp -j MARK --set-mark 0x110
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x110 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m layer7 --l7proto ftp -j MARK --set-mark 0x210
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x210 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m layer7 --l7proto ftp -j MARK --set-mark 0x310
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x310 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m layer7 --l7proto ftp -j MARK --set-mark 0x410
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x410 -j RETURN
##END FTP

##HTTP
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m layer7 --l7proto http -j MARK --set-mark 0x111
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x111 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m layer7 --l7proto http -j MARK --set-mark 0x211
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x211 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m layer7 --l7proto http -j MARK --set-mark 0x311
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x311 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m layer7 --l7proto http -j MARK --set-mark 0x411
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x411 -j RETURN
#END HTTP

##JABBER
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m layer7 --l7proto jabber -j MARK --set-mark 0x112
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x112 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m layer7 --l7proto jabber -j MARK --set-mark 0x212
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x212 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m layer7 --l7proto jabber -j MARK --set-mark 0x312
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x312 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m layer7 --l7proto jabber -j MARK --set-mark 0x412
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x412 -j RETURN
##END JABBER

##SMB
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m layer7 --l7proto smb -j MARK --set-mark 0x113
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x113 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m layer7 --l7proto smb -j MARK --set-mark 0x213
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x213 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m layer7 --l7proto smb -j MARK --set-mark 0x313
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x313 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m layer7 --l7proto smb -j MARK --set-mark 0x413
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x413 -j RETURN
##END SMB

##SSH
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m layer7 --l7proto ssh -j MARK --set-mark 0x114
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x114 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m layer7 --l7proto ssh -j MARK --set-mark 0x214
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x214 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m layer7 --l7proto ssh -j MARK --set-mark 0x314
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x314 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m layer7 --l7proto ssh -j MARK --set-mark 0x414
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x414 -j RETURN
##END SSH

##SSL
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m layer7 --l7proto validcertssl -j MARK --set-mark 0x115
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x115 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m layer7 --l7proto validcertssl -j MARK --set-mark 0x215
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x215 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m layer7 --l7proto validcertssl -j MARK --set-mark 0x315
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x315 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m layer7 --l7proto validcertssl -j MARK --set-mark 0x415
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x415 -j RETURN
##END SSL

##HLDS
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p tcp --sport 27015 -j MARK --set-mark 0x116
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p udp --sport 27015 -j MARK --set-mark 0x116
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p tcp --sport 27016 -j MARK --set-mark 0x116
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p udp --sport 27016 -j MARK --set-mark 0x116
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p tcp --sport 27005 -j MARK --set-mark 0x116
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p udp --sport 27005 -j MARK --set-mark 0x116
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p tcp --dport 27015 -j MARK --set-mark 0x116
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p udp --dport 27015 -j MARK --set-mark 0x116
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p tcp --dport 27016 -j MARK --set-mark 0x116
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p udp --dport 27016 -j MARK --set-mark 0x116
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p tcp --dport 27005 -j MARK --set-mark 0x116
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p udp --dport 27005 -j MARK --set-mark 0x116
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x116 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p tcp --sport 27015 -j MARK --set-mark 0x216
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p udp --sport 27015 -j MARK --set-mark 0x216
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p tcp --sport 27016 -j MARK --set-mark 0x216
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p udp --sport 27016 -j MARK --set-mark 0x216
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p tcp --sport 27005 -j MARK --set-mark 0x216
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p udp --sport 27005 -j MARK --set-mark 0x216
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p tcp --dport 27015 -j MARK --set-mark 0x216
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p udp --dport 27015 -j MARK --set-mark 0x216
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p tcp --dport 27016 -j MARK --set-mark 0x216
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p udp --dport 27016 -j MARK --set-mark 0x216
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p tcp --dport 27005 -j MARK --set-mark 0x216
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p udp --dport 27005 -j MARK --set-mark 0x216
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x216 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p tcp --sport 27015 -j MARK --set-mark 0x316
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p udp --sport 27015 -j MARK --set-mark 0x316
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p tcp --sport 27016 -j MARK --set-mark 0x316
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p udp --sport 27016 -j MARK --set-mark 0x316
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p tcp --sport 27005 -j MARK --set-mark 0x316
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p udp --sport 27005 -j MARK --set-mark 0x316
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p tcp --dport 27015 -j MARK --set-mark 0x316
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p udp --dport 27015 -j MARK --set-mark 0x316
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p tcp --dport 27016 -j MARK --set-mark 0x316
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p udp --dport 27016 -j MARK --set-mark 0x316
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p tcp --dport 27005 -j MARK --set-mark 0x316
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p udp --dport 27005 -j MARK --set-mark 0x316
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x316 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --sport 27015 -j MARK --set-mark 0x416
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p udp --sport 27015 -j MARK --set-mark 0x416
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --sport 27016 -j MARK --set-mark 0x416
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p udp --sport 27016 -j MARK --set-mark 0x416
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --sport 27005 -j MARK --set-mark 0x416
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p udp --sport 27005 -j MARK --set-mark 0x416
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --dport 27015 -j MARK --set-mark 0x416
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p udp --dport 27015 -j MARK --set-mark 0x416
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --dport 27016 -j MARK --set-mark 0x416
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p udp --dport 27016 -j MARK --set-mark 0x416
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --dport 27005 -j MARK --set-mark 0x416
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p udp --dport 27005 -j MARK --set-mark 0x416
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x416 -j RETURN
##END HLDS

##CCXSTREAM
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p tcp --sport 1400 -j MARK --set-mark 0x117
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p tcp --dport 1400 -j MARK --set-mark 0x117
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p udp --sport 1400 -j MARK --set-mark 0x117
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p udp --dport 1400 -j MARK --set-mark 0x117
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x117 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p tcp --sport 1400 -j MARK --set-mark 0x217
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p tcp --dport 1400 -j MARK --set-mark 0x217
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p udp --sport 1400 -j MARK --set-mark 0x217
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p udp --dport 1400 -j MARK --set-mark 0x217
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x217 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p tcp --sport 1400 -j MARK --set-mark 0x317
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p tcp --dport 1400 -j MARK --set-mark 0x317
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p udp --sport 1400 -j MARK --set-mark 0x317
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p udp --dport 1400 -j MARK --set-mark 0x317
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x317 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --sport 1400 -j MARK --set-mark 0x417
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p tcp --dport 1400 -j MARK --set-mark 0x417
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p udp --sport 1400 -j MARK --set-mark 0x417
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p udp --dport 1400 -j MARK --set-mark 0x417
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x417 -j RETURN
##END CCXSTREAM

##ICMP
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -p icmp -j MARK --set-mark 0x118
$IPTABLES -t mangle -A PREROUTING -i $WIFI_IFACE -m mark --mark 0x117 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -p icmp -j MARK --set-mark 0x218
$IPTABLES -t mangle -A POSTROUTING -o $WIFI_IFACE -m mark --mark 0x217 -j RETURN

$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -p icmp -j MARK --set-mark 0x318
$IPTABLES -t mangle -A PREROUTING -i $INET_IFACE -m mark --mark 0x317 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -p icmp -j MARK --set-mark 0x418
$IPTABLES -t mangle -A POSTROUTING -o $INET_IFACE -m mark --mark 0x417 -j RETURN
##END ICMP


#Classes
tc qdisc add dev $WIFI_IFACE root handle 1: htb default 50
tc class add dev $WIFI_IFACE parent 1: classid 1:1 htb rate 9Mbit burst 6k
tc class add dev $WIFI_IFACE parent 1:1 classid 1:10 htb rate 9Mbit burst 6k prio 1
tc class add dev $WIFI_IFACE parent 1:1 classid 1:20 htb rate  8Mbit burst 6k prio 2
tc class add dev $WIFI_IFACE parent 1:1 classid 1:30 htb rate  8Mbit burst 6k prio 3
tc class add dev $WIFI_IFACE parent 1:1 classid 1:40 htb rate  7Mbit burst 6k prio 4
tc class add dev $WIFI_IFACE parent 1:1 classid 1:50 htb rate  7Mbit burst 6k prio 5
tc class add dev $WIFI_IFACE parent 1:1 classid 1:60 htb rate  7Mbit burst 6k prio 6
tc class add dev $WIFI_IFACE parent 1:1 classid 1:70 htb rate  6Mbit burst 6k prio 7
tc class add dev $WIFI_IFACE parent 1:1 classid 1:80 htb rate  6Mbit burst 6k prio 8

tc qdisc add dev $WIFI_IFACE parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev $WIFI_IFACE parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev $WIFI_IFACE parent 1:30 handle 30: sfq perturb 10
tc qdisc add dev $WIFI_IFACE parent 1:40 handle 40: sfq perturb 10
tc qdisc add dev $WIFI_IFACE parent 1:50 handle 50: sfq perturb 10
tc qdisc add dev $WIFI_IFACE parent 1:60 handle 60: sfq perturb 10
tc qdisc add dev $WIFI_IFACE parent 1:70 handle 70: sfq perturb 10
tc qdisc add dev $WIFI_IFACE parent 1:80 handle 80: sfq perturb 10

tc qdisc add dev $INET_IFACE root handle 2: htb default 50
tc class add dev $INET_IFACE parent 2: classid 2:1 htb rate 90Mbit burst 6k
tc class add dev $INET_IFACE parent 2:1 classid 2:10 htb rate 90Mbit burst 6k prio 1
tc class add dev $INET_IFACE parent 2:1 classid 2:20 htb rate  90Mbit burst 6k prio 2
tc class add dev $INET_IFACE parent 2:1 classid 2:30 htb rate  90Mbit burst 6k prio 3
tc class add dev $INET_IFACE parent 2:1 classid 2:40 htb rate  90Mbit burst 6k prio 4
tc class add dev $INET_IFACE parent 2:1 classid 2:50 htb rate  90Mbit burst 6k prio 5
tc class add dev $INET_IFACE parent 2:1 classid 2:60 htb rate  90Mbit burst 6k prio 6
tc class add dev $INET_IFACE parent 2:1 classid 2:70 htb rate  90Mbit burst 6k prio 7
tc class add dev $INET_IFACE parent 2:1 classid 2:80 htb rate  90Mbit burst 6k prio 8

tc qdisc add dev $INET_IFACE parent 2:10 handle 10: sfq perturb 10
tc qdisc add dev $INET_IFACE parent 2:20 handle 20: sfq perturb 10
tc qdisc add dev $INET_IFACE parent 2:30 handle 30: sfq perturb 10
tc qdisc add dev $INET_IFACE parent 2:40 handle 40: sfq perturb 10
tc qdisc add dev $INET_IFACE parent 2:50 handle 50: sfq perturb 10
tc qdisc add dev $INET_IFACE parent 2:60 handle 60: sfq perturb 10
tc qdisc add dev $INET_IFACE parent 2:70 handle 70: sfq perturb 10
tc qdisc add dev $INET_IFACE parent 2:80 handle 80: sfq perturb 10


##Classifying network stream

#HLDS
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x116 fw classid 1:10
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x216 fw classid 1:10
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x316 fw classid 2:10
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x416 fw classid 2:10
###END HLDS

#ICMP
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x118 fw classid 1:20
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x218 fw classid 1:20
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x318 fw classid 2:20
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x418 fw classid 2:20
##END ICMP

#MAIL - 107 108 109
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x107 fw classid 1:30
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x207 fw classid 1:30
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x307 fw classid 2:30
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x407 fw classid 2:30

tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x108 fw classid 1:30
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x208 fw classid 1:30
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x308 fw classid 2:30
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x408 fw classid 2:30

tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x109 fw classid 1:30
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x209 fw classid 1:30
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x309 fw classid 2:30
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x409 fw classid 2:30
##END MAIL

##SSH
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x114 fw classid 1:40
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x214 fw classid 1:40
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x314 fw classid 2:40
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x414 fw classid 2:40
##END SSH

##FTP, HTTP, SSL
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x115 fw classid 1:60
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x215 fw classid 1:60
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x315 fw classid 2:60
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x415 fw classid 2:60

tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x111 fw classid 1:60
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x211 fw classid 1:60
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x311 fw classid 2:60
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x411 fw classid 2:60

tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x110 fw classid 1:60
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x210 fw classid 1:60
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x310 fw classid 2:60
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x410 fw classid 2:60
##END FTP, HTTP, SSL

##SAMBA, CCXSTREAM
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x117 fw classid 1:70
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x217 fw classid 1:70
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x317 fw classid 2:70
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x417 fw classid 2:70

tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x113 fw classid 1:70
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x213 fw classid 1:70
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x313 fw classid 2:70
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x413 fw classid 2:70
##END SAMBA, CCXSTREAM

##P2P
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x102 fw classid 1:80
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x202 fw classid 1:80
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x302 fw classid 2:80
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x402 fw classid 2:80

tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x101 fw classid 1:80
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x201 fw classid 1:80
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x301 fw classid 2:80
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x401 fw classid 2:80

tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x103 fw classid 1:80
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x203 fw classid 1:80
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x303 fw classid 2:80
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x403 fw classid 2:80

tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x104 fw classid 1:80
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x204 fw classid 1:80
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x304 fw classid 2:80
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x404 fw classid 2:80

tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x105 fw classid 1:80
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x205 fw classid 1:80
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x305 fw classid 2:80
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x405 fw classid 2:80

tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x106 fw classid 1:80
tc filter add dev $WIFI_IFACE parent 1:0 protocol ip handle 0x206 fw classid 1:80
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x306 fw classid 2:80
tc filter add dev $INET_IFACE parent 2:0 protocol ip handle 0x406 fw classid 2:80
##END P2P


All traffic gets assigned to the default class 1:50 and 2:50
Here is the output of iptables -t mangle -L -n -v -x:

Code:
Chain PREROUTING (policy ACCEPT 33534569 packets, 5086715259 bytes)
    pkts      bytes target     prot opt in     out     source               destination
       0        0 MARK       all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto directconnect MARK set 0x102
       0        0 MARK       tcp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           tcp spts:!5444:5453 dpts:!5444:5453 MARK match 0x102 MARK set 0x602
       0        0 MARK       tcp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           multiport sports 411,412,4012 MARK match 0x602 MARK set 0x102
       0        0 MARK       tcp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           multiport dports 411,412,4012 MARK match 0x602 MARK set 0x102
       0        0 LOG        all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x602 limit: avg 3/min burst 3 LOG flags 0 level 7 prefix `directconnect (input): '
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x102
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x602
       0        0 MARK       all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto directconnect MARK set 0x302
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x302
       0        0 MARK       all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto fasttrack MARK set 0x101
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x101
       0        0 MARK       all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto fasttrack MARK set 0x301
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x301
       0        0 MARK       all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto gnutella MARK set 0x103
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x103
       0        0 MARK       all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto gnutella MARK set 0x303
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x303
       0        0 MARK       all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto bittorrent MARK set 0x104
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x104
       0        0 MARK       all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto bittorrent MARK set 0x304
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x304
       0        0 MARK       all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto openft MARK set 0x105
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x105
       0        0 MARK       all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto openft MARK set 0x305
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x305
       0        0 MARK       tcp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           tcp spts:4200:4700 LAYER7 l7proto edonkey MARK set 0x106
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x106
       0        0 MARK       tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           tcp spts:4200:4700 LAYER7 l7proto edonkey MARK set 0x306
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x306
       0        0 MARK       all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto smtp MARK set 0x107
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x107
       0        0 MARK       all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto smtp MARK set 0x307
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x307
       0        0 MARK       all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto pop3 MARK set 0x108
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x108
       0        0 MARK       all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto pop3 MARK set 0x308
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x308
       0        0 MARK       all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto imap MARK set 0x109
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x109
       0        0 MARK       all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto imap MARK set 0x309
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x309
       0        0 MARK       all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto ftp MARK set 0x110
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x110
       0        0 MARK       all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto ftp MARK set 0x310
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x310
       0        0 MARK       all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto http MARK set 0x111
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x111
       0        0 MARK       all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto http MARK set 0x311
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x311
       0        0 MARK       all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto jabber MARK set 0x112
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x112
       0        0 MARK       all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto jabber MARK set 0x312
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x312
       0        0 MARK       all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto smb MARK set 0x113
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x113
       0        0 MARK       all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto smb MARK set 0x313
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x313
       0        0 MARK       all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto ssh MARK set 0x114
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x114
       0        0 MARK       all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto ssh MARK set 0x314
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x314
       0        0 MARK       all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto validcertssl MARK set 0x115
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x115
       0        0 MARK       all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto validcertssl MARK set 0x315
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x315
       0        0 MARK       tcp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           tcp spt:27015 MARK set 0x116
       0        0 MARK       udp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           udp spt:27015 MARK set 0x116
       0        0 MARK       tcp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           tcp spt:27016 MARK set 0x116
       0        0 MARK       udp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           udp spt:27016 MARK set 0x116
       0        0 MARK       tcp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           tcp spt:27005 MARK set 0x116
       0        0 MARK       udp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           udp spt:27005 MARK set 0x116
       0        0 MARK       tcp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           tcp dpt:27015 MARK set 0x116
       0        0 MARK       udp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           udp dpt:27015 MARK set 0x116
       0        0 MARK       tcp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           tcp dpt:27016 MARK set 0x116
       0        0 MARK       udp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           udp dpt:27016 MARK set 0x116
       0        0 MARK       tcp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           tcp dpt:27005 MARK set 0x116
       0        0 MARK       udp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           udp dpt:27005 MARK set 0x116
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x116
       0        0 MARK       tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           tcp spt:27015 MARK set 0x316
       0        0 MARK       udp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           udp spt:27015 MARK set 0x316
       0        0 MARK       tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           tcp spt:27016 MARK set 0x316
       0        0 MARK       udp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           udp spt:27016 MARK set 0x316
       0        0 MARK       tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           tcp spt:27005 MARK set 0x316
       0        0 MARK       udp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           udp spt:27005 MARK set 0x316
       0        0 MARK       tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           tcp dpt:27015 MARK set 0x316
       0        0 MARK       udp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           udp dpt:27015 MARK set 0x316
       0        0 MARK       tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           tcp dpt:27016 MARK set 0x316
       0        0 MARK       udp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           udp dpt:27016 MARK set 0x316
       0        0 MARK       tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           tcp dpt:27005 MARK set 0x316
       0        0 MARK       udp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           udp dpt:27005 MARK set 0x316
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x316
       0        0 MARK       tcp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           tcp spt:1400 MARK set 0x117
       0        0 MARK       tcp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           tcp dpt:1400 MARK set 0x117
       0        0 MARK       udp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           udp spt:1400 MARK set 0x117
       0        0 MARK       udp  --  eth1   *       0.0.0.0/0            0.0.0.0/0           udp dpt:1400 MARK set 0x117
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x117
       0        0 MARK       tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           tcp spt:1400 MARK set 0x317
       0        0 MARK       tcp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           tcp dpt:1400 MARK set 0x317
       0        0 MARK       udp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           udp spt:1400 MARK set 0x317
       0        0 MARK       udp  --  eth0   *       0.0.0.0/0            0.0.0.0/0           udp dpt:1400 MARK set 0x317
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x317
       0        0 MARK       icmp --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK set 0x118
       0        0 RETURN     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x117
       0        0 MARK       icmp --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK set 0x318
       0        0 RETURN     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           MARK match 0x317

Chain INPUT (policy ACCEPT 10147124 packets, 2972921848 bytes)
    pkts      bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 23388743 packets, 2113852735 bytes)
    pkts      bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 13387965 packets, 16432385100 bytes)
    pkts      bytes target     prot opt in     out     source               destination

Chain POSTROUTING (policy ACCEPT 36775756 packets, 18546110076 bytes)
    pkts      bytes target     prot opt in     out     source               destination
       0        0 MARK       all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto directconnect MARK set 0x202
       0        0 MARK       tcp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           tcp spts:!5444:5453 dpts:!5444:5453 MARK match 0x112 MARK set 0x702
       0        0 MARK       tcp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           multiport sports 411,412,4012 MARK match 0x702 MARK set 0x202
       0        0 MARK       tcp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           multiport dports 411,412,4012 MARK match 0x702 MARK set 0x202
       0        0 LOG        all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x702 limit: avg 3/min burst 3 LOG flags 0 level 7 prefix `directconnec (output):'
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x202
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x702
       0        0 MARK       all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto directconnect MARK set 0x402
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x402
       0        0 MARK       all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto fasttrack MARK set 0x201
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x201
       0        0 MARK       all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto fasttrack MARK set 0x401
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x401
       0        0 MARK       all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto gnutella MARK set 0x203
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x203
       0        0 MARK       all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto gnutella MARK set 0x403
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x403
       0        0 MARK       all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto bittorrent MARK set 0x204
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x204
       0        0 MARK       all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto bittorrent MARK set 0x404
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x404
       0        0 MARK       all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto openft MARK set 0x205
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x205
       0        0 MARK       all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto openft MARK set 0x405
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x405
       0        0 MARK       tcp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           tcp dpts:4200:4700 LAYER7 l7proto edonkey MARK set 0x206
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x206
       0        0 MARK       tcp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           tcp dpts:4200:4700 LAYER7 l7proto edonkey MARK set 0x406
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x406
       0        0 MARK       all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto smtp MARK set 0x207
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x207
       0        0 MARK       all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto smtp MARK set 0x407
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x407
       0        0 MARK       all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto pop3 MARK set 0x208
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x208
       0        0 MARK       all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto pop3 MARK set 0x408
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x408
       0        0 MARK       all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto imap MARK set 0x209

       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x209
       0        0 MARK       all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto imap MARK set 0x409
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x409
       0        0 MARK       all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto ftp MARK set 0x210
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x210
       0        0 MARK       all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto ftp MARK set 0x410
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x410
       0        0 MARK       all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto http MARK set 0x211
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x211
       0        0 MARK       all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto http MARK set 0x411
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x411
       0        0 MARK       all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto jabber MARK set 0x212
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x212
       0        0 MARK       all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto jabber MARK set 0x412
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x412
       0        0 MARK       all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto smb MARK set 0x213
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x213
       0        0 MARK       all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto smb MARK set 0x413
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x413
       0        0 MARK       all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto ssh MARK set 0x214
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x214
       0        0 MARK       all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto ssh MARK set 0x414
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x414
       0        0 MARK       all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto validcertssl MARK set 0x215
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x215
       0        0 MARK       all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto validcertssl MARK set 0x415
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x415
       0        0 MARK       tcp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           tcp spt:27015 MARK set 0x216
       0        0 MARK       udp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           udp spt:27015 MARK set 0x216
       0        0 MARK       tcp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           tcp spt:27016 MARK set 0x216
       0        0 MARK       udp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           udp spt:27016 MARK set 0x216
       0        0 MARK       tcp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           tcp spt:27005 MARK set 0x216
       0        0 MARK       udp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           udp spt:27005 MARK set 0x216
       0        0 MARK       tcp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           tcp dpt:27015 MARK set 0x216
       0        0 MARK       udp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           udp dpt:27015 MARK set 0x216
       0        0 MARK       tcp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           tcp dpt:27016 MARK set 0x216
       0        0 MARK       udp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           udp dpt:27016 MARK set 0x216
       0        0 MARK       tcp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           tcp dpt:27005 MARK set 0x216
       0        0 MARK       udp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           udp dpt:27005 MARK set 0x216
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x216
       0        0 MARK       tcp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           tcp spt:27015 MARK set 0x416
       0        0 MARK       udp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           udp spt:27015 MARK set 0x416
       0        0 MARK       tcp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           tcp spt:27016 MARK set 0x416
       0        0 MARK       udp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           udp spt:27016 MARK set 0x416
       0        0 MARK       tcp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           tcp spt:27005 MARK set 0x416
       0        0 MARK       udp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           udp spt:27005 MARK set 0x416
       0        0 MARK       tcp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           tcp dpt:27015 MARK set 0x416
       0        0 MARK       udp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           udp dpt:27015 MARK set 0x416
       0        0 MARK       tcp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           tcp dpt:27016 MARK set 0x416
       0        0 MARK       udp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           udp dpt:27016 MARK set 0x416
       0        0 MARK       tcp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           tcp dpt:27005 MARK set 0x416
       0        0 MARK       udp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           udp dpt:27005 MARK set 0x416
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x416
       0        0 MARK       tcp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           tcp spt:1400 MARK set 0x217
       0        0 MARK       tcp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           tcp dpt:1400 MARK set 0x217
       0        0 MARK       udp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           udp spt:1400 MARK set 0x217
       0        0 MARK       udp  --  *      eth1    0.0.0.0/0            0.0.0.0/0           udp dpt:1400 MARK set 0x217
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x217
       0        0 MARK       tcp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           tcp spt:1400 MARK set 0x417
       0        0 MARK       tcp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           tcp dpt:1400 MARK set 0x417
       0        0 MARK       udp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           udp spt:1400 MARK set 0x417
       0        0 MARK       udp  --  *      eth0    0.0.0.0/0            0.0.0.0/0           udp dpt:1400 MARK set 0x417
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x417
       0        0 MARK       icmp --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK set 0x218
       0        0 RETURN     all  --  *      eth1    0.0.0.0/0            0.0.0.0/0           MARK match 0x217
       0        0 MARK       icmp --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK set 0x418
       0        0 RETURN     all  --  *      eth0    0.0.0.0/0            0.0.0.0/0           MARK match 0x417


I'm not sure exactly what this output says but I guess it lists the rules set (which seem fine) and the traffic at each rule. This is the problem it is 0.

Here is an output of the tc traffic:
[code]
15:19:58 up 1 day, 4:36, 2 users, load average: 0.00, 0.00, 0.00
Interval Cumulated Total
Dev Classid Tokens Ctokens Rate Speed Send Send
-------------------------------------------------------------------------
eth1 1:1 4267 1155 204.45KB 23.10KB/s 618.18KB 204.34MB
eth1 1:10 5592 2480 0B 0B/s 0B 0B
eth1 1:20 6291 2662 0B 0B/s 0B 0B
eth1 1:30 6291 2662 0B 0B/s 0B 0B
eth1 1:40 7189 2895 0B 0B/s 0B 0B
eth1 1:50 5486 1192 197.30KB 23.10KB/s 618.18KB 204.34MB
eth1 1:60 7189 2895 0B 0B/s 0B 0B
eth1 1:70 8388 3208 0B 0B/s 0B 0B
eth1 1:80 8388 3208 0B 0B/s 0B 0B
eth0 2:1 555 1165 8.48KB 675B/s 24.61KB 29.99MB
eth0 2:10 559 1169 0B 0B/s 0B 0B
eth0 2:20 559 1169 0B 0B/s 0B 0B
eth0 2:30 559 1169 0B 0B/s 0B 0B
eth0 2:40 559 1169 0B 0B/s 0B 0B
eth0 2:50 555 1165 8.49KB 675B/s 24.61KB 29.99MB
eth0 2:60 559 1169 0B 0B/s 0B 0B
eth0 2:70 559 1169 0B 0B/s 0B 0B
eth0 2:80 559 1169 0B 0B/s 0B 0B
[code]

This is when I'm streaming music to my xbox via my ccxstream server on the same machine that has the rules...

Anyone that can see the problem?
Back to top
View user's profile Send private message
kaksi
Tux's lil' helper
Tux's lil' helper


Joined: 21 May 2004
Posts: 125

PostPosted: Tue Jun 14, 2005 2:16 pm    Post subject: Reply with quote

It seem like the bridge is the problem. Cause when I set the interface to be br0 on the iptables parts it works... Hmmm so iptables can not see of the package belongs to eth1 or eth0 when they are bridges as br0 but tc can...
Back to top
View user's profile Send private message
kaksi
Tux's lil' helper
Tux's lil' helper


Joined: 21 May 2004
Posts: 125

PostPosted: Tue Jun 14, 2005 3:53 pm    Post subject: Reply with quote

I seem to have problem with l7-filter. I have emerged l7-filter and l7-protocol and iptables with l7-support.

But I still can not get any result from it. I have this code to mark ssh packages:

Code:

$IPTABLES -t mangle -A PREROUTING -m layer7 --l7proto ssh -j MARK --set-mark 0x114
$IPTABLES -t mangle -A PREROUTING -m mark --mark 0x114 -j RETURN

$IPTABLES -t mangle -A INPUT -m layer7 --l7proto ssh -j MARK --set-mark 0x114
$IPTABLES -t mangle -A INPUT -m mark --mark 0x114 -j RETURN

$IPTABLES -t mangle -A OUTPUT -m layer7 --l7proto ssh -j MARK --set-mark 0x114
$IPTABLES -t mangle -A OUTPUT -m mark --mark 0x114 -j RETURN

$IPTABLES -t mangle -A FORWARD -m layer7 --l7proto ssh -j MARK --set-mark 0x114
$IPTABLES -t mangle -A FORWARD -m mark --mark 0x114 -j RETURN

$IPTABLES -t mangle -A POSTROUTING -m layer7 --l7proto ssh -j MARK --set-mark 0x214
$IPTABLES -t mangle -A POSTROUTING -m mark --mark 0x214 -j RETURN


This should mark ssh packages whatever they come from... But the output of iptables:
Code:

iptables -t mangle -L -n -v -x | grep ssh
       0        0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto ssh MARK set 0x114
       0        0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto ssh MARK set 0x114
       0        0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto ssh MARK set 0x114
       0        0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto ssh MARK set 0x114
       0        0 MARK       all  --  *      *       0.0.0.0/0            0.0.0.0/0           LAYER7 l7proto ssh MARK set 0x214


What could be the problem?
Back to top
View user's profile Send private message
ranmakun
Guru
Guru


Joined: 06 Nov 2002
Posts: 372
Location: Buenos Aires - Argentina

PostPosted: Tue Jun 14, 2005 10:50 pm    Post subject: Reply with quote

tnt wrote:

I hope you'll find your way in all this mess. :D
If you get stucked, do not hesitate to ask!


Aha!!, so you were keeping the best part just for yourself, you greedy bastard!! :wink:
This is great, I don't have the time to see it right now, but it will be very useful, thank you very much!
Back to top
View user's profile Send private message
tnt
Veteran
Veteran


Joined: 27 Feb 2004
Posts: 1222

PostPosted: Tue Jun 14, 2005 11:24 pm    Post subject: Reply with quote

You're all welcome! ;)
_________________
gentoo user
Back to top
View user's profile Send private message
kaksi
Tux's lil' helper
Tux's lil' helper


Joined: 21 May 2004
Posts: 125

PostPosted: Wed Jun 15, 2005 8:53 pm    Post subject: Reply with quote

tnt: Can you post the scripts that generate the graphs aswell?
Back to top
View user's profile Send private message
tnt
Veteran
Veteran


Joined: 27 Feb 2004
Posts: 1222

PostPosted: Wed Jun 15, 2005 9:04 pm    Post subject: Reply with quote

It's little bit messed up, and too long for one post:

Code:
#!/usr/bin/perl
#

use RRDs;

# define location of rrdtool databases
my $rrd = '/var/lib/rrd';
# define location of images
my $img = '/var/www/localhost/htdocs/monitor/graphs';

my $hight = '200';
my $big = '240';
my $width = '1000';
my $s_hight = '150';
my $s_big = '180';
my $s_width = '500';

&CreateGraph1("system-5min", "day", "Temperatures on Titan");
&CreateGraph1("system-5min", "week", "Temperatures on Titan");
&CreateGraph1("system-5min", "month", "Temperatures on Titan");
&CreateGraph1("system-5min", "year", "Temperatures on Titan");
&CreateGraph1("system-5min", "0years", "Temperatures on Titan");

sub CreateGraph1
{
        RRDs::graph "$img/system.temperatures-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $hight, "-w", $width,
#                "-l 0",
                "-Y",
                "-M",
                "-a", "PNG",
                "-v Celcius",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:systemp=$rrd/$_[0].rrd:temp_sys:AVERAGE",
                "DEF:cputemp=$rrd/$_[0].rrd:temp_cpu:AVERAGE",
                "CDEF:systemp_over=systemp,UN,UNKN,systemp,42,GT,systemp,systemp,2,-,20,200,LIMIT,IF,IF",
                "CDEF:cputemp_over=cputemp,UN,UNKN,cputemp,35,GT,cputemp,cputemp,2,-,20,200,LIMIT,IF,IF",
                "CDEF:systemp_good=systemp,UN,UNKN,systemp,42,GT,42,systemp,IF,IF",
                "CDEF:cputemp_good=cputemp,UN,UNKN,cputemp,35,GT,35,cputemp,IF,IF",
                "AREA:systemp_over#397563",
                "LINE1:systemp_over#3CB18E",
                "AREA:systemp_good#346370:System",
                "LINE1:systemp_good#22AAD1",
                "GPRINT:systemp:MAX:  Max\\: %5.1lf %s",
                "GPRINT:systemp:AVERAGE: Avg\\: %5.1lf %S",
                "GPRINT:systemp:LAST: Current\\: %5.1lf %S\Celsius\\n",
                "AREA:cputemp_over#A7343B",
                "LINE1:cputemp_over#EC4954",
                "AREA:cputemp_good#7C5B57:CPU   ",
                "LINE1:cputemp_good#CC958F",
                "GPRINT:cputemp:MAX:  Max\\: %5.1lf %S",
                "GPRINT:cputemp:AVERAGE: Avg\\: %5.1lf %S",
                "GPRINT:cputemp:LAST: Current\\: %5.1lf %SCelsius",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph2("system-5min", "day", "Disk temperatures on Titan");
&CreateGraph2("system-5min", "week", "Disk temperatures on Titan");
&CreateGraph2("system-5min", "month", "Disk temperatures on Titan");
&CreateGraph2("system-5min", "year", "Disk temperatures on Titan");
&CreateGraph2("system-5min", "0years", "Disk temperatures on Titan");

sub CreateGraph2
{
        RRDs::graph "$img/system.disk-temps-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_hight, "-w", $s_width,
#                "-l 0",
                "-Y",
                "-M",
                "-a", "PNG",
                "-v Celcius",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:sda=$rrd/$_[0].rrd:temp_sda:AVERAGE",
                "DEF:sdb=$rrd/$_[0].rrd:temp_sdb:AVERAGE",
                "DEF:sdc=$rrd/$_[0].rrd:temp_sdc:AVERAGE",
                "DEF:sdd=$rrd/$_[0].rrd:temp_sdd:AVERAGE",
                "LINE2:sda#3CB18E:sda",
                "LINE1:sda#397563",
                "GPRINT:sda:MAX:  Max\\: %5.1lf",
                "GPRINT:sda:AVERAGE: Avg\\: %5.1lf",
                "GPRINT:sda:LAST: Current\\: %5.1lf Celsius\\n",
                "LINE2:sdb#22AAD1:sdb",
                "LINE1:sdb#346370",
                "GPRINT:sdb:MAX:  Max\\: %5.1lf",
                "GPRINT:sdb:AVERAGE: Avg\\: %5.1lf",
                "GPRINT:sdb:LAST: Current\\: %5.1lf Celsius\\n",
                "LINE2:sdc#CC958F:sdc",
                "LINE1:sdc#7C5B57",
                "GPRINT:sdc:MAX:  Max\\: %5.1lf",
                "GPRINT:sdc:AVERAGE: Avg\\: %5.1lf",
                "GPRINT:sdc:LAST: Current\\: %5.1lf Celsius\\n",
                "LINE2:sdd#A97EB0:sdd",
                "LINE1:sdd#715A6F",
                "GPRINT:sdd:MAX:  Max\\: %5.1lf",
                "GPRINT:sdd:AVERAGE: Avg\\: %5.1lf",
                "GPRINT:sdd:LAST: Current\\: %5.1lf Celsius",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph3("system-5min", "day", "Memory usage on Titan");
&CreateGraph3("system-5min", "week", "Memory usage on Titan");
&CreateGraph3("system-5min", "month", "Memory usage on Titan");
&CreateGraph3("system-5min", "year", "Memory usage on Titan");
&CreateGraph3("system-5min", "0years", "Memory usage on Titan");

sub CreateGraph3
{
        RRDs::graph "$img/system.mem-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy",
                "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $hight, "-w", $width,
                "-l 0",
                "-Y",
#               "-M",
                "-a", "PNG",
                "-b 1024",
                "-v Bytes",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:mem_app=$rrd/$_[0].rrd:mem_app:AVERAGE",
                "DEF:mem_buffers=$rrd/$_[0].rrd:mem_buffers:AVERAGE",
                "DEF:mem_cache=$rrd/$_[0].rrd:mem_cache:AVERAGE",
                "DEF:mem_active=$rrd/system-temp.rrd:mem_active:AVERAGE",
                "DEF:mem_inactive=$rrd/system-temp.rrd:mem_inactive:AVERAGE",
                "CDEF:app=mem_app,1024,*",
                "CDEF:buffers=mem_buffers,1024,*",
                "CDEF:cache=mem_cache,1024,*",
                "CDEF:buffstack=app,buffers,+",
                "CDEF:total=app,buffers,+,cache,+",
                "CDEF:active=mem_active,1024,*",
                "CDEF:inactive=mem_inactive,1024,*",
                "AREA:total#346370:Cache      ",
                "GPRINT:cache:MAX:  Max\\: %5.1lf %s",
                "GPRINT:cache:AVERAGE: Avg\\: %5.1lf %S",
                "GPRINT:cache:LAST: Current\\: %5.1lf %SB\\n",
                "AREA:buffstack#397563:Buffers    ",
                "LINE1:buffstack#3CB18E",
                "GPRINT:buffers:MAX:  Max\\: %5.1lf %s",
                "GPRINT:buffers:AVERAGE: Avg\\: %5.1lf %S",
                "GPRINT:buffers:LAST: Current\\: %5.1lf %SB\\n",
                "AREA:app#7C5B57:Application",
                "LINE1:app#CC958F",
                "GPRINT:app:MAX:  Max\\: %5.1lf %s",
                "GPRINT:app:AVERAGE: Avg\\: %5.1lf %S",
                "GPRINT:app:LAST: Current\\: %5.1lf %SB\\n",
                "LINE1:total#22AAD1:Total      ",
                "GPRINT:total:MAX:  Max\\: %5.1lf %S",
                "GPRINT:total:AVERAGE: Avg\\: %5.1lf %S",
                "GPRINT:total:LAST: Current\\: %5.1lf %SB",
#                "AREA:active#FF000011:Active     ",
#                "GPRINT:active:MAX:  Max\\: %5.1lf %s",
#                "GPRINT:active:AVERAGE: Avg\\: %5.1lf %S",
#                "GPRINT:active:LAST: Current\\: %5.1lf %SB\\n",
#                "STACK:inactive#00FF0011:Inactive   ",
#                "GPRINT:inactive:MAX:  Max\\: %5.1lf %s",
#                "GPRINT:inactive:AVERAGE: Avg\\: %5.1lf %S",
#                "GPRINT:inactive:LAST: Current\\: %5.1lf %SB",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph4("system-5min", "day", "Swap usage on Titan");
&CreateGraph4("system-5min", "week", "Swap usage on Titan");
&CreateGraph4("system-5min", "month", "Swap usage on Titan");
&CreateGraph4("system-5min", "year", "Swap usage on Titan");
&CreateGraph4("system-5min", "0years", "Swap usage on Titan");

sub CreateGraph4
{
        RRDs::graph "$img/system.swap-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $hight, "-w", $width,
                "-l 0", "-b 1024",
                "-Y", "-M",
                "-a", "PNG",
                "-v Bytes",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:swap_cached=$rrd/$_[0].rrd:swap_cached:AVERAGE",
                "DEF:swap_total=$rrd/$_[0].rrd:swap_total:AVERAGE",
                "CDEF:cached=swap_cached,1024,*",
                "CDEF:total=swap_total,1024,*",
                "AREA:total#346370:Total ",
                "LINE1:total#22AAD1",
                "GPRINT:total:MAX:  Max\\: %5.1lf %S",
                "GPRINT:total:AVERAGE: Avg\\: %5.1lf %S",
                "GPRINT:total:LAST: Current\\: %5.1lf %SB\\n",
                "AREA:cached#397563:Cached",
                "LINE1:cached#3CB18E",
                "GPRINT:cached:MAX:  Max\\: %5.1lf %s",
                "GPRINT:cached:AVERAGE: Avg\\: %5.1lf %S",
                "GPRINT:cached:LAST: Current\\: %5.1lf %SB",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph5("system-5min", "day", "CPU usage on Titan");
&CreateGraph5("system-5min", "week", "CPU usage on Titan");
&CreateGraph5("system-5min", "month", "CPU usage on Titan");
&CreateGraph5("system-5min", "year", "CPU usage on Titan");
&CreateGraph5("system-5min", "0years", "CPU usage on Titan");

sub CreateGraph5
{
        RRDs::graph "$img/system.cpu0-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy",
                "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $hight, "-w", $width,
                "-l 0",
#                "-Y",
#               "-M",
#               "-u 100",
                "-r",
                "-a", "PNG",
                "-v %",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:user=$rrd/$_[0].rrd:cpu0_user:AVERAGE",
                "DEF:nice=$rrd/$_[0].rrd:cpu0_nice:AVERAGE",
                "DEF:system=$rrd/$_[0].rrd:cpu0_system:AVERAGE",
                "DEF:iowait=$rrd/$_[0].rrd:cpu0_iowait:AVERAGE",
                "DEF:irq=$rrd/$_[0].rrd:cpu0_irq:AVERAGE",
                "DEF:softirq=$rrd/$_[0].rrd:cpu0_softirq:AVERAGE",
                "CDEF:softirq_stack=softirq,irq,+",
                "CDEF:iowait_stack=softirq_stack,iowait,+",
                "CDEF:nice_stack=iowait_stack,nice,+",
                "CDEF:user_stack=nice_stack,user,+",
                "CDEF:system_stack=user_stack,system,+,100,MIN",
                "CDEF:total=system_stack",

                "AREA:system_stack#A7343B:system ",
                "LINE1:total#CA3F48",
                "GPRINT:system:MAX:  Max\\: %5.1lf",
                "GPRINT:system:AVERAGE: Avg\\: %5.1lf",
                "GPRINT:system:LAST: Current\\: %5.1lf %%\\n",
                "AREA:user_stack#7C5B57:user   ",
                "LINE1:user_stack#CC958f",
                "GPRINT:user:MAX:  Max\\: %5.1lf",
                "GPRINT:user:AVERAGE: Avg\\: %5.1lf",
                "GPRINT:user:LAST: Current\\: %5.1lf %%\\n",
                "AREA:nice_stack#346370:nice   ",
                "LINE1:nice_stack#22AAD1",
                "GPRINT:nice:MAX:  Max\\: %5.1lf",
                "GPRINT:nice:AVERAGE: Avg\\: %5.1lf",
                "GPRINT:nice:LAST: Current\\: %5.1lf %%\\n",
                "AREA:iowait_stack#397563:iowait ",
                "LINE1:iowait_stack#3CB18E",
                "GPRINT:iowait:MAX:  Max\\: %5.1lf",
                "GPRINT:iowait:AVERAGE: Avg\\: %5.1lf",
                "GPRINT:iowait:LAST: Current\\: %5.1lf %%\\n",
                "AREA:softirq_stack#5E7149:softirq",
                "LINE1:softirq_stack#71A43B",
                "GPRINT:softirq:MAX:  Max\\: %5.1lf",
                "GPRINT:softirq:AVERAGE: Avg\\: %5.1lf",
                "GPRINT:softirq:LAST: Current\\: %5.1lf %%\\n",
                "AREA:irq#756339:irq    ",
                "LINE1:irq#B18E3C",
                "GPRINT:irq:MAX:  Max\\: %5.1lf",
                "GPRINT:irq:AVERAGE: Avg\\: %5.1lf",
                "GPRINT:irq:LAST: Current\\: %5.1lf %%\\n",
                "HRULE:0#888888:total  ",
#                "LINE1:total#CA3F48:total  ",
                "GPRINT:total:MAX:  Max\\: %5.1lf",
                "GPRINT:total:AVERAGE: Avg\\: %5.1lf",
                "GPRINT:total:LAST: Current\\: %5.1lf %%";

        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph6("system-5min", "day", "Swaped memory on Titan");
&CreateGraph6("system-5min", "week", "Swaped memory on Titan");
&CreateGraph6("system-5min", "month", "Swaped memory on Titan");
&CreateGraph6("system-5min", "year", "Swaped memory on Titan");
&CreateGraph6("system-5min", "0years", "Swaped memory on Titan");

sub CreateGraph6
{
        RRDs::graph "$img/system.swaped-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_big, "-w", $s_width,
                "-l 0",
                "-Y",
                "-M",
                "-a", "PNG",
                "-b 1024",
                "-v Bytes per second",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:swaped_in=$rrd/$_[0].rrd:swaped_in:AVERAGE",
                "DEF:swaped_out=$rrd/$_[0].rrd:swaped_out:AVERAGE",
                "CDEF:sin=swaped_in,4096,*",
                "CDEF:sout=swaped_out,-4096,*",
                "CDEF:sout_print=swaped_out,4096,*",
                "AREA:sin#7C5B57:swaped in ",
                "LINE1:sin#CC958F",
                "GPRINT:sin:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:sin:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:sin:LAST: Current\\: %5.1lf %sB/s\\n",
                "AREA:sout#346370:swaped out",
                "LINE1:sout#22AAD1",
                "GPRINT:sout_print:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:sout_print:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:sout_print:LAST: Current\\: %5.1lf %sB/s",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph7("system-5min", "day", "eth0 (LAN) usage on Titan");
&CreateGraph7("system-5min", "week", "eth0 (LAN) usage on Titan");
&CreateGraph7("system-5min", "month", "eth0 (LAN) usage on Titan");
&CreateGraph7("system-5min", "year", "eth0 (LAN) usage on Titan");
&CreateGraph7("system-5min", "0years", "eth0 (LAN) usage on Titan");

sub CreateGraph7
{
        RRDs::graph "$img/system.eth0-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $big, "-w", $width,
                "-l 0",
#               "-Y",
                "-M",
                "-a", "PNG",
                "-v Bytes per second",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:eth0_in=$rrd/$_[0].rrd:eth0_in:AVERAGE",
                "DEF:eth0_out=$rrd/$_[0].rrd:eth0_out:AVERAGE",
                "CDEF:eth0_out_n=eth0_out,-1,*",
                "AREA:eth0_in#7C5B57:eth0 in ",
                "LINE1:eth0_in#CC958F",
                "GPRINT:eth0_in:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth0_in:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth0_in:LAST: Current\\: %5.1lf %sB/s\\n",
                "AREA:eth0_out_n#346370:eth0 out",
                "LINE1:eth0_out_n#22AAD1",
                "GPRINT:eth0_out:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth0_out:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth0_out:LAST: Current\\: %5.1lf %sB/s",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph8("system-5min", "day", "Dirty memory on Titan");
&CreateGraph8("system-5min", "week", "Dirty memory on Titan");
&CreateGraph8("system-5min", "month", "Dirty memory on Titan");
&CreateGraph8("system-5min", "year", "Dirty memory on Titan");
&CreateGraph8("system-5min", "0years", "Dirty memory on Titan");

sub CreateGraph8
{
        RRDs::graph "$img/system.dirty-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_hight, "-w", $s_width,
                "-l 0", "-b 1024",
                "-Y", "-M",
                "-a", "PNG",
                "-b 1024",
                "-v Bytes",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:dirty_pages=$rrd/$_[0].rrd:dirty_pages:AVERAGE",
                "CDEF:dirty=dirty_pages,4096,*",
                "AREA:dirty#397563:dirty:",
                "LINE1:dirty#3CB18E",
                "GPRINT:dirty:MAX:  Max\\: %5.1lf %S",
                "GPRINT:dirty:AVERAGE: Avg\\: %5.1lf %S",
                "GPRINT:dirty:LAST: Current\\: %5.1lf %SB",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph9("system-5min", "day", "CPU load on Titan");
&CreateGraph9("system-5min", "week", "CPU load on Titan");
&CreateGraph9("system-5min", "month", "CPU load on Titan");
&CreateGraph9("system-5min", "year", "CPU load on Titan");
&CreateGraph9("system-5min", "0years", "CPU load on Titan");

sub CreateGraph9
{
        RRDs::graph "$img/system.load-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_hight, "-w", $s_width,
                "-l 0",
                "-Y",
                "-M",
                "-a", "PNG",
                "-v processes",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:load=$rrd/$_[0].rrd:load:AVERAGE",
                "AREA:load#7C5B57:Load",
                "LINE1:load#CC958F",
                "GPRINT:load:MAX:  Max\\: %5.2lf",
                "GPRINT:load:AVERAGE: Avg\\: %5.2lf",
                "GPRINT:load:LAST: Current\\: %5.2lf processes",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}


&CreateGraph10("system-5min", "day", "CPU frequency on Titan");
&CreateGraph10("system-5min", "week", "CPU frequency on Titan");
&CreateGraph10("system-5min", "month", "CPU frequency on Titan");
&CreateGraph10("system-5min", "year", "CPU frequency on Titan");
&CreateGraph10("system-5min", "0years", "CPU frequency on Titan");

sub CreateGraph10
{
        RRDs::graph "$img/system.freq-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_hight, "-w", $s_width,
                "-l 0",
                "-Y",
                "-u 100",
                "-r",
                "-a", "PNG",
                "-v %",
                "-c", "CANVAS#585858",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:t_1000=$rrd/$_[0].rrd:time_1000:AVERAGE",
                "DEF:t_1800=$rrd/$_[0].rrd:time_1800:AVERAGE",
                "CDEF:time_1000=100,t_1000,t_1000,t_1800,+,/,*",
                "CDEF:time_1800=100,t_1800,t_1000,t_1800,+,/,*",
                "AREA:time_1000#346370:Time at 1.0GHz",
                "GPRINT:time_1000:MAX:  Max\\: %5.1lf %s",
                "GPRINT:time_1000:AVERAGE: Avg\\: %5.1lf %S",
                "GPRINT:time_1000:LAST: Current\\: %5.1lf %S%%\\n",
                "STACK:time_1800#7C5B57:Time at 1.8GHz",
                "GPRINT:time_1800:MAX:  Max\\: %5.1lf %s",
                "GPRINT:time_1800:AVERAGE: Avg\\: %5.1lf %S",
                "GPRINT:time_1800:LAST: Current\\: %5.1lf %S%%",
                "LINE1:time_1000#CC958F",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph11("system-5min", "day", "Voltages on Titan");
&CreateGraph11("system-5min", "week", "Voltages on Titan");
&CreateGraph11("system-5min", "month", "Voltages on Titan");
&CreateGraph11("system-5min", "year", "Voltages on Titan");
&CreateGraph11("system-5min", "0years", "Voltages on Titan");

sub CreateGraph11
{
        RRDs::graph "$img/system.voltages1-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_hight, "-w", $s_width,
#                "-l 0",
                "-Y",
#               "-r",
                "-a", "PNG",
                "-v Volts",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:cpu=$rrd/$_[0].rrd:voltage_cpu:AVERAGE",
                "DEF:ram=$rrd/$_[0].rrd:voltage_ram:AVERAGE",
                "LINE2:cpu#CC958F:CPU    ",
                "LINE1:cpu#7C5B57",
                "GPRINT:cpu:MAX:  Max\\: %5.2lf %S",
                "GPRINT:cpu:AVERAGE: Avg\\: %5.2lf %S",
                "GPRINT:cpu:LAST: Current\\: %5.2lf %SV\\n",
                "LINE2:ram#22AAD1:RAM    ",
                "LINE1:ram#346370",
                "GPRINT:ram:MAX:  Max\\: %5.2lf %S",
                "GPRINT:ram:AVERAGE: Avg\\: %5.2lf %S",
                "GPRINT:ram:LAST: Current\\: %5.2lf %SV",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph12("system-5min", "day", "Voltages on Titan");
&CreateGraph12("system-5min", "week", "Voltages on Titan");
&CreateGraph12("system-5min", "month", "Voltages on Titan");
&CreateGraph12("system-5min", "year", "Voltages on Titan");
&CreateGraph12("system-5min", "0years", "Voltages on Titan");

sub CreateGraph12
{
        RRDs::graph "$img/system.voltages2-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_hight, "-w", $s_width,
#                "-l 0",
                "-M",
#               "-r",
                "-a", "PNG",
                "-v Volts",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:v33v=$rrd/$_[0].rrd:voltage_33v:AVERAGE",
                "DEF:v5v=$rrd/$_[0].rrd:voltage_5v:AVERAGE",
                "DEF:v12v=$rrd/$_[0].rrd:voltage_12v:AVERAGE",
                "DEF:bat=$rrd/$_[0].rrd:voltage_bat:AVERAGE",
                "LINE2:bat#A97EB0:Battery",
                "LINE1:bat#715A6F",
                "GPRINT:bat:MAX:  Max\\: %5.2lf %S",
                "GPRINT:bat:AVERAGE: Avg\\: %5.2lf %S",
                "GPRINT:bat:LAST: Current\\: %5.2lf %SV\\n",
                "LINE2:v33v#71A43B:3.3v   ",
                "LINE1:v33v#5E7149",
                "GPRINT:v33v:MAX:  Max\\: %5.2lf %S",
                "GPRINT:v33v:AVERAGE: Avg\\: %5.2lf %S",
                "GPRINT:v33v:LAST: Current\\: %5.2lf %SV\\n",
                "LINE2:v5v#3CB18E:5v     ",
                "LINE1:v5v#397563",
                "GPRINT:v5v:MAX:  Max\\: %5.2lf %S",
                "GPRINT:v5v:AVERAGE: Avg\\: %5.2lf %S",
                "GPRINT:v5v:LAST: Current\\: %5.2lf %SV\\n",
                "LINE2:v12v#22AAD1:12v    ",
                "LINE1:v12v#346370",
                "GPRINT:v12v:MAX:  Max\\: %5.2lf %S",
                "GPRINT:v12v:AVERAGE: Avg\\: %5.2lf %S",
                "GPRINT:v12v:LAST: Current\\: %5.2lf %SV",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph13("system-procs", "day", "Active processes on Titan");
&CreateGraph13("system-procs", "week", "Active processes on Titan");
&CreateGraph13("system-procs", "month", "Active processes on Titan");
&CreateGraph13("system-procs", "year", "Active processes on Titan");
&CreateGraph13("system-procs", "0years", "Active processes on Titan");

sub CreateGraph13
{
        RRDs::graph "$img/system.proc-active-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_hight, "-w", $s_width,
                "-l 0",
                "-Y", "-M",
                "-a", "PNG",
                "-v processes",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:active=$rrd/$_[0].rrd:processes_active:AVERAGE",
                "AREA:active#397563:Active ",
                "LINE1:active#3CB18E",
                "GPRINT:active:MAX:  Max\\: %5.2lf %S",
                "GPRINT:active:AVERAGE: Avg\\: %5.2lf %S",
                "GPRINT:active:LAST: Current\\: %5.2lf %Sactive",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph14("system-procs", "day", "Processes on Titan");
&CreateGraph14("system-procs", "week", "Processes on Titan");
&CreateGraph14("system-procs", "month", "Processes on Titan");
&CreateGraph14("system-procs", "year", "Processes on Titan");
&CreateGraph14("system-procs", "0years", "Processes on Titan");

sub CreateGraph14
{
        RRDs::graph "$img/system.proc-total-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_hight, "-w", $s_width,
                "-l 0",
#               "-Y",
                "-M",
                "-a", "PNG",
                "-v processes",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:total=$rrd/$_[0].rrd:processes_total:AVERAGE",
                "AREA:total#346370:Total ",
                "LINE1:total#22AAD1",
                "GPRINT:total:MAX:  Max\\: %5.1lf %S",
                "GPRINT:total:AVERAGE: Avg\\: %5.1lf %S",
                "GPRINT:total:LAST: Current\\: %5.1lf %Sprocesses",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph15("system-5min", "day", "Uptime of Titan");
&CreateGraph15("system-5min", "week", "Uptime of Titan");
&CreateGraph15("system-5min", "month", "Uptime of Titan");
&CreateGraph15("system-5min", "year", "Uptime of Titan");
&CreateGraph15("system-5min", "0years", "Uptime of Titan");

sub CreateGraph15
{
        RRDs::graph "$img/system.uptime-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_hight, "-w", $s_width,
                "-l 0",
                "-Y", "-M",
                "-a", "PNG",
                "-v days",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:upt=$rrd/$_[0].rrd:uptime:AVERAGE",
                "CDEF:uptime=upt,86400,/",
                "AREA:uptime#397563:Uptime",
                "LINE1:uptime#3CB18E",
                "GPRINT:uptime:MAX:  Max\\: %5.1lf",
                "GPRINT:uptime:AVERAGE: Avg\\: %5.1lf",
                "GPRINT:uptime:LAST: Current\\: %5.1lf days",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph16("system-5min", "day", "Fan Speeds on Titan");
&CreateGraph16("system-5min", "week", "Fan Speeds on Titan");
&CreateGraph16("system-5min", "month", "Fan Speeds on Titan");
&CreateGraph16("system-5min", "year", "Fan Speeds on Titan");
&CreateGraph16("system-5min", "0years", "Fan Speeds on Titan");

sub CreateGraph16
{
        RRDs::graph "$img/system.fans-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy",
                "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_hight, "-w", $s_width,
                "-l 0",
                "-Y",
                "-r",
                "-a", "PNG",
                "-v rpm",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:fan1=$rrd/$_[0].rrd:fan1:AVERAGE",
                "DEF:fan2=$rrd/$_[0].rrd:fan2:AVERAGE",
                "DEF:fan3=$rrd/$_[0].rrd:fan3:AVERAGE",
                "LINE2:fan3#3CB18E:PSU fan   ",
                "LINE1:fan3#397563",
                "GPRINT:fan3:MAX:  Max\\: %5.0lf",
                "GPRINT:fan3:AVERAGE: Avg\\: %5.0lf",
                "GPRINT:fan3:LAST: Current\\: %5.0lf rpm\\n",
                "LINE2:fan2#22AAD1:System fan",
                "LINE1:fan2#346370",
                "GPRINT:fan2:MAX:  Max\\: %5.0lf",
                "GPRINT:fan2:AVERAGE: Avg\\: %5.0lf",
                "GPRINT:fan2:LAST: Current\\: %5.0lf rpm\\n",
                "LINE2:fan1#CC958F:CPU fan   ",
                "LINE1:fan1#7C5B57",
                "GPRINT:fan1:MAX:  Max\\: %5.0lf",
                "GPRINT:fan1:AVERAGE: Avg\\: %5.0lf",
                "GPRINT:fan1:LAST: Current\\: %5.0lf rpm",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph18("system-2h", "day", "Frequency transitions on Titan");
&CreateGraph18("system-2h", "week", "Frequency transitions on Titan");
&CreateGraph18("system-2h", "month", "Frequency transitions on Titan");
&CreateGraph18("system-2h", "year", "Frequency transitions on Titan");
&CreateGraph18("system-2h", "0years", "Frequency transitions on Titan");

sub CreateGraph18
{
        RRDs::graph "$img/system.freq_trans-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_hight, "-w", $s_width,
                "-l 0",
                "-Y", "-M",
                "-a", "PNG",
                "-v transitions",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:freq_trans=$rrd/$_[0].rrd:freq_trans:AVERAGE",
                "CDEF:trans=freq_trans,3600,*",
                "AREA:trans#7C5B57:Transitions",
                "LINE1:trans#CC958F",
                "GPRINT:trans:MAX:  Max\\: %5.1lf %s",
                "GPRINT:trans:AVERAGE: Avg\\: %5.1lf %s",
                "GPRINT:trans:LAST: Current\\: %5.1lf %stras/hour",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph19("pings", "day", "Ping to BGWireless");
&CreateGraph19("pings", "week", "Ping to BGWireless");
&CreateGraph19("pings", "month", "Ping to BGWireless");
&CreateGraph19("pings", "year", "Ping to BGWireless");
&CreateGraph19("pings", "0years", "Ping to BGWireless");

sub CreateGraph19
{
        RRDs::graph "$img/ping.bgw-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $hight, "-w", $width,
                "-l 0",
                "-Y", "-M",
                "-a", "PNG",
                "-v s",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:bgw=$rrd/$_[0].rrd:ping_bgw:AVERAGE",
                "CDEF:ping=bgw,1000,/",
                "AREA:ping#346370:BGWireless",
                "LINE1:ping#22AAD1",
                "GPRINT:ping:MAX:  Max\\: %5.1lf %ss",
                "GPRINT:ping:AVERAGE: Avg\\: %5.1lf %ss",
                "GPRINT:ping:LAST: Current\\: %5.1lf %ss",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph20("pings", "day", "Ping to ISP");
&CreateGraph20("pings", "week", "Ping to ISP");
&CreateGraph20("pings", "month", "Ping to ISP");
&CreateGraph20("pings", "year", "Ping to ISP");
&CreateGraph20("pings", "0years", "Ping to ISP");

sub CreateGraph20
{
        RRDs::graph "$img/ping.isp-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_hight, "-w", $s_width,
                "-l 0",
                "-Y", "-M",
                "-a", "PNG",
                "-v s",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:isp=$rrd/$_[0].rrd:ping_isp:AVERAGE",
                "CDEF:ping=isp,1000,/",
                "AREA:ping#346370:ISP",
                "LINE1:ping#22AAD1",
                "GPRINT:ping:MAX:  Max\\: %5.1lf %ss",
                "GPRINT:ping:AVERAGE: Avg\\: %5.1lf %ss",
                "GPRINT:ping:LAST: Current\\: %5.1lf %ss",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph21("pings", "day", "Ping to Google");
&CreateGraph21("pings", "week", "Ping to Google");
&CreateGraph21("pings", "month", "Ping to Google");
&CreateGraph21("pings", "year", "Ping to Google");
&CreateGraph21("pings", "0years", "Ping to Google");

sub CreateGraph21
{
        RRDs::graph "$img/ping.google-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_hight, "-w", $s_width,
                "-l 0",
                "-Y", "-M",
                "-a", "PNG",
                "-v s",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:google=$rrd/$_[0].rrd:ping_google:AVERAGE",
                "CDEF:ping=google,1000,/",
                "AREA:ping#346370:Google",
                "LINE1:ping#22AAD1",
                "GPRINT:ping:MAX:  Max\\: %5.1lf %ss",
                "GPRINT:ping:AVERAGE: Avg\\: %5.1lf %ss",
                "GPRINT:ping:LAST: Current\\: %5.1lf %ss",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph17("system-5min", "day", "sda usage on Titan");
&CreateGraph17("system-5min", "week", "sda usage on Titan");
&CreateGraph17("system-5min", "month", "sda usage on Titan");
&CreateGraph17("system-5min", "year", "sda usage on Titan");
&CreateGraph17("system-5min", "0years", "sda usage on Titan");

sub CreateGraph17
{
        RRDs::graph "$img/system.sda-rw-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_big, "-w", $s_width,
                "-l 0",
                "-Y", "-M",
                "-a", "PNG",
                "-b 1024",
                "-v Bytes per second",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:sda_read=$rrd/$_[0].rrd:sda_read:AVERAGE",
                "DEF:sda_write=$rrd/$_[0].rrd:sda_write:AVERAGE",
                "CDEF:read=sda_read,512,*",
                "CDEF:write=sda_write,512,*",
                "CDEF:write_n=write,-1,*",
                "AREA:read#7C5B57:sda read ",
                "LINE1:read#CC958F",
                "GPRINT:read:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:read:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:read:LAST: Current\\: %5.1lf %sB/s\\n",
                "AREA:write_n#346370:sda write",
                "LINE1:write_n#22AAD1",
                "GPRINT:write:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:write:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:write:LAST: Current\\: %5.1lf %sB/s",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph22("system-5min", "day", "sdb usage on Titan");
&CreateGraph22("system-5min", "week", "sdb usage on Titan");
&CreateGraph22("system-5min", "month", "sdb usage on Titan");
&CreateGraph22("system-5min", "year", "sdb usage on Titan");
&CreateGraph22("system-5min", "0years", "sdb usage on Titan");

sub CreateGraph22
{
        RRDs::graph "$img/system.sdb-rw-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_big, "-w", $s_width,
                "-l 0",
                "-Y", "-M",
                "-a", "PNG",
                "-b 1024",
                "-v Bytes per second",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:sdb_read=$rrd/$_[0].rrd:sdb_read:AVERAGE",
                "DEF:sdb_write=$rrd/$_[0].rrd:sdb_write:AVERAGE",
                "CDEF:read=sdb_read,512,*",
                "CDEF:write=sdb_write,512,*",
                "CDEF:write_n=write,-1,*",
                "AREA:read#7C5B57:sdb read ",
                "LINE1:read#CC958F",
                "GPRINT:read:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:read:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:read:LAST: Current\\: %5.1lf %sB/s\\n",
                "AREA:write_n#346370:sdb write",
                "LINE1:write_n#22AAD1",
                "GPRINT:write:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:write:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:write:LAST: Current\\: %5.1lf %sB/s",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph23("system-5min", "day", "sdc usage on Titan");
&CreateGraph23("system-5min", "week", "sdc usage on Titan");
&CreateGraph23("system-5min", "month", "sdc usage on Titan");
&CreateGraph23("system-5min", "year", "sdc usage on Titan");
&CreateGraph23("system-5min", "0years", "sdc usage on Titan");

sub CreateGraph23
{
        RRDs::graph "$img/system.sdc-rw-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_big, "-w", $s_width,
                "-l 0",
                "-Y", "-M",
                "-a", "PNG",
                "-b 1024",
                "-v Bytes per second",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:sdc_read=$rrd/$_[0].rrd:sdc_read:AVERAGE",
                "DEF:sdc_write=$rrd/$_[0].rrd:sdc_write:AVERAGE",
                "CDEF:read=sdc_read,512,*",
                "CDEF:write=sdc_write,512,*",
                "CDEF:write_n=write,-1,*",
                "AREA:read#7C5B57:sdc read ",
                "LINE1:read#CC958F",
                "GPRINT:read:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:read:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:read:LAST: Current\\: %5.1lf %sB/s\\n",
                "AREA:write_n#346370:sdc write",
                "LINE1:write_n#22AAD1",
                "GPRINT:write:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:write:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:write:LAST: Current\\: %5.1lf %sB/s",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

_________________
gentoo user
Back to top
View user's profile Send private message
tnt
Veteran
Veteran


Joined: 27 Feb 2004
Posts: 1222

PostPosted: Wed Jun 15, 2005 9:08 pm    Post subject: Reply with quote

Still first script, part 2:
Code:

&CreateGraph24("system-5min", "day", "sdd usage on Titan");
&CreateGraph24("system-5min", "week", "sdd usage on Titan");
&CreateGraph24("system-5min", "month", "sdd usage on Titan");
&CreateGraph24("system-5min", "year", "sdd usage on Titan");
&CreateGraph24("system-5min", "0years", "sdd usage on Titan");

sub CreateGraph24
{
        RRDs::graph "$img/system.sdd-rw-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_big, "-w", $s_width,
                "-l 0",
                "-Y", "-M",
                "-a", "PNG",
                "-b 1024",
                "-v Bytes per second",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:sdd_read=$rrd/$_[0].rrd:sdd_read:AVERAGE",
                "DEF:sdd_write=$rrd/$_[0].rrd:sdd_write:AVERAGE",
                "CDEF:read=sdd_read,512,*",
                "CDEF:write=sdd_write,512,*",
                "CDEF:write_n=write,-1,*",
                "AREA:read#7C5B57:sdd read ",
                "LINE1:read#CC958F",
                "GPRINT:read:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:read:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:read:LAST: Current\\: %5.1lf %sB/s\\n",
                "AREA:write_n#346370:sdd write",
                "LINE1:write_n#22AAD1",
                "GPRINT:write:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:write:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:write:LAST: Current\\: %5.1lf %sB/s",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph25("system-5min", "day", "eth1 (BGWireless) usage on Titan");
&CreateGraph25("system-5min", "week", "eth1 (BGWireless) usage on Titan");
&CreateGraph25("system-5min", "month", "eth1 (BGWireless) usage on Titan");
&CreateGraph25("system-5min", "year", "eth1 (BGWireless) usage on Titan");
&CreateGraph25("system-5min", "0years", "eth1 (BGWireless) usage on Titan");

sub CreateGraph25
{
        RRDs::graph "$img/system.eth1-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy",
                "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $big, "-w", $width,
                "-l 0",
                "-Y", "-M",
                "-a", "PNG",
                "-v Bytes per second",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:eth1_in=$rrd/$_[0].rrd:eth1_in:AVERAGE",
                "DEF:eth1_out=$rrd/$_[0].rrd:eth1_out:AVERAGE",
                "DEF:eth1_in_ft=$rrd/p2p.rrd:eth1_in_ft:AVERAGE",
                "DEF:eth1_out_ft=$rrd/p2p.rrd:eth1_out_ft:AVERAGE",
                "DEF:eth1_in_dc=$rrd/p2p.rrd:eth1_in_dc:AVERAGE",
                "DEF:eth1_out_dc=$rrd/p2p.rrd:eth1_out_dc:AVERAGE",
                "DEF:eth1_in_gnu=$rrd/p2p.rrd:eth1_in_gnu:AVERAGE",
                "DEF:eth1_out_gnu=$rrd/p2p.rrd:eth1_out_gnu:AVERAGE",
                "DEF:eth1_in_bittor=$rrd/p2p.rrd:eth1_in_bittor:AVERAGE",
                "DEF:eth1_out_bittor=$rrd/p2p.rrd:eth1_out_bittor:AVERAGE",
                "DEF:eth1_in_oft=$rrd/p2p.rrd:eth1_in_oft:AVERAGE",
                "DEF:eth1_out_oft=$rrd/p2p.rrd:eth1_out_oft:AVERAGE",
                "DEF:eth1_in_edonk=$rrd/p2p.rrd:eth1_in_edonk:AVERAGE",
                "DEF:eth1_out_edonk=$rrd/p2p.rrd:eth1_out_edonk:AVERAGE",
                "DEF:eth1_in_rest=$rrd/p2p.rrd:eth1_in_rest:AVERAGE",
                "DEF:eth1_out_rest=$rrd/p2p.rrd:eth1_out_rest:AVERAGE",
                "CDEF:eth1_out_n=eth1_out,-1,*",
                "CDEF:eth1_out_p2p=eth1_out_ft,eth1_out_dc,+,eth1_out_gnu,+,eth1_out_bittor,+,eth1_out_oft,+,eth1_out_edonk,+,eth1_out_rest,+,eth1_out,MIN",
                "CDEF:eth1_in_p2p=eth1_in_ft,eth1_in_dc,+,eth1_in_gnu,+,eth1_in_bittor,+,eth1_in_oft,+,eth1_in_edonk,+,eth1_in_rest,+,eth1_in,MIN",
                "CDEF:eth1_out_p2p_n=eth1_out_p2p,-1,*",

                "AREA:eth1_in#7C5B57:eth1 in ",
                "GPRINT:eth1_in:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_in:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_in:LAST: Current\\: %5.1lf %sB/s\\n",
                "AREA:eth1_in_p2p#A7343B:p2p  in ",
                "LINE1:eth1_in_p2p#EC4954",
                "GPRINT:eth1_in_p2p:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_p2p:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_p2p:LAST: Current\\: %5.1lf %sB/s\\n",
                "LINE1:eth1_in#CC958F",

                "AREA:eth1_out_n#346370:eth1 out",
                "GPRINT:eth1_out:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_out:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_out:LAST: Current\\: %5.1lf %sB/s\\n",
                "AREA:eth1_out_p2p_n#397563:p2p  out",
                "LINE1:eth1_out_p2p_n#3CB18E",
                "GPRINT:eth1_out_p2p:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_p2p:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_p2p:LAST: Current\\: %5.1lf %sB/s",
                "LINE1:eth1_out_n#22AAD1",

                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph26("system-5min", "day", "eth2 (Internet) usage on Titan");
&CreateGraph26("system-5min", "week", "eth2 (Internet) usage on Titan");
&CreateGraph26("system-5min", "month", "eth2 (Internet) usage on Titan");
&CreateGraph26("system-5min", "year", "eth2 (Internet) usage on Titan");
&CreateGraph26("system-5min", "0years", "eth2 (Internet) usage on Titan");

sub CreateGraph26
{
        RRDs::graph "$img/system.eth2-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $big, "-w", $width,
                "-l 0",
#               "-Y",
                "-M",
                "-a", "PNG",
                "-v Bytes per second",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:eth2_in=$rrd/$_[0].rrd:eth2_in:AVERAGE",
                "DEF:eth2_out=$rrd/$_[0].rrd:eth2_out:AVERAGE",
                "DEF:eth2_in_ft=$rrd/p2p.rrd:eth2_in_ft:AVERAGE",
                "DEF:eth2_out_ft=$rrd/p2p.rrd:eth2_out_ft:AVERAGE",
                "DEF:eth2_in_dc=$rrd/p2p.rrd:eth2_in_dc:AVERAGE",
                "DEF:eth2_out_dc=$rrd/p2p.rrd:eth2_out_dc:AVERAGE",
                "DEF:eth2_in_gnu=$rrd/p2p.rrd:eth2_in_gnu:AVERAGE",
                "DEF:eth2_out_gnu=$rrd/p2p.rrd:eth2_out_gnu:AVERAGE",
                "DEF:eth2_in_bittor=$rrd/p2p.rrd:eth2_in_bittor:AVERAGE",
                "DEF:eth2_out_bittor=$rrd/p2p.rrd:eth2_out_bittor:AVERAGE",
                "DEF:eth2_in_oft=$rrd/p2p.rrd:eth2_in_oft:AVERAGE",
                "DEF:eth2_out_oft=$rrd/p2p.rrd:eth2_out_oft:AVERAGE",
                "DEF:eth2_in_edonk=$rrd/p2p.rrd:eth2_in_edonk:AVERAGE",
                "DEF:eth2_out_edonk=$rrd/p2p.rrd:eth2_out_edonk:AVERAGE",
                "DEF:eth2_in_rest=$rrd/p2p.rrd:eth2_in_rest:AVERAGE",
                "DEF:eth2_out_rest=$rrd/p2p.rrd:eth2_out_rest:AVERAGE",
                "CDEF:eth2_out_n=eth2_out,-1,*",
                "CDEF:eth2_out_p2p=eth2_out_ft,eth2_out_dc,+,eth2_out_gnu,+,eth2_out_bittor,+,eth2_out_oft,+,eth2_out_edonk,+,eth2_out_rest,+,eth2_out,MIN",
                "CDEF:eth2_in_p2p=eth2_in_ft,eth2_in_dc,+,eth2_in_gnu,+,eth2_in_bittor,+,eth2_in_oft,+,eth2_in_edonk,+,eth2_in_rest,+,eth2_in,MIN",
                "CDEF:eth2_out_p2p_n=eth2_out_p2p,-1,*",

                "AREA:eth2_in#7C5B57:eth2 in ",
                "GPRINT:eth2_in:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_in:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_in:LAST: Current\\: %5.1lf %sB/s\\n",
                "AREA:eth2_in_p2p#A7343B:p2p  in ",
                "LINE1:eth2_in_p2p#EC4954",
                "GPRINT:eth2_in_p2p:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_p2p:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_p2p:LAST: Current\\: %5.1lf %sB/s\\n",
                "LINE1:eth2_in#CC958F",

                "AREA:eth2_out_n#346370:eth2 out",
                "GPRINT:eth2_out:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_out:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_out:LAST: Current\\: %5.1lf %sB/s\\n",
                "AREA:eth2_out_p2p_n#397563:p2p  out",
                "LINE1:eth2_out_p2p_n#3CB18E",
                "GPRINT:eth2_out_p2p:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_p2p:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_p2p:LAST: Current\\: %5.1lf %sB/s",
                "LINE1:eth2_out_n#22AAD1",

                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}



&CreateGraph27("system-5min", "day", "Disks usage on Titan");
&CreateGraph27("system-5min", "week", "Disks usage on Titan");
&CreateGraph27("system-5min", "month", "Disks usage on Titan");
&CreateGraph27("system-5min", "year", "Disks usage on Titan");
&CreateGraph27("system-5min", "0years", "Disks usage on Titan");

sub CreateGraph27
{
        RRDs::graph "$img/system.disks-rw-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $big, "-w", $width,
                "-l 0",
                "-Y", "-M",
                "-a", "PNG",
                "-b 1024",
                "-v Bytes per second",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:sda_read=$rrd/$_[0].rrd:sda_read:AVERAGE",
                "DEF:sda_write=$rrd/$_[0].rrd:sda_write:AVERAGE",
                "DEF:sdb_read=$rrd/$_[0].rrd:sdb_read:AVERAGE",
                "DEF:sdb_write=$rrd/$_[0].rrd:sdb_write:AVERAGE",
                "DEF:sdc_read=$rrd/$_[0].rrd:sdc_read:AVERAGE",
                "DEF:sdc_write=$rrd/$_[0].rrd:sdc_write:AVERAGE",
                "DEF:sdd_read=$rrd/$_[0].rrd:sdd_read:AVERAGE",
                "DEF:sdd_write=$rrd/$_[0].rrd:sdd_write:AVERAGE",
                "CDEF:read=sda_read,sdb_read,+,sdc_read,+,sdd_read,+,512,*",
                "CDEF:write=sda_write,sdb_write,+,sdc_write,+,sdd_write,+,512,*",
                "CDEF:write_n=write,-1,*",
                "AREA:read#7C5B57:Disk reads ",
                "LINE1:read#CC958F",
                "GPRINT:read:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:read:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:read:LAST: Current\\: %5.1lf %sB/s\\n",
                "AREA:write_n#346370:Disk writes",
                "LINE1:write_n#22AAD1",
                "GPRINT:write:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:write:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:write:LAST: Current\\: %5.1lf %sB/s",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph28("p2p", "day", "p2p traffic on eth1");
&CreateGraph28("p2p", "week", "p2p traffic on eth1");
&CreateGraph28("p2p", "month", "p2p traffic on eth1");
&CreateGraph28("p2p", "year", "p2p traffic on eth1");
&CreateGraph28("p2p", "0years", "p2p traffic on eth1");

sub CreateGraph28
{
        RRDs::graph "$img/p2p.eth1-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy",
                "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_big, "-w", $s_width,
                "-l 0",
                "-Y", "-M",
                "-a", "PNG",
                "-v Bytes per second",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:eth1_in_ft=$rrd/$_[0].rrd:eth1_in_ft:AVERAGE",
                "DEF:eth1_out_ft=$rrd/$_[0].rrd:eth1_out_ft:AVERAGE",
                "DEF:eth1_in_dc=$rrd/$_[0].rrd:eth1_in_dc:AVERAGE",
                "DEF:eth1_out_dc=$rrd/$_[0].rrd:eth1_out_dc:AVERAGE",
                "DEF:eth1_in_gnu=$rrd/$_[0].rrd:eth1_in_gnu:AVERAGE",
                "DEF:eth1_out_gnu=$rrd/$_[0].rrd:eth1_out_gnu:AVERAGE",
                "DEF:eth1_in_bittor=$rrd/$_[0].rrd:eth1_in_bittor:AVERAGE",
                "DEF:eth1_out_bittor=$rrd/$_[0].rrd:eth1_out_bittor:AVERAGE",
                "DEF:eth1_in_oft=$rrd/$_[0].rrd:eth1_in_oft:AVERAGE",
                "DEF:eth1_out_oft=$rrd/$_[0].rrd:eth1_out_oft:AVERAGE",
                "DEF:eth1_in_edonk=$rrd/$_[0].rrd:eth1_in_edonk:AVERAGE",
                "DEF:eth1_out_edonk=$rrd/$_[0].rrd:eth1_out_edonk:AVERAGE",
                "DEF:eth1_in_rest=$rrd/$_[0].rrd:eth1_in_rest:AVERAGE",
                "DEF:eth1_out_rest=$rrd/$_[0].rrd:eth1_out_rest:AVERAGE",
                "DEF:eth1_in=$rrd/system-5min.rrd:eth1_in:AVERAGE",

                "DEF:eth1_out=$rrd/system-5min.rrd:eth1_out:AVERAGE",
                "CDEF:eth1_out_ft_n=eth1_out_ft,eth1_out,MIN,-1,*",
                "CDEF:eth1_out_dc_n=eth1_out_dc,eth1_out,MIN,-1,*",
                "CDEF:eth1_out_gnu_n=eth1_out_gnu,eth1_out,MIN,-1,*",
                "CDEF:eth1_out_bittor_n=eth1_out_bittor,eth1_out,MIN,-1,*",
                "CDEF:eth1_out_oft_n=eth1_out_oft,eth1_out,MIN,-1,*",
                "CDEF:eth1_out_edonk_n=eth1_out_edonk,eth1_out,MIN,-1,*",
                "CDEF:eth1_out_rest_n=eth1_out_rest,eth1_out,MIN,-1,*",
                "CDEF:eth1_in_ft_g=eth1_in_ft,eth1_in,MIN",
                "CDEF:eth1_in_dc_g=eth1_in_dc,eth1_in,MIN",
                "CDEF:eth1_in_gnu_g=eth1_in_gnu,eth1_in,MIN",
                "CDEF:eth1_in_bittor_g=eth1_in_bittor,eth1_in,MIN",
                "CDEF:eth1_in_oft_g=eth1_in_oft,eth1_in,MIN",
                "CDEF:eth1_in_edonk_g=eth1_in_edonk,eth1_in,MIN",
                "CDEF:eth1_in_rest_g=eth1_in_rest,eth1_in,MIN",
                "CDEF:eth1_out_p2p=eth1_out_ft,eth1_out_dc,+,eth1_out_gnu,+,eth1_out_bittor,+,eth1_out_oft,+,eth1_out_edonk,+,eth1_out_rest,+,eth1_out,MIN",
                "CDEF:eth1_in_p2p=eth1_in_ft,eth1_in_dc,+,eth1_in_gnu,+,eth1_in_bittor,+,eth1_in_oft,+,eth1_in_edonk,+,eth1_in_rest,+,eth1_in,MIN",
                "CDEF:eth1_out_p2p_n=eth1_out_p2p,-1,*",

                "AREA:eth1_in_ft_g#7C5B57:Fasttrack      in",
                "GPRINT:eth1_in_ft_g:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_ft_g:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_ft_g:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth1_in_dc_g#346370:DirectConnect  in",
                "GPRINT:eth1_in_dc_g:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_dc_g:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_dc_g:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth1_in_gnu_g#397563:Gnutella       in",
                "GPRINT:eth1_in_gnu_g:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_gnu_g:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_gnu_g:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth1_in_bittor_g#5E7149:Bittorrent     in",
                "GPRINT:eth1_in_bittor_g:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_bittor_g:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_bittor_g:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth1_in_oft_g#756339:OpenFT         in",
                "GPRINT:eth1_in_oft_g:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_oft_g:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_oft_g:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth1_in_edonk_g#925A39:Edonkey        in",
                "GPRINT:eth1_in_edonk_g:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_edonk_g:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_edonk_g:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth1_in_rest_g#A7343B:Other p2p      in",
                "GPRINT:eth1_in_rest_g:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_rest_g:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_in_rest_g:LAST: Current\\: %5.1lf %sB/s\\n",
                "LINE1:eth1_in_p2p#CC958F",

                "AREA:eth1_out_ft_n#7C5B57AA:Fasttrack     out",
                "GPRINT:eth1_out_ft:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_ft:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_ft:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth1_out_dc_n#346370AA:DirectConnect out",
                "GPRINT:eth1_out_dc:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_dc:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_dc:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth1_out_gnu_n#397563AA:Gnutella      out",
                "GPRINT:eth1_out_gnu:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_gnu:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_gnu:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth1_out_bittor_n#5E7149AA:Bittorrent    out",
                "GPRINT:eth1_out_bittor:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_bittor:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_bittor:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth1_out_oft_n#756339AA:OpenFT        out",
                "GPRINT:eth1_out_oft:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_oft:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_oft:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth1_out_edonk_n#925A39AA:Edonkey       out",
                "GPRINT:eth1_out_edonk:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_edonk:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_edonk:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth1_out_rest_n#A7343BAA:Other p2p     out",
                "GPRINT:eth1_out_rest:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_rest:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth1_out_rest:LAST: Current\\: %5.1lf %sB/s",
                "LINE1:eth1_out_p2p_n#CC958FAA",

                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph29("p2p", "day", "p2p traffic on eth2");
&CreateGraph29("p2p", "week", "p2p traffic on eth2");
&CreateGraph29("p2p", "month", "p2p traffic on eth2");
&CreateGraph29("p2p", "year", "p2p traffic on eth2");
&CreateGraph29("p2p", "0years", "p2p traffic on eth2");

sub CreateGraph29
{
        RRDs::graph "$img/p2p.eth2-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy",
                "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_big, "-w", $s_width,
                "-l 0",
                "-Y", "-M",
                "-a", "PNG",
                "-v Bytes per second",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:eth2_in_ft=$rrd/$_[0].rrd:eth2_in_ft:AVERAGE",
                "DEF:eth2_out_ft=$rrd/$_[0].rrd:eth2_out_ft:AVERAGE",
                "DEF:eth2_in_dc=$rrd/$_[0].rrd:eth2_in_dc:AVERAGE",
                "DEF:eth2_out_dc=$rrd/$_[0].rrd:eth2_out_dc:AVERAGE",
                "DEF:eth2_in_gnu=$rrd/$_[0].rrd:eth2_in_gnu:AVERAGE",
                "DEF:eth2_out_gnu=$rrd/$_[0].rrd:eth2_out_gnu:AVERAGE",
                "DEF:eth2_in_bittor=$rrd/$_[0].rrd:eth2_in_bittor:AVERAGE",
                "DEF:eth2_out_bittor=$rrd/$_[0].rrd:eth2_out_bittor:AVERAGE",
                "DEF:eth2_in_oft=$rrd/$_[0].rrd:eth2_in_oft:AVERAGE",
                "DEF:eth2_out_oft=$rrd/$_[0].rrd:eth2_out_oft:AVERAGE",
                "DEF:eth2_in_edonk=$rrd/$_[0].rrd:eth2_in_edonk:AVERAGE",
                "DEF:eth2_out_edonk=$rrd/$_[0].rrd:eth2_out_edonk:AVERAGE",
                "DEF:eth2_in_rest=$rrd/$_[0].rrd:eth2_in_rest:AVERAGE",
                "DEF:eth2_out_rest=$rrd/$_[0].rrd:eth2_out_rest:AVERAGE",
                "DEF:eth2_in=$rrd/system-5min.rrd:eth2_in:AVERAGE",
                "DEF:eth2_out=$rrd/system-5min.rrd:eth2_out:AVERAGE",
                "CDEF:eth2_out_ft_n=eth2_out_ft,eth2_out,MIN,-1,*",
                "CDEF:eth2_out_dc_n=eth2_out_dc,eth2_out,MIN,-1,*",
                "CDEF:eth2_out_gnu_n=eth2_out_gnu,eth2_out,MIN,-1,*",
                "CDEF:eth2_out_bittor_n=eth2_out_bittor,eth2_out,MIN,-1,*",
                "CDEF:eth2_out_oft_n=eth2_out_oft,eth2_out,MIN,-1,*",
                "CDEF:eth2_out_edonk_n=eth2_out_edonk,eth2_out,MIN,-1,*",
                "CDEF:eth2_out_rest_n=eth2_out_rest,eth2_out,MIN,-1,*",
                "CDEF:eth2_in_ft_g=eth2_in_ft,eth2_in,MIN",
                "CDEF:eth2_in_dc_g=eth2_in_dc,eth2_in,MIN",
                "CDEF:eth2_in_gnu_g=eth2_in_gnu,eth2_in,MIN",
                "CDEF:eth2_in_bittor_g=eth2_in_bittor,eth2_in,MIN",
                "CDEF:eth2_in_oft_g=eth2_in_oft,eth2_in,MIN",
                "CDEF:eth2_in_edonk_g=eth2_in_edonk,eth2_in,MIN",
                "CDEF:eth2_in_rest_g=eth2_in_rest,eth2_in,MIN",
                "CDEF:eth2_out_p2p=eth2_out_ft,eth2_out_dc,+,eth2_out_gnu,+,eth2_out_bittor,+,eth2_out_oft,+,eth2_out_edonk,+,eth2_out_rest,+,eth2_out,MIN",
                "CDEF:eth2_in_p2p=eth2_in_ft,eth2_in_dc,+,eth2_in_gnu,+,eth2_in_bittor,+,eth2_in_oft,+,eth2_in_edonk,+,eth2_in_rest,+,eth2_in,MIN",
                "CDEF:eth2_out_p2p_n=eth2_out_p2p,-1,*",

                "AREA:eth2_in_ft_g#7C5B57:Fasttrack      in",
                "GPRINT:eth2_in_ft_g:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_ft_g:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_ft_g:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth2_in_dc_g#346370:DirectConnect  in",
                "GPRINT:eth2_in_dc_g:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_dc_g:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_dc_g:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth2_in_gnu_g#397563:Gnutella       in",
                "GPRINT:eth2_in_gnu_g:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_gnu_g:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_gnu_g:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth2_in_bittor_g#5E7149:Bittorrent     in",
                "GPRINT:eth2_in_bittor_g:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_bittor_g:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_bittor_g:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth2_in_oft_g#756339:OpenFT         in",
                "GPRINT:eth2_in_oft_g:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_oft_g:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_oft_g:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth2_in_edonk_g#925A39:Edonkey        in",
                "GPRINT:eth2_in_edonk_g:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_edonk_g:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_edonk_g:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth2_in_rest_g#A7343B:Other p2p      in",
                "GPRINT:eth2_in_rest_g:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_rest_g:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_in_rest_g:LAST: Current\\: %5.1lf %sB/s\\n",
                "LINE1:eth2_in_p2p#CC958F",

                "AREA:eth2_out_ft_n#7C5B57AA:Fasttrack     out",
                "GPRINT:eth2_out_ft:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_ft:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_ft:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth2_out_dc_n#346370AA:DirectConnect out",
                "GPRINT:eth2_out_dc:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_dc:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_dc:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth2_out_gnu_n#397563AA:Gnutella      out",
                "GPRINT:eth2_out_gnu:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_gnu:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_gnu:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth2_out_bittor_n#5E7149AA:Bittorrent    out",
                "GPRINT:eth2_out_bittor:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_bittor:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_bittor:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth2_out_oft_n#756339AA:OpenFT        out",
                "GPRINT:eth2_out_oft:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_oft:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_oft:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth2_out_edonk_n#925A39AA:Edonkey       out",
                "GPRINT:eth2_out_edonk:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_edonk:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_edonk:LAST: Current\\: %5.1lf %sB/s\\n",
                "STACK:eth2_out_rest_n#A7343BAA:Other p2p     out",
                "GPRINT:eth2_out_rest:MAX:  Max\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_rest:AVERAGE: Avg\\: %5.1lf %sB/s",
                "GPRINT:eth2_out_rest:LAST: Current\\: %5.1lf %sB/s",
                "LINE1:eth2_out_p2p_n#CC958FAA",

                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph30("dns", "day", "DNS stats on Titan");
&CreateGraph30("dns", "week", "DNS stats on Titan");
&CreateGraph30("dns", "month", "DNS stats on Titan");
&CreateGraph30("dns", "year", "DNS stats on Titan");
&CreateGraph30("dns", "0years", "DNS stats on Titan");

sub CreateGraph30
{
        RRDs::graph "$img/system.dns-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy",
                "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_hight, "-w", $s_width,
                "-l 0",
#                "-Y",
                "-r",
                "-a", "PNG",
                "-v per minute",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:success_ps=$rrd/$_[0].rrd:success:AVERAGE",
                "DEF:referral_ps=$rrd/$_[0].rrd:referral:AVERAGE",
                "DEF:nxrrset_ps=$rrd/$_[0].rrd:nxrrset:AVERAGE",
                "DEF:nxdomain_ps=$rrd/$_[0].rrd:nxdomain:AVERAGE",
                "DEF:recursion_ps=$rrd/$_[0].rrd:recursion:AVERAGE",
                "DEF:failure_ps=$rrd/$_[0].rrd:failure:AVERAGE",
                "CDEF:success=success_ps,60,*",
                "CDEF:referral=referral_ps,60,*",
                "CDEF:nxrrset=nxrrset_ps,60,*",
                "CDEF:nxdomain=nxdomain_ps,60,*",
                "CDEF:recursion=recursion_ps,60,*",
                "CDEF:failure=failure_ps,60,*",
                "CDEF:total=success,referral,+,nxrrset,+,nxdomain,+,recursion,+,failure,+",
                "AREA:success#756339:Success   ",
                "GPRINT:success:MAX:  Max\\: %6.2lf",
                "GPRINT:success:AVERAGE: Avg\\: %6.2lf",
                "GPRINT:success:LAST: Current\\: %6.2lf %s  1\/min\\n",
                "STACK:referral#5E7149:Referral  ",
                "GPRINT:referral:MAX:  Max\\: %6.2lf",
                "GPRINT:referral:AVERAGE: Avg\\: %6.2lf",
                "GPRINT:referral:LAST: Current\\: %6.2lf %s  1\/min\\n",
                "STACK:nxrrset#397563:NXrrset   ",
                "GPRINT:nxrrset:MAX:  Max\\: %6.2lf",
                "GPRINT:nxrrset:AVERAGE: Avg\\: %6.2lf",
                "GPRINT:nxrrset:LAST: Current\\: %6.2lf %s  1\/min\\n",
                "STACK:nxdomain#346370:NXdomain  ",
                "GPRINT:nxdomain:MAX:  Max\\: %6.2lf",
                "STACK:recursion#7C5B57:Recursion ",
                "GPRINT:recursion:MAX:  Max\\: %6.2lf",
                "GPRINT:recursion:AVERAGE: Avg\\: %6.2lf",
                "GPRINT:recursion:LAST: Current\\: %6.2lf %s  1\/min\\n",
                "STACK:failure#A7343B:Failure   ",
                "GPRINT:failure:MAX:  Max\\: %6.2lf",
                "GPRINT:failure:AVERAGE: Avg\\: %6.2lf",
                "GPRINT:failure:LAST: Current\\: %6.2lf %s  1\/min\\n",
                "LINE1:total#CC958F:Total     ",
                "GPRINT:total:MAX:  Max\\: %6.2lf",
                "GPRINT:total:AVERAGE: Avg\\: %6.2lf",
                "GPRINT:total:LAST: Current\\: %6.2lf   %s1\/min",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}

&CreateGraph31("system-temp", "day", "IP Connections on Titan");
&CreateGraph31("system-temp", "week", "IP Connections on Titan");
&CreateGraph31("system-temp", "month", "IP Connections on Titan");
&CreateGraph31("system-temp", "year", "IP Connections on Titan");
&CreateGraph31("system-temp", "0years", "IP Connections on Titan");

sub CreateGraph31
{
        RRDs::graph "$img/system.ip_conntrack-$_[1].png",
                "-s -1$_[1]",
                "-t $_[2] - $_[1]",
                "--lazy", "-E", "-i", "--font", "TITLE:11:/usr/share/fonts/corefonts/arialbd.ttf",
                "-h", $s_hight, "-w", $s_width,
                "-l 0",
#               "-Y",
                "-M",
                "-a", "PNG",
                "-v processes",
                "-c", "CANVAS#222222",
                "-c", "BACK#C0C0CC",
                "-c", "GRID#576F6622",
                "-c", "MGRID#11111144",
                "DEF:connections=$rrd/$_[0].rrd:ip_conntrack_count:AVERAGE",
                "AREA:connections#7C5B57:Connections ",
                "LINE1:connections#CC958F",
                "GPRINT:connections:MAX:  Max\\: %5.1lf %S",
                "GPRINT:connections:AVERAGE: Avg\\: %5.1lf %S",
                "GPRINT:connections:LAST: Current\\: %5.1lf %S",
                "HRULE:0#888888";
        if ($ERROR = RRDs::error) { print "$0: unable to generate $_[0] $_[1] graph: $ERROR\n"; }
}


and this is cgi I point my browser to:
Code:
#!/bin/bash

echo "Content-Type: text/html"
echo
echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>"
echo "<html>"
echo "<br>"
echo "<HEAD><META HTTP-EQUIV='Refresh' CONTENT='300'><META HTTP-EQUIV='Pragma' CONTENT='no-cache'>"
echo "<META HTTP-EQUIV='Expires' CONTENT='Sun, 02 Apr 2000 04:55:58 GMT'>"
echo "<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=iso-8859-1'>"

nice -n 12 ./system_graphs.pl

echo "<TITLE>System monitoring for Titan</TITLE></HEAD>"

echo "<BODY BGCOLOR='#333333' link='#D0B0B0' vlink='#DDCCFF' alink='#EEEEEE'><div align='center'>"
echo "<TABLE BORDER=0 WIDTH='100%'>"
echo "<TR><TD><center><IMG ALT='Gentoo Linux' BORDER=0 SRC='../pics/powered-small.png'>"
echo "</TD><TD><center><H4><font COLOR=#C0C0CC>System monitoring for Titan</font></H4>"
echo "<a href="./system-day.cgi" title="Day">Day</a> <a href="./system-week.cgi" title="Week">Week</a> "
echo "<a href="./system-month.cgi" title="Month">Month</a> <a href="./system-year.cgi" title="Year">Year</a><br>"
echo "<br>"
echo "<a href="./squid-day.cgi" title="Squid">Squid</a> <a href="./apc-day.cgi" title="APC">APC</a> "
#echo "<a href="./network-day.cgi" title="Network">Network</a><br><br>"
echo "</TD><TD><center><IMG ALT='Gentoo Linux' BORDER=0 SRC='../pics/moving-drag.gif'>"
echo "</TD></TR></TABLE>"

echo "<br>"
echo "<A HREF='system.cpu0.cgi'><IMG ALT='system.cpu0 Graph' BORDER=0 SRC='graphs/system.cpu0-day.png'></A>"

echo "<br>"
echo "<A HREF='system.load.cgi'><IMG ALT='system.load Graph' BORDER=0 SRC='graphs/system.load-day.png'></A>"
#echo "<br>"
echo "<A HREF='system.proc-active.cgi'><IMG ALT='system.proc-active Graph' BORDER=0 SRC='graphs/system.proc-active-day.png'></A>"

echo "<br>"
echo "<A HREF='system.freq.cgi'><IMG ALT='system.freq Graph' BORDER=0 SRC='graphs/system.freq-day.png'></A>"
#echo "<br>"
echo "<A HREF='system.proc-total.cgi'><IMG ALT='system.proc-total Graph' BORDER=0 SRC='graphs/system.proc-total-day.png'></A>"

echo "<br>"
echo "<A HREF='system.mem.cgi'><IMG ALT='system.mem Graph' BORDER=0 SRC='graphs/system.mem-day.png'></A>"

echo "<br>"
echo "<A HREF='system.swap.cgi'><IMG ALT='system.swap Graph' BORDER=0 SRC='graphs/system.swap-day.png'></A>"

echo "<br>"
echo "<A HREF='system.swaped.cgi'><IMG ALT='system.swaped Graph' BORDER=0 SRC='graphs/system.swaped-day.png'></A>"
#echo "<br>"
echo "<A HREF='system.dirty.cgi'><IMG ALT='system.dirty Graph' BORDER=0 SRC='graphs/system.dirty-day.png'></A>"

echo "<br>"
echo "<A HREF='system.eth0.cgi'><IMG ALT='system.eth0 Graph' BORDER=0 SRC='graphs/system.eth0-day.png'></A>"
echo "<br>"
echo "<A HREF='system.eth1.cgi'><IMG ALT='system.eth1 Graph' BORDER=0 SRC='graphs/system.eth1-day.png'></A>"
echo "<br>"
echo "<A HREF='system.eth2.cgi'><IMG ALT='system.eth2 Graph' BORDER=0 SRC='graphs/system.eth2-day.png'></A>"
echo "<br>"
echo "<A HREF='p2p.eth2.cgi'><IMG ALT='p2p.eth2 Graph' BORDER=0 SRC='graphs/p2p.eth2-day.png'></A>"

echo "<br>"
echo "<A HREF='system.disks-rw.cgi'><IMG ALT='system.disks-rw Graph' BORDER=0 SRC='graphs/system.disks-rw-day.png'></A>"

echo "<br>"
echo "<A HREF='system.sda-rw.cgi'><IMG ALT='system.sda-rw Graph' BORDER=0 SRC='graphs/system.sda-rw-day.png'></A>"
#echo "<br>"
echo "<A HREF='system.sdb-rw.cgi'><IMG ALT='system.sdb-rw Graph' BORDER=0 SRC='graphs/system.sdb-rw-day.png'></A>"
echo "<br>"
echo "<A HREF='system.sdc-rw.cgi'><IMG ALT='system.sdc-rw Graph' BORDER=0 SRC='graphs/system.sdc-rw-day.png'></A>"
#echo "<br>"
echo "<A HREF='system.sdd-rw.cgi'><IMG ALT='system.sdd-rw Graph' BORDER=0 SRC='graphs/system.sdd-rw-day.png'></A>"

echo "<br>"
echo "<A HREF='system.temperatures.cgi'><IMG ALT='system.temperatures Graph' BORDER=0 SRC='graphs/system.temperatures-day.png'></A>"

echo "<br>"
echo "<A HREF='system.disk-temps.cgi'><IMG ALT='system.disk-temps Graph' BORDER=0 SRC='graphs/system.disk-temps-day.png'></A>"
#echo "<br>"
echo "<A HREF='system.fans.cgi'><IMG ALT='system.fans Graph' BORDER=0 SRC='graphs/system.fans-day.png'></A>"

echo "<br>"
echo "<A HREF='system.voltages1.cgi'><IMG ALT='system.voltages1 Graph' BORDER=0 SRC='graphs/system.voltages1-day.png'></A>"
#echo "<br>"
echo "<A HREF='system.freq_trans.cgi'><IMG ALT='system.freq_trans Graph' BORDER=0 SRC='graphs/system.freq_trans-day.png'></A>"

echo "<br>"
echo "<A HREF='system.voltages2.cgi'><IMG ALT='system.voltages2 Graph' BORDER=0 SRC='graphs/system.voltages2-day.png'></A>"
#echo "<br>"
echo "<A HREF='system.dns.cgi'><IMG ALT='system.dns Graph' BORDER=0 SRC='graphs/system.dns-day.png'></A>"

echo "<br>"
echo "<A HREF='system.uptime.cgi'><IMG ALT='system.uptime Graph' BORDER=0 SRC='graphs/system.uptime-day.png'></A>"
#echo "<br>"
echo "<A HREF='system.ip_conntrack.cgi'><IMG ALT='system.ip_conntrack Graph' BORDER=0 SRC='graphs/system.ip_conntrack-day.png'></A>"

echo "<br>"
echo "<A HREF='ping.bgw.cgi'><IMG ALT='ping.bgw Graph' BORDER=0 SRC='graphs/ping.bgw-day.png'></A>"

echo "<br>"
echo "<A HREF='ping.isp.cgi'><IMG ALT='ping.isp Graph' BORDER=0 SRC='graphs/ping.isp-day.png'></A>"
#echo "<br>"
echo "<A HREF='ping.google.cgi'><IMG ALT='ping.google Graph' BORDER=0 SRC='graphs/ping.google-day.png'></A>"

echo "</div></body></html>"

_________________
gentoo user
Back to top
View user's profile Send private message
tnt
Veteran
Veteran


Joined: 27 Feb 2004
Posts: 1222

PostPosted: Wed Jun 15, 2005 9:13 pm    Post subject: Reply with quote

Take your time ;)
_________________
gentoo user
Back to top
View user's profile Send private message
abz
n00b
n00b


Joined: 18 Nov 2004
Posts: 64
Location: Melbourne

PostPosted: Thu Jun 16, 2005 2:20 pm    Post subject: Reply with quote

Thanks for that, just the right size and complexity.

Abz.
Back to top
View user's profile Send private message
tnt
Veteran
Veteran


Joined: 27 Feb 2004
Posts: 1222

PostPosted: Thu Jun 16, 2005 2:27 pm    Post subject: Reply with quote

You've asked for my scripts, you've got them...

:wink:
_________________
gentoo user
Back to top
View user's profile Send private message
bakreule
Apprentice
Apprentice


Joined: 27 Aug 2003
Posts: 233
Location: Paris, France

PostPosted: Thu Jun 16, 2005 2:48 pm    Post subject: Reply with quote

To the original author, thank you very much for this how to, very well written and very informative.

To everyone, I just have a curiosity question: How much overhead does implementing bandwidth throttling impose on the kernel? Is it just a matter of how many rules you have? Or does it have a fixed penalty as soon as you have one rule, combined with the penalty for each additional rule?
_________________
Buses stop at a bus station.
Trains stop at a train station.
On my desk there's a workstation.....
Back to top
View user's profile Send private message
tnt
Veteran
Veteran


Joined: 27 Feb 2004
Posts: 1222

PostPosted: Thu Jun 16, 2005 4:46 pm    Post subject: Reply with quote

bakreule wrote:
To everyone, I just have a curiosity question: How much overhead does implementing bandwidth throttling impose on the kernel? Is it just a matter of how many rules you have? Or does it have a fixed penalty as soon as you have one rule, combined with the penalty for each additional rule?


http://l7-filter.sourceforge.net/performance
_________________
gentoo user
Back to top
View user's profile Send private message
theDreamer
Tux's lil' helper
Tux's lil' helper


Joined: 20 Oct 2003
Posts: 118

PostPosted: Sat Jun 18, 2005 7:58 pm    Post subject: nice Reply with quote

nice howto, thanks!
_________________
Cheers,
Nir Dremer
www.dremer.org
Back to top
View user's profile Send private message
gringo
Advocate
Advocate


Joined: 27 Apr 2003
Posts: 3793

PostPosted: Wed Jun 22, 2005 10:08 am    Post subject: Reply with quote

thanx guys, very interesting thread !

cheers
Back to top
View user's profile Send private message
Seather
Apprentice
Apprentice


Joined: 23 May 2003
Posts: 194
Location: South Africa

PostPosted: Fri Jul 15, 2005 10:09 pm    Post subject: A little problem Reply with quote

I have a linux gateway that shares the internet connection for my whole home network. I use the following to forward DC++ connections to my machine on the internal network (connected to eth0) that's actually running DC++ (p2p application).

What I want to do is set up bandwidth limiting on my gateway that will limit the upload traffic of that specific box on the inside network.

I use this to let dc++ work on the inside machine:
Code:
$IPTABLES -t nat -A PREROUTING -i ppp0 -p tcp --dport 555 -j DNAT --to 192.168.0.57:555
$IPTABLES -t nat -A PREROUTING -i ppp0 -p udp --dport 555 -j DNAT --to 192.168.0.57:555
$IPTABLES -I FORWARD -i ppp0 -d 192.168.0.57 -p tcp --dport 555 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -I FORWARD -i ppp0 -d 192.168.0.57 -p udp --dport 555 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT


This I added the following rule to mark the packets:
Code:
$IPTABLES -t mangle -I PREROUTING -i eth0 -s 192.168.0.57 -j MARK --set-mark 2


And this to bandwidth limit
Code:
# Define root
tc qdisc add dev eth0 root handle 1: htb default 10
tc class add dev eth0 parent 1: classid 1:1 htb rate 102400kbit burst 1218k

# Classes
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 102400kbit burst 1218k prio 1
tc class add dev eth0 parent 1:1 classid 1:20 htb rate 504kbit burst 12k prio 2
tc class add dev eth0 parent 1:1 classid 1:30 htb rate 56kbit burst 6k prio 3

# Fairly devide rest
tc qdisc add dev eth0 parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev eth0 parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev eth0 parent 1:30 handle 30: sfq perturb 10

# Limit
tc filter add dev eth0 protocol ip parent 1:0 handle 2 fw flowid 1:30


However this is limiting my download as well, it should though? How can I fix this?
Back to top
View user's profile Send private message
Seather
Apprentice
Apprentice


Joined: 23 May 2003
Posts: 194
Location: South Africa

PostPosted: Fri Jul 15, 2005 10:34 pm    Post subject: Reply with quote

I changed it over to work on ppp0, still limiting download too however:

Code:
# Define root
tc qdisc add dev ppp0 root handle 1: htb default 10
tc class add dev ppp0 parent 1: classid 1:1 htb rate 504kbit burst 6k

# Classes
tc class add dev ppp0 parent 1:1 classid 1:10 htb rate 504kbit burst 6k prio 1
tc class add dev ppp0 parent 1:1 classid 1:20 htb rate 252kbit burst 6k prio 2
tc class add dev ppp0 parent 1:1 classid 1:30 htb rate 56kbit burst 6k prio 3

# Fairly devide rest
tc qdisc add dev ppp0 parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev ppp0 parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev ppp0 parent 1:30 handle 30: sfq perturb 10

# Limit
tc filter add dev ppp0 protocol ip parent 1:0 handle 2 fw flowid 1:30


And

Code:
$IPTABLES -t nat -A PREROUTING -i ppp0 -p tcp --dport 555 -j DNAT --to 192.168.0.57:555
$IPTABLES -t nat -A PREROUTING -i ppp0 -p udp --dport 555 -j DNAT --to 192.168.0.57:555
$IPTABLES -I FORWARD -i ppp0 -d 192.168.0.57 -p tcp --dport 555 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -I FORWARD -i ppp0 -d 192.168.0.57 -p udp --dport 555 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

$IPTABLES -t mangle -I FORWARD -i eth0 -s 192.168.0.57 -o ppp0 -j MARK --set-mark 2
Back to top
View user's profile Send private message
tnt
Veteran
Veteran


Joined: 27 Feb 2004
Posts: 1222

PostPosted: Sat Jul 16, 2005 3:34 am    Post subject: Reply with quote

Try to use this:

http://l7-filter.sourceforge.net/

and read this:

http://l7-filter.sourceforge.net/L7-HOWTO-Netfilter#Doing

;)
_________________
gentoo user
Back to top
View user's profile Send private message
ddaas
Tux's lil' helper
Tux's lil' helper


Joined: 28 Feb 2005
Posts: 106
Location: Germany

PostPosted: Wed Jul 20, 2005 2:30 pm    Post subject: Reply with quote

Hi,
I am very new to HTB. In fact this is my first htb script.
Everything works great (a very good tutorial :)), but I have 2 questions:

1) It seams that my ftp transfer runs faster than 10kbit. It seams it works with 15kbytes/s... Do you know why? This is not a very accurate measurement. It is the value showed my Total Commander when I transfer a file to my xp box from my linux server.

2) Could anyone explain the following?

class htb 1:20 parent 1:1 leaf 20: prio 2 rate 10Kbit ceil 10Kbit burst 1611b cburst 1611b
Sent 193705 bytes 2836 pkts (dropped 0, overlimits 0 requeues 0)
rate 1291bit 19pps backlog 7p
lended: 2829 borrowed: 0 giants: 0
tokens: -1354518 ctokens: -1354518

my script is:
Quote:
#!/bin/bash
#deletes everything
tc qdisc del dev eth0 root

tc qdisc add dev eth0 root handle 1: htb default 12

tc class add dev eth0 parent 1: classid 1:1 htb rate 9mbps ceil 9mbps

tc class add dev eth0 parent 1:1 classid 1:10 htb rate 9mbps ceil 9mbps prio 1

tc class add dev eth0 parent 1:1 classid 1:20 htb rate 10kbit ceil 10kbit prio 2

tc class add dev eth0 parent 1:1 classid 1:30 htb rate 5kbit ceil 5kbit prio 3

tc qdisc add dev eth0 parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev eth0 parent 1:20 handle 20: sfq perturb 10
tc qdisc add dev eth0 parent 1:30 handle 30: sfq perturb 10

tc filter add dev eth0 parent 1: protocol ip u32 match ip sport 20 0xffff flowid 1:20
tc filter add dev eth0 parent 1: protocol ip u32 match ip sport 80 0xffff flowid 1:30



Thanks a lot
_________________
Best regards,
ddaas
Back to top
View user's profile Send private message
tnt
Veteran
Veteran


Joined: 27 Feb 2004
Posts: 1222

PostPosted: Wed Jul 20, 2005 3:14 pm    Post subject: Reply with quote

Probably you use passive ftp and port 20 on the server side is not used...
_________________
gentoo user
Back to top
View user's profile Send private message
ahorn
Guru
Guru


Joined: 01 Nov 2004
Posts: 366
Location: Ol' europe

PostPosted: Thu Aug 11, 2005 6:59 am    Post subject: Reply with quote

I tried it the last two days. i don't get some real good shaping to work. why is there no X tool with preconfigured stuff
for ssh,ed2k,etc? ;) - do you know the tool for ms windows called 'cFos' - thats such a klick-yougetit-tool. Maybe
someone can post his entirely firewall-script with l7-filters, because i don't get how to manage fw-rules with l7-masking.

My router (avm fritzbox sl) got traffic shaping, too. is it important to find out the shaping rules from the router? i mean,
if i manage some traffic at the gentoo box, can it be possible, that the route manage it again with other restrictions?
maybe that's the reason why my poorly ssh stucks down when i surf the net after doing the traffic shaping howto at
gentoo-wiki.com.

thanks for help, ahorn.
_________________
Too many connections. Please try again later.
Back to top
View user's profile Send private message
n0rbi666
l33t
l33t


Joined: 04 Mar 2005
Posts: 707
Location: \Poland\Krakow

PostPosted: Mon Sep 19, 2005 12:08 pm    Post subject: Reply with quote

Hi !
Nice How-to, but ... for me it does'nt work as I expected....

I want to limit amule upload and only upload.

so I wrote a script :
Code:

tc qdisc del root dev eth0
tc qdisc add dev eth0 root handle 1: htb default 10
tc class add dev eth0 parent 1: classid 1:1 htb rate 100kbit ceil 100kbit
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 90kbit ceil 100kbit prio 1
tc class add dev eth0 parent 1:1 classid 1:20 htb rate  10kbit ceil 20kbit prio 9
tc qdisc add dev eth0 parent 1:10 handle 10: sfq perturb 10
tc qdisc add dev eth0 parent 1:20 handle 20: sfq perturb 10

iptables -t mangle -A OUTPUT -m owner --cmd-owner amule -j MARK --set-mark 2
tc filter add dev eth0 protocol ip parent 1:0 handle 2 fw flowid 1:20


And it works, but it limits upload and download - not only upload

How to fix it, so the script will limit only upload? (I tried with sport, dport at port 4666 but it does'nt work at all (I use 4666 for emule)

Thanx for help :)
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Thu Sep 22, 2005 10:16 pm    Post subject: Reply with quote

The HTB qdisc you set up on eth0 will shape everything that's sent out on eth0. So this script would only make sense if eth0 is a device that is dedicated to internet access. For shaping both up- and download with this, it would have to be some very weird network setup, like a router with only one network device (that serves both internet and LAN via eth0).
Back to top
View user's profile Send private message
Lajasha
Veteran
Veteran


Joined: 17 Mar 2004
Posts: 1040
Location: Vibe Central

PostPosted: Mon Oct 24, 2005 4:54 pm    Post subject: Reply with quote

Thanks for the HowTo, but I was unable to get it up and running reffering to only this Doc. I was able to get it working after refering to a few different places for data. I figured I would post the configs that I used just so anyone else that maybe having issues with this too can give it a go.

First let me give you a little background into what I wanted to achieve. My classes are arranged like this
Code:

Main Class (divided into 5 pieces)
  Priority 1) Interactive applications (Highest Priority SSH)
  Priority 2) Shoutcast Server
  Priority 3) Services (http,ftp,etc.)
  Priority 4) Default (Anything not owned by the other rules)
  Priority 5) Bittorrent (Lowest Priority)


KERNEL
I used a 2.6 kernel and used a kernel config based on the one at gentoo wiki:

Code:
 Networking options  --->
   QoS and/or fair queueing  --->
     [*] QoS and/or fair queueing
     <M>   HTB packet scheduler
     <M>   SFQ queue
     [*]   Packet classifier API
     <M> Firewall based classifier
   IP: Netfilter Configuration  --->
     <M> Connection tracking (required for masq/NAT)
     <M> IP tables support (required for filtering/masq/NAT)
     <M>   limit match support
     <M>   MAC address match support
     <M>   Packet type match support
     <M>   netfilter MARK match support
     <M>   Multiple port match support
     <M>   TOS match support
     <M>   random match support
     <M>   recent match support
     <M>   ECN match support
     <M>   DSCP match support
     <M>   AH/ESP match support
     <M>   LENGTH match support
     <M>   TTL match support
     <M>   tcpmss match support
     <M>   Helper match support
     <M>   Connection state match support
     <M>   Connection mark match support
     <M>   Connection tracking match support
     <M>   Unclean match support (EXPERIMENTAL)
     <M>   Owner match support (EXPERIMENTAL)
     <M>   Packet filtering
     <M>     REJECT target support
     <M>     MIRROR target support (EXPERIMENTAL)
     <M>   Full NAT
     <M>     MASQUERADE target support
     <M>     REDIRECT target support
     <M>     Basic SNMP-ALG support (EXPERIMENTAL)
     <M>   Packet mangling
     <M>     TOS target support
     <M>     ECN target support
     <M>     DSCP target support
     <M>     MARK target support
     <M>   LOG target support
     <M>   CONNMARK target support
     <M>   ULOG target support
     <M>   TCPMSS target support
     <M> ARP tables support
     <M>   ARP packet filtering
     <M>   ARP payload mangling


I went more with the iptables based marking of packets instead of the route this HowTo used. Below is the iptables listing I used, and the shapping commands I used.

IPTABLES
Code:

#!/bin/bash

echo Creating Constants
# Constants
LOCALNET="192.168.0.0/255.255.255.0"
MARKPRIO1="1"
MARKPRIO2="2"
MARKPRIO3="3"
MARKPRIO4="4"
MARKPRIO5="5"

echo Setting Default Policies
# Setting policy
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P PREROUTING ACCEPT

echo Flushing All Tables
# Flushing all tables
iptables -F INPUT
iptables -F OUTPUT
iptables -F FORWARD
iptables -t nat -F POSTROUTING
iptables -t nat -F PREROUTING
iptables -t mangle -F OUTPUT
iptables -t mangle -F FORWARD

echo Setting up Redirections
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 23 -j REDIRECT --to-ports 22

echo Punching Wholes in Firewall for Services
iptables -t filter -A INPUT -i lo -j ACCEPT
iptables -t filter -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -t filter -A INPUT -p tcp -m tcp --dport 22:23 -j ACCEPT
iptables -t filter -A INPUT -p tcp -m tcp -m multiport --dports 20,21 -j ACCEPT
iptables -t filter -A INPUT -p udp -m udp -m multiport --dports 20,21 -j ACCEPT
iptables -t filter -A INPUT -p tcp -m tcp -m multiport --dports 80,443 -j ACCEPT
iptables -t filter -A INPUT -p tcp -m tcp --dport 5190 -j ACCEPT
iptables -t filter -A INPUT -p tcp -m tcp --dport 60000:65535 -j ACCEPT
iptables -t filter -A INPUT -p udp -m udp --dport 60000:65535 -j ACCEPT

echo Setting Priority Markers
# Setting priority marks
# Prio 1
# icmp
iptables -t mangle -A OUTPUT -p icmp -j MARK --set-mark $MARKPRIO1
# ssh
iptables -t mangle -A OUTPUT -p tcp --sport 22 -j MARK --set-mark $MARKPRIO1
# non tcp
iptables -t mangle -A OUTPUT -p ! tcp -j MARK --set-mark $MARKPRIO1

# Prio 2
#Shoutcast
iptables -t mangle -A OUTPUT -p tcp --sport 5190 -j MARK --set-mark $MARKPRIO2


# Prio 3
# http
iptables -t mangle -A OUTPUT -p tcp --sport 80 -j MARK --set-mark $MARKPRIO3
# https
iptables -t mangle -A OUTPUT -p tcp --sport 443 -j MARK --set-mark $MARKPRIO3

# Prio 4 (Default)

# Prio 5
#Used UID owner as I could not seem to collect all connections that were related to the bitorrent connection by just port
iptables -t mangle -A OUTPUT -m owner --uid-owner 500 -j MARK --set-mark $MARKPRIO5
iptables -t mangle -A OUTPUT -p tcp --sport 6881:6889 -j MARK --set-mark $MARKPRIO5
iptables -t mangle -A OUTPUT -p tcp --sport 6881:6889 -j MARK --set-mark $MARKPRIO5

# Remaining packets are marked according to TOS
iptables -t mangle -A OUTPUT -p tcp -m tos --tos Minimize-Delay -m mark --mark 0 -j MARK --set-mark $MARKPRIO1
iptables -t mangle -A OUTPUT -p tcp -m tos --tos Maximize-Throughput -m mark --mark 0 -j MARK --set-mark $MARKPRIO4
iptables -t mangle -A OUTPUT -p tcp -m tos --tos Minimize-Cost -m mark --mark 0 -j MARK --set-mark $MARKPRIO5


BANDWIDTH SHAPING
Code:

#!/bin/bash
echo Dump Current Rules
tc qdisc del dev eth0 root

echo Create Rules
tc qdisc add dev eth0 root handle 1:0 htb default 14
tc class add dev eth0 parent 1:0 classid 1:1 htb rate 300kbit ceil 300kbit
tc class add dev eth0 parent 1:1 classid 1:11 htb rate 64kbit ceil 300kbit prio 1
tc class add dev eth0 parent 1:1 classid 1:12 htb rate 100kbit ceil 300kbit prio 2
tc class add dev eth0 parent 1:1 classid 1:13 htb rate 64kbit ceil 300kbit prio 3
tc class add dev eth0 parent 1:1 classid 1:14 htb rate 64kbit ceil 300kbit prio 4
tc class add dev eth0 parent 1:1 classid 1:15 htb rate 8kbit ceil 300kbit prio 5
tc filter add dev eth0 parent 1:0 protocol ip prio 1 handle 1 fw classid 1:11
tc filter add dev eth0 parent 1:0 protocol ip prio 2 handle 2 fw classid 1:12
tc filter add dev eth0 parent 1:0 protocol ip prio 3 handle 3 fw classid 1:13
tc filter add dev eth0 parent 1:0 protocol ip prio 4 handle 4 fw classid 1:14
tc filter add dev eth0 parent 1:0 protocol ip prio 5 handle 5 fw classid 1:15


Once you have run this, the simply issue this command and watch to see your packets are working like specified:
Code:
watch tc -s class show dev eth0


Pages I referenced:
This Howto
Gentoo Wiki
HTB Linux queuing discipline manual - user guide
_________________
Come and play in my land
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 3 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum