CONTRIB: crash_samba
Francesc Guasch
frankie at etsetb.upc.es
Mon Jul 12 15:05:49 GMT 1999
I just wrote this little script that makes concurrent
connections to a samba or NT server.
It connects to a service and does a dir.
This may be useful if you want to check the resources
of your server.
Configure it changing the vars at the begining.
In my tests I compared two computers, NT vs samba-2.0.3
NT was much faster. 50 concurrent connections, 10 commands issued.
NT-4.0 SP4 Ppro 166 , 256 MB RAM
elapsed: 0:6.7
Linux-2.0.6 Pentium II 300, 128 MB RAM
elapsed 0:31.8
#!/usr/bin/perl -w
###########################################################################
# crash_samba.pl
# it comes with no warranty, no support, it could blow away your system
# use at your own risk
# author: frankie at etsetb.upc.es
use strict;
my $CONCURRENT=20;
my $COMMANDS=10;
my $HOST="localhost";
my $SERVICE="soft";
my $USER="frankie";
my $PASSWORD="";
my $SMBCLIENT=
"/usr/local/samba/bin/smbclient \\\\\\\\$HOST\\\\$SERVICE $PASSWORD
-U$USER>/dev/null";
$|=1;
my @pid=();
my $pid;
$SIG{CHLD}=sub {wait };
foreach (1..$CONCURRENT) {
unless ($pid = fork) {
open CLIENT ,"|$SMBCLIENT" or die $!;
foreach (1..$COMMANDS) {
print CLIENT "dir\n";
}
print CLIENT "quit\n";
close CLIENT;
exit 0;
}
push @pid,($pid);
}
foreach (@pid) {
print "wating for $_ ...";
waitpid ($_,0);
print "returned $_\n";
}
#
#########################################################################
I wrote a second one that tells you how is the load
and memory. It may not work in another OSes that are
not linux , but it's small and should be easy to port.
It works reading uptime and the second line of /proc/meminfo
total: used: free: shared: buffers: cached:
Mem: 131448832 127242240 4206592 22233088 14864384 62238720
I guess the real used memory is:
used_mem=total-free-buffers-cached
#!/usr/bin/perl -w
# it comes with no warranty, no support, it could blow away your system
# use at your own risk
# author: frankie at etsetb.upc.es
use strict;
while (1) {
my ($load)=`uptime`=~/age:\s+(\S+),/;
print "$load\t";
open MEM ,"</proc/meminfo" or die $!;
<MEM>;
$_=<MEM>;
my @mem=split;
print $mem[1]-$mem[3]-$mem[5]-$mem[6];
print "\n";
sleep 1;
}
More information about the samba
mailing list