Hi,
Your scripts might be useful. However, ipvsadm can be used to list
connections, for example,
ipvsadm -lcn
or
ipvsadm -l --connection -n
Cheers,
Wensong
On 7 Aug 2002, Jeff Warnica wrote:
>
> Ive been running a nat ipvs cluster here at work for a few months. At
> the very beginig I was having some trouble with some realservers, and I
> did agian today. So I finaly broke down and came up with a
> /proc/net/ip_vs_conn hex mode to integer script.. Also, if its given an
> ipaddress as an argument on the commandline it will show only lines with
> that ipaddress in it. Quick and dirty:
>
>
> #!/usr/bin/perl
>
> if (@ARGV) {
> $mask = $ARGV[0];
> }
> open(DATA, "/proc/net/ip_vs_conn");
>
> $format = "%8s %-17s %-5s %-17s %-5s %-17s %-5s %-17s %-20s\n";
> printf $format, "Protocol", "From IP", "FPort", "To IP", "TPort", "Dest
> IP", "DPort", "State", "Expires";
> while(<DATA>){
> chop;
> ($proto, $fromip, $fromport, $toip, $toport, $destip, $destport,
> $state, $expiry) = split();
> next unless $fromip;
> next if ($proto =~ /Pro/);
>
> $fromip = hex2ip($fromip);
> $toip = hex2ip($toip);
> $destip = hex2ip($destip);
>
> $fromport = hex($fromport);
> $toport = hex($toport);
> $destport = hex($destport);
>
> if ( ($fromip =~ /$mask/) || ($toip =~ /$mask/) || ($destip =~
> /$mask/) || (!($mask))) {
> printf $format, $proto, $fromip, $fromport, $toip,
> $toport, $destip, $destport, $state, $expiry;
> }
> }
>
>
> sub hex2ip($input) {
> my $input = shift;
>
> $first = substr($input,0,2);
> $second = substr($input,2,2);
> $third = substr($input,4,2);
> $fourth = substr($input,6,2);
>
> $first = hex($first);
> $second = hex($second);
> $third = hex($third);
> $fourth = hex($fourth);
>
> return "$first.$second.$third.$fourth";
> }
>
|