DXSpider Tracing Debug Entries
General Information
DXSpider has the ability to log information at various levels, and those levels are set using the debug tool in conjunction with the debug levels. Whilst this information is captured in the data files of ../spider/local_data/debug/ it can also be seen in realtime from the command line prompt. Once the debug levels are set the 'watchdbg' tool can be used from ../spider/perl/ to watch the cluster's full data stream. This can be a very busy stream but it can be filtered for easier scrutiny.
This guide assumes that 'watchdbg' has been linked to /usr/local/bin. If not, you can run this command in Linux:
sudo ln -s /spider/perl/*dbg /usr/local/bin
This will command will link all dbg subroutines in /spider/perl to /usr/local/bin so they can be accessed from the user prompt like any other built in command.
watchdbg
- watchdbg [-nnn lines before] [!<regexp>|<regexp>]...
You can have more than one <regexp> with an implicit 'and' between them. All <regexes> are caseless. It's recommended to put 'not' (!<regex>) first in any list. Don't forget that you are doing this in a shell and you may need to quote your <regex>s.
grepdbg
- grepdbg [nn days before] [-nnn lines before] [<perl filter module>] [<regexp>|!<regexp>]...
You can have more than one <regexp> with an implicit 'and' between them. All <regexes> are caseless. It's recommended to put 'not' (!<regex>) first in any list. Don't forget that you are doing this in a shell and you may need to quote your <regex>s. 'grepdbg' with no arguments will simply list the current debug log with the timestamp for each line decoded into a human readable form.
grepdbg | less
is a handy way of scrolling through the debug log.
grepdbg -2 progress
will display any line containing 'progress' and also the two lines before that. You can install your own content and display arrangement (useful for filtering data in some complicated way). You call it like this (assuming it is called 'filter.pm').
This is what is meant by <perl filter module>.
grepdbg filter.pm
All the other arguments to grepdbg are available to limit the input to your filter. If you want them. The filter module MUST contain at least:
package main;
sub handle
{
your code goes here
}
1;
It can also have a 'sub begin {...}' and / or 'sub end {...}' which are executed immediately after opening a logfile and then just before closing it, respectively. You can also add a 'sub total {...}' which executes after the last line is printed and grepdbg exits. Read the code of this program and copy'n'paste the 'sub process' code into a new file. Then change 'sub process' to 'sub handle'. Add the line 'package main;' at the beginning of the file and a line '1;' at the end and then modify it to your requirements...
Filtering traces
Regexes can be debug levels, nodes, or even a strings of text. See Wikipedia for a basic regex explanation. Regex101 is a good place to practice.
To trace incoming messages the I is used, and for outbound the D is used:
'<- I' or ' I '
'-> D' or ' D '
Protocols can be traced by using the PC number:
'PC9[23]'
In this example we're using '[23]' to express a range of possibilities. This results in PC92 and PC93 being hits for the filter.
Debug levels can be traced using the level name:
"chan|progress"
This regex will hit on any debug entry with the level label of "chan" or "progress".
Trace examples
To watch all outbound spots from this node:
watchdbg ' D ' 'PC[16]1'
or to watch everything outbound:
watchdbg '\-> D' or watchdbg ' D '
The same can be done for inbound traffic:
watchdbg '<\- I' or watchdbg ' I '
or two watch all inbound PC92 frames:
watchdbg ' I ' 'PC92'
Note: the hyphen needs to be escaped with the " \ " character. The spaces between ' D ' are important, make sure they are included.
Saving to a file
It is possible to save the output of these commands to a specific file by using the redirection operator " > " or " >> "in Linux. The " > " will overwrite a file and " >> " will append to a file. Both operators will create a file if it does not exist. Ex:
watchdbg ' D ' 'PC[16]1' >> trace.txt
This command will create the file 'trace.txt' and redirect the output of the command to the file. This will need to be stopped with the key combination of Ctrl + C. If we run the same command again:
watchdbg ' D ' 'PC[16]1' >> trace.txt
it will append the output to the existing file, but if we run:
watchdbg ' D ' 'PC[16]1' > trace.txt
it will clobber (wipe out the contents of) the existing file and then start to output data to the file.