[Netpass-devel] NetPass/bin interfacecfg.pl,1.11,1.12
Brought to you by:
jeffmurphy
From: jeff m. <jef...@us...> - 2005-08-04 06:45:45
|
Update of /cvsroot/netpass/NetPass/bin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9864/bin Modified Files: interfacecfg.pl Log Message: installation fixes Index: interfacecfg.pl =================================================================== RCS file: /cvsroot/netpass/NetPass/bin/interfacecfg.pl,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- interfacecfg.pl 16 May 2005 16:10:42 -0000 1.11 +++ interfacecfg.pl 4 Aug 2005 06:45:24 -0000 1.12 @@ -60,6 +60,7 @@ sub getIps($); sub director($); sub realserver($); +sub getmem(); my %opts; my %ifaces; @@ -207,7 +208,7 @@ printf("echo \"\t\t\t\tldirectord\" >> %s\n\n", $HARESOURCES); - print <<END + print <<END2 # set ip_forward OFF for vs-dr director (1 on, 0 off) cat /proc/sys/net/ipv4/ip_forward echo "0" >/proc/sys/net/ipv4/ip_forward @@ -221,6 +222,25 @@ echo "1" >/proc/sys/net/ipv4/conf/eth0/send_redirects cat /proc/sys/net/ipv4/conf/eth0/send_redirects +#echo 1048576 > /proc/sys/net/ipv4/netfilter/ip_conntrack_max # 512 MB +#echo 2097152 > /proc/sys/net/ipv4/netfilter/ip_conntrack_max # 1024 MB +#echo 4194304 > /proc/sys/net/ipv4/netfilter/ip_conntrack_max # 2048 MB + +END2 + ; + my $memsize = getmem(); + print "# getmem says we have at least $memsize MB in the local machine\n"; + if ($memsize == 2048) { + print "echo 4194304 > /proc/sys/net/ipv4/netfilter/ip_conntrack_max # 2048 MB\n"; + } + elsif ($memsize == 1024) { + print "echo 2097152 > /proc/sys/net/ipv4/netfilter/ip_conntrack_max # 1024 MB\n"; + } + else { + print "echo 1048576 > /proc/sys/net/ipv4/netfilter/ip_conntrack_max # 512 MB\n"; + } + + print <<END # start heartbeat /etc/init.d/heartbeat stop /etc/init.d/heartbeat start @@ -329,3 +349,20 @@ int2ip($m), int2ip($b)); } + +sub getmem() { + open(FD, "/proc/meminfo") || return 512; + my $ms = 0; + while(my $l = <FD>) { + if ($l =~ /^MemTotal:\s*(\d+)/) { + $ms = $1; + last; + } + } + close(FD); + $ms /= 1024; + return 2048 if ($ms > 2048); + return 1024 if ($ms > 1024); + return 512; +} + |