# get pid
ps -ax|grep netxms
# run gdb with one argument -- path to binary
gdb /opt/netxms/bin/netxmsd
# IN GDB! (prompt will be like '(gbd)')
# attach to running process (e.g. 12345 -- pid from step 1)
attach 12345
# get information about threads
info threads
# do smth on thread '<threadId>' (number from info threads)
thread apply <threadId> backtrace
# proceed with next thread...
attached script can do this routine procedure for you:
change $nxBIN to your path and then run it:
./getState.pl PID > state.log
and then: Mail -s "app state (`date +%D`)" netxms-dev_at_alk.lv < state.log
wbr, alex.
p.s. script checked on GNU gdb 4.18 (FreeBSD)
-- Alexander Kirhenshtein C.T.Co Cellular: +371-9145688
#!/usr/bin/perl -w
use FileHandle;
use IPC::Open2;
############################################
my $nxPID = $ARGV[0];
my $nxBIN = "/tmp/nx/bin/netxmsd";
############################################
$| = 1;
my $pid = open2(*Reader, *Writer, "gdb $nxBIN 2>/dev/null")
|| die "open2 failed: $!";
while (my $got = <Reader>)
{
if ($got =~ /This GDB was configured as/)
{
last;
}
}
print Writer "attach $nxPID\n";
while (my $got = <Reader>)
{
if ($got =~ /^0x[0-9a-zA-Z]+ in/)
{
last;
}
}
my $threads = 0;
print Writer "info thread\n";
while (my $got = <Reader>)
{
if ($got =~ /process [0-9]+, thread [0-9]/)
{
$threads++;
}
if ($got =~ /^\*/)
{
last;
}
}
print "$threads threads\n";
for (; $threads > 0; $threads--)
{
print Writer "thread apply $threads bt\n";
}
print Writer "detach\n";
print Writer "kill\ny\n"; # JIC
print Writer "quit\n";
while (my $got = <Reader>)
{
print "$got";
}
Received on Mon Feb 28 2005 - 12:31:45 EET
This archive was generated by hypermail 2.2.0 : Mon Aug 01 2005 - 00:43:28 EEST