Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I have a load of rules on one of my linux routers that monitor bandwidth on a local IP basis, as shown below PHP Code: # Bash script to monitor bandwidth on FireWallSkip iptables  - N client1 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2007
    Posts
    1

    IPTables - Extract values for traffic monitoring


    Hi,

    I have a load of rules on one of my linux routers that monitor bandwidth on a local IP basis, as shown below

    PHP Code:
    # Bash script to monitor bandwidth on FireWallSkip
    iptables -N client1
    iptables 
    -N client2
    iptables 
    -N client3
    iptables 
    -N client4
    iptables 
    -N client5
    iptables 
    -N client6
    iptables 
    -N client7
    iptables 
    -N client8
    iptables 
    -N client9
    iptables 
    -N client10

    iptables 
    -A FORWARD

    iptables 
    -A FORWARD -d 192.168.2.6 -j client1
    iptables 
    -A FORWARD -d 192.168.2.10 -j client2
    iptables 
    -A FORWARD -d 192.168.2.14 -j client3
    iptables 
    -A FORWARD -d 192.168.2.18 -j client4
    iptables 
    -A FORWARD -d 192.168.2.22 -j client5
    iptables 
    -A FORWARD -d 192.168.2.26 -j client6
    iptables 
    -A FORWARD -d 192.168.2.30 -j client7
    iptables 
    -A FORWARD -d 192.168.2.34 -j client8
    iptables 
    -A FORWARD -d 192.168.2.38 -j client9
    iptables 
    -A FORWARD -d 192.168.2.42 -j client10

    iptables 
    -A FORWARD -s 192.168.2.6 -j client1
    iptables 
    -A FORWARD -s 192.168.2.10 -j client2
    iptables 
    -A FORWARD -s 192.168.2.14 -j client3
    iptables 
    -A FORWARD -s 192.168.2.18 -j client4
    iptables 
    -A FORWARD -s 192.168.2.22 -j client5
    iptables 
    -A FORWARD -s 192.168.2.26 -j client6
    iptables 
    -A FORWARD -s 192.168.2.30 -j client7
    iptables 
    -A FORWARD -s 192.168.2.34 -j client8
    iptables 
    -A FORWARD -s 192.168.2.38 -j client9
    iptables 
    -A FORWARD -s 192.168.2.42 -j client10 
    So when I run

    Code:
    iptables -L -v -n
    I get an output like this

    PHP Code:
    6795 3182K            all  --  *      *       0.0.0.0/0            0.0.0.0/0           
      649  264K client1  all  
    --  *      *       0.0.0.0/0            192.168.2.6         
        1   139 client2  all  
    --  *      *       0.0.0.0/0            192.168.2.10        
        0     0 client3  all  
    --  *      *       0.0.0.0/0            192.168.2.14        
        0     0 client4  all  
    --  *      *       0.0.0.0/0            192.168.2.18        
        0     0 client5  all  
    --  *      *       0.0.0.0/0            192.168.2.22        
        0     0 client6  all  
    --  *      *       0.0.0.0/0            192.168.2.26        
        0     0 client7  all  
    --  *      *       0.0.0.0/0            192.168.2.30        
        0     0 client8  all  
    --  *      *       0.0.0.0/0            192.168.2.34        
        0     0 client9  all  
    --  *      *       0.0.0.0/0            192.168.2.38        
     2941 2501K client10  all  
    --  *      *       0.0.0.0/0            192.168.2.42        
      712  103K client1  all  
    --  *      *       192.168.2.6          0.0.0.0/0           
        1    89 client2  all  
    --  *      *       192.168.2.10         0.0.0.0/0           
        0     0 client3  all  
    --  *      *       192.168.2.14         0.0.0.0/0           
        0     0 client4  all  
    --  *      *       192.168.2.18         0.0.0.0/0           
        0     0 client5  all  
    --  *      *       192.168.2.22         0.0.0.0/0           
        0     0 client6  all  
    --  *      *       192.168.2.26         0.0.0.0/0           
        0     0 client7  all  
    --  *      *       192.168.2.30         0.0.0.0/0           
        0     0 client8  all  
    --  *      *       192.168.2.34         0.0.0.0/0           
        0     0 client9  all  
    --  *      *       192.168.2.38         0.0.0.0/0           
     2491  313K client10  all  
    --  *      *       192.168.2.42         0.0.0.0/
    So what I want to do is somehow extract the traffic values and input them into a mysql DB.

    Any thoughts?

    Thanks

  2. #2
    Linux Newbie framp's Avatar
    Join Date
    Jul 2006
    Location
    Stuttgart, Germany
    Posts
    240
    I don't know how to get the data into a mySQL DB - but I would use either a shell script, awk script or perl script to extract the traffic counter and then add the appropriate code to write the data into the mySQL DB.
    "Really, I'm not out to destroy Microsoft. That will just be a completely unintentional side effect." Linus Benedict Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •