jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-pre6/] [modules/] [netstat/] [platform/] [linux.pm] - Blame information for rev 7

 

Line No. Rev Author Line
11simandlpackage HotSaNICmod::OSdep;
2 
3sub version {
4 ($VERSION = '$Revision: 1.4 $') =~ s/.*(\d+\.\d+).*/$1/;
5 return "$^O.pm $VERSION";
6 }
7 
8sub sample {
9 my %args=@_;
10 
11 my @values=(0,0,0,0,0,0,0,0,0,0,0,0);
12 
13 open FILE,"/proc/net/tcp";
14 while (<FILE>) {
15 (undef,undef,undef,$state)=split;
16 if ($state =~ /[0-9A-F]+/) {
17 if ($state =~ /^0/) {
18 $state =~ s/^0//;
19 if ($state eq "A") { $state=10; }
20 elsif ($state eq "B") { $state=11; }
21 elsif ($state !~ /[0-9]/) { $state=0; }
22 }
23 else { $state=0; }
24 $values[$state]++;
25 }
26 }
27 close FILE;
28 HotSaNICmod::do_rrd("connections","U",time,@values);
29 }
30 
311;
32 
33# known states:
34#
35# 01=ESTABLISHED 02=SYN_SENT 03=SYN_RECV 04=FIN_WAIT1 05=FIN_WAIT2
36# 06=TIME_WAIT 07=CLOSE 09=LAST_ACK 0A=LISTEN 0B=CLOSING
37 
38# TODO:
39#
40# this module only stats local connections.
41#
42# to stat ALL (i.e. including masq'ed) connections: use /proc/net/ip_conntrack
43# select all lines containing "tcp" as 1st keyword
44# the connection state can be found in plaintext on pos. #4
45#
46# ATTENTION: This stat also contains the connections to the local configured IPs!
47#
48# format of ip_conntrack:
49#
50# <proto> <proto#> <expire time (sec.)> <original source> <packet destination> <src port> <dst port> <expected return source> <expected return dest> <expected ret. src port> <expected ret. dst port> <use>
51#
52# for more details see:
53# http://www.faqs.org/docs/iptables/theconntrackentries.html
54# <kernel source tree>/net/ipv4/netfilter/ip_conntrack.c
55# <kernel source tree>/include/linux/netfilter_ipv4/ip_conntrack.h
56 
57 

Powered by WebSVN 2.2.1