moved tools directory; added threadid column to logfile splitter

sayer/1.4-spce2.6
Stefan Sayer 16 years ago
parent 18a7933986
commit a59c88275b

@ -8,7 +8,7 @@ all: modules
COREPATH=core
include Makefile.defs
subdirs = core apps
subdirs = core apps tools
.PHONY: clean
clean:

@ -3,7 +3,6 @@ LIBNAME=sems.so
PLUGIN_DIR=plug-in
SIP_STACK_DIR=sip
TOOLS_DIR=tools
SRCS=$(filter-out $(NAME).cpp, $(wildcard *.cpp))
HDRS=$(SRCS:.cpp=.h)
@ -17,8 +16,7 @@ all: ../Makefile.defs
-@$(MAKE) sip_stack && \
$(MAKE) deps && \
$(MAKE) $(NAME) && \
$(MAKE) modules && \
$(MAKE) tools
$(MAKE) modules
.PHONY: clean
clean:
@ -26,7 +24,6 @@ clean:
rm -f lib/*.so compat/getos compat/getarch
$(MAKE) -C $(SIP_STACK_DIR) clean
$(MAKE) -C $(PLUGIN_DIR) clean
$(MAKE) -C $(TOOLS_DIR) clean
.PHONY: sip_stack
sip_stack:
@ -40,12 +37,6 @@ modules:
-@echo "making core modules"
-@cd $(PLUGIN_DIR); $(MAKE) modules
.PHONY: tools
tools:
-@echo ""
-@echo "making tools"
-@cd $(TOOLS_DIR); $(MAKE) all
.PHONY: test
test:
-@echo ""
@ -82,9 +73,7 @@ install: all mk-install-dirs \
install-modules-cfg \
install-cfg \
install-bin \
install-modules \
install-tools
install-modules
# note: on solaris 8 sed: ? or \(...\)* (a.s.o) do not work
@ -108,9 +97,6 @@ install-bin: $(DESTDIR)$(bin-prefix)/$(bin-dir)
install-modules: $(PLUGIN_DIR) $(DESTDIR)$(modules-prefix)/$(modules-dir)
$(MAKE) -C $(PLUGIN_DIR) install
install-tools: $(TOOLS_DIR)
$(MAKE) -C $(TOOLS_DIR) install
install-modules-cfg: $(PLUGIN_DIR)
$(MAKE) -C $(PLUGIN_DIR) install-cfg

@ -1,6 +1,6 @@
all: make_tools
COREPATH ?= ../
COREPATH ?= ../core
include $(COREPATH)/../Makefile.defs
sems-tools = sems-logfile-callextract

@ -5,6 +5,11 @@ using namespace std;
#include <vector>
#include <algorithm>
#include <map>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <limits.h>
std::vector<string> explode(const string& s, const string& delim,
const bool keep_empty = false);
@ -15,11 +20,29 @@ using namespace std;
int main(int argc, char *argv[])
{
if (argc<3) {
cout << "usage: " << argv[0] << " infile callid" << endl;
if (argc<4) {
cerr << "usage: " << argv[0] << " <infile> <callid> <threadid_position>" << endl;
cerr << " where <infile> is the log file to process" << endl;
cerr << " <callid> the Call-ID to extract" << endl;
cerr << " <threadid_position> the column of the thread ID in the "
"log, starting with 0 (i.e. number of spaces before the thread ID)" << endl;
exit(1);
}
int log_offset = -1;
char* endptr;
log_offset = strtol(argv[3], &endptr, 10); // offset of thread
if ((errno == ERANGE && (log_offset == LONG_MAX || log_offset == LONG_MIN))
|| (errno != 0 && log_offset == 0) || endptr == argv[3] || log_offset<0) {
cerr << "invalid thread column ID " << argv[3] << endl;
exit(1);
}
if (log_offset<0) {
}
ifstream f;
string fname = argv[1];
@ -30,6 +53,8 @@ int main(int argc, char *argv[])
exit(1);
}
string app_thread;
string ltag;
@ -43,16 +68,15 @@ int main(int argc, char *argv[])
vector<string> v = explode(s, " ");
unsigned log_offset = 5; // offset of thread
if (v.size() < log_offset+1)
if (v.size() < (unsigned)log_offset+1)
continue;
string t = v[log_offset + 0]; // thread
string delim;
if (v.size() > log_offset + 4)
if (v.size() > (unsigned)log_offset + 4)
delim = v[log_offset + 4]; // vv or ^^
string ptype;
if (v.size() > log_offset + 5)
if (v.size() > (unsigned)log_offset + 5)
ptype = v[log_offset + 5]; // M or S
// cout << "thread " << t << " delim " << delim << " ptype " << ptype << endl;
@ -65,7 +89,7 @@ int main(int argc, char *argv[])
} else if (ptype == "S") { // app processing
#define GET_CALL_IDENT \
string call_ident; \
if (v.size() > log_offset + 6) \
if (v.size() > (unsigned)log_offset + 6) \
call_ident = v[log_offset + 6]; \
call_ident = call_ident.substr(1, call_ident.length()-2); \
vector<string> ci_parts = explode(call_ident, "|", true); \
Loading…
Cancel
Save