On 06/06/03 22:49 +0200, Luca Deri wrote:
> Devdas,
> please mail me the script you're using for crashing ntop and I'll see
> what I can do.
Sending info inline.
gdb on a stalled process (attached gdb to the pid reported by ps):
=============================================================================
0x420b4c37 in pause () from /lib/i686/libc.so.6
(gdb) bt
#0 0x420b4c37 in pause () from /lib/i686/libc.so.6
#1 0x403bbaa3 in pause () from /lib/i686/libpthread.so.0
#2 0x0804bd25 in main ()
#3 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6
gdb) bt full
#0 0x420b4c37 in pause () from /lib/i686/libc.so.6
No symbol table info available.
#1 0x403bbaa3 in pause () from /lib/i686/libpthread.so.0
No symbol table info available.
#2 0x0804bd25 in main ()
No symbol table info available.
#3 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6
No symbol table info available.
=============================================================================
On the offending pid as seen from /var/log/messages:
==============================================================================
(gdb) bt
#0 0x420293d5 in sigsuspend () from /lib/i686/libc.so.6
#1 0x403b9609 in __pthread_wait_for_restart_signal ()
from /lib/i686/libpthread.so.0
#2 0x403bb449 in __pthread_alt_lock () from /lib/i686/libpthread.so.0
#3 0x403b80d6 in pthread_mutex_lock () from /lib/i686/libpthread.so.0
#4 0x420e456e in closelog () from /lib/i686/libc.so.6
#5 0x401048c9 in traceEvent (eventTraceLevel=3, file=0x40111f70
"ntop.c",
line=34,
format=0x401121a0 "%s is %s (last lock %s:%d) [max lock time %s:%d
(%d sec)]") at util.c:2167
#6 0x400ee808 in printMutexInfo (mutexId=0x4011b118,
mutexName=0x40111fba "myGlobals.hostsHashMutex") at ntop.c:34
#7 0x400ee8d2 in handleSigHup (signalId=1) at ntop.c:61
#8 0x403b9f05 in pthread_sighandler () from /lib/i686/libpthread.so.0
#9 <signal handler called>
#10 0x420293d5 in sigsuspend () from /lib/i686/libc.so.6
#11 0x403b9609 in __pthread_wait_for_restart_signal ()
from /lib/i686/libpthread.so.0
#12 0x403ba72c in sem_wait@@GLIBC_2.1 () from /lib/i686/libpthread.so.0
#13 0x401030b8 in waitSem (semId=0x4011af6c) at util.c:1344
#14 0x400f4925 in dequeuePacket (notUsed=0x0) at pbuf.c:1610
#15 0x403b6faf in pthread_start_thread () from /lib/i686/libpthread.so.0
(gdb)
#0 0x420293d5 in sigsuspend () from /lib/i686/libc.so.6
No symbol table info available.
#1 0x403b9609 in __pthread_wait_for_restart_signal ()
from /lib/i686/libpthread.so.0
No symbol table info available.
#2 0x403bb449 in __pthread_alt_lock () from /lib/i686/libpthread.so.0
No symbol table info available.
#3 0x403b80d6 in pthread_mutex_lock () from /lib/i686/libpthread.so.0
No symbol table info available.
#4 0x420e456e in closelog () from /lib/i686/libc.so.6
No symbol table info available.
#5 0x401048c9 in traceEvent (eventTraceLevel=3, file=0x40111f70
"ntop.c",
line=34,
format=0x401121a0 "%s is %s (last lock %s:%d) [max lock time %s:%d
(%d sec)]") at util.c:2167
theDate = '\0' <repeats 31 times>
buf = "myGlobals.hostsHashMutex is unlocked (last lock pbuf.c:0)
[max lock time pbuf.c:2584 (0 sec)]", '\0' <repeats 930 times>
theTime = 1054932301
t = {tm_sec = 0, tm_min = 0, tm_hour = 0, tm_mday = 0, tm_mon =
0,
tm_year = 0, tm_wday = 0, tm_yday = 0, tm_isdst = 0, tm_gmtoff = 0,
tm_zone = 0x0}
beginFileIdx = 1074863984
mFile = 0x0
#6 0x400ee808 in printMutexInfo (mutexId=0x4011b118,
mutexName=0x40111fba "myGlobals.hostsHashMutex") at ntop.c:34
mutexId = (PthreadMutex *) 0xfffffffc
#7 0x400ee8d2 in handleSigHup (signalId=1) at ntop.c:61
No locals.
#8 0x403b9f05 in pthread_sighandler () from /lib/i686/libpthread.so.0
No symbol table info available.
#9 <signal handler called>
No symbol table info available.
#10 0x420293d5 in sigsuspend () from /lib/i686/libc.so.6
No symbol table info available.
#11 0x403b9609 in __pthread_wait_for_restart_signal ()
from /lib/i686/libpthread.so.0
No symbol table info available.
#12 0x403ba72c in sem_wait@@GLIBC_2.1 () from /lib/i686/libpthread.so.0
No symbol table info available.
#13 0x401030b8 in waitSem (semId=0x4011af6c) at util.c:1344
rc = -4
#14 0x400f4925 in dequeuePacket (notUsed=0x0) at pbuf.c:1610
pktInfo = {deviceId = 0, h = {ts = {tv_sec = 0, tv_usec = 0},
caplen = 0, len = 0}, p = '\0' <repeats 768 times>}
deviceId = 44544
h = {ts = {tv_sec = 0, tv_usec = 0}, caplen = 0, len = 0}
p = '\0' <repeats 8231 times>
#15 0x403b6faf in pthread_start_thread () from /lib/i686/libpthread.so.0
No symbol table info available.
=============================================================================
The script, passwords and usernames removed:
#!/usr/bin/perl -w
use strict;
use LWP::Simple;
use DBI;
my $dbname = "";
my $dbuser = "";
my $dbpass = "";
my $dbh = db_connect();
my $ntopdata = process_ntop_data();
db_insert($dbh,$ntopdata);
db_disconnect($dbh);
sub get_ntop_data
{
my $ntophost="localhost";
my $ntopport = `grep http-server /etc/ntop.conf|grep -v "#"` ||
"3000";
my $url =
"http://$ntophost:$ntopport/dumpData.html?language=perl";
my $content = get($url);
if ($content eq "") { die "Could not get content $!" };
\$content;
}
sub process_ntop_data
{
#This is the hash from ntop
my %ntopHash = ();
#Evaluate the hash from the URL
my %traffic = eval(${&get_ntop_data});
my %data = ();
# foreach my $ip (keys %traffic)
my $ip = "202.88.170.34"; #Hardcoded for now
if (($ip ne "broadcast") and ($ip !~ /(..:){5}/))
{
my %hash = %{$traffic{$ip}};
$data{$ip}{'rcvd'} = $hash{'ipBytesRcvd'};
$data{$ip}{'sent'} = $hash{'ipBytesSent'};
}
# }
`killall -HUP ntop`;
\%data;
}
sub db_connect
{
my $dbh =
DBI->connect("dbi:Pg:dbname=$dbname;host=localhost;port=5432","$dbuser","$dbpass",
{ RaiseError => 1, PrintError => 1, AutoCommit => 0 })
or die "Could not connect to database";
return $dbh;
}
sub db_disconnect
{
my $dbh = shift;
$dbh->disconnect or warn $dbh->errstr;
}
sub db_insert
{
my ($dbh, $dataref) = @_;
my ($ip, $rcvdbytes, $sentbytes);
my %data = %$dataref;
my $sql = "INSERT INTO records(ip, download_bytes, upload_bytes)
VALUES
(?,?,?)";
my $sth = $dbh->prepare($sql);
#$dbh->begin_work or die $dbh->errstr;
eval
{
foreach $ip (keys %data)
{
$rcvdbytes = $data{$ip}{'rcvd'};
$sentbytes = $data{$ip}{'sent'};
$sth->bind_param(1,$ip);
$sth->bind_param(2,$rcvdbytes);
$sth->bind_param(3,$sentbytes);
$sth->execute;
}
};
if ($@)
{
$dbh->rollback;
}
else
{
$dbh->commit;
}
}
===========================================================================
I hope this helps.
Devdas Bhagat
_______________________________________________
Ntop mailing list
[EMAIL PROTECTED]
http://listgateway.unipi.it/mailman/listinfo/ntop