Module: sems Branch: master Commit: a59c88275b7665749348d7bf8933e1f2db5e8af3 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=a59c88275b7665749348d7bf8933e1f2db5e8af3
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Wed Feb 23 11:19:32 2011 +0100 moved tools directory; added threadid column to logfile splitter --- Makefile | 2 +- core/Makefile | 18 +----------- {core/tools => tools}/Makefile | 2 +- {core/tools => tools}/logfile-splitter.cpp | 38 ++++++++++++++++++++++----- 4 files changed, 35 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index ac9e23e..1d02340 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ all: modules COREPATH=core include Makefile.defs -subdirs = core apps +subdirs = core apps tools .PHONY: clean clean: diff --git a/core/Makefile b/core/Makefile index 6adf1b9..21bd7af 100644 --- a/core/Makefile +++ b/core/Makefile @@ -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 diff --git a/core/tools/Makefile b/tools/Makefile similarity index 87% rename from core/tools/Makefile rename to tools/Makefile index 4c2a39d..549be23 100644 --- a/core/tools/Makefile +++ b/tools/Makefile @@ -1,6 +1,6 @@ all: make_tools -COREPATH ?= ../ +COREPATH ?= ../core include $(COREPATH)/../Makefile.defs sems-tools = sems-logfile-callextract diff --git a/core/tools/logfile-splitter.cpp b/tools/logfile-splitter.cpp similarity index 77% rename from core/tools/logfile-splitter.cpp rename to tools/logfile-splitter.cpp index 55525b4..7cafacd 100644 --- a/core/tools/logfile-splitter.cpp +++ b/tools/logfile-splitter.cpp @@ -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); \ _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
