From c009cff9a49470ee15f2a9bb76ad5900d1e75233 Mon Sep 17 00:00:00 2001 From: Kun Huang Date: Wed, 4 Nov 2015 23:57:42 +0800 Subject: [PATCH] add rpc count tracer Change-Id: Ied86a60dad36661736a47ac4fa6d42f609582c9d --- scalpels/agents/base.py | 3 +++ scalpels/cli/actions/start.py | 1 + scripts/rpc-count.stp | 14 ++++++++++++++ 3 files changed, 18 insertions(+) create mode 100755 scripts/rpc-count.stp diff --git a/scalpels/agents/base.py b/scalpels/agents/base.py index 376db14..0cb4d75 100644 --- a/scalpels/agents/base.py +++ b/scalpels/agents/base.py @@ -91,3 +91,6 @@ def parse_modelsave(out): def parse_sqlaexec(out): return _parse_count_stream(out, "Sqlalchemy-Execute") + +def parse_rpccount(out): + return _parse_count_stream(out, "RPC-Count") diff --git a/scalpels/cli/actions/start.py b/scalpels/cli/actions/start.py index cfe1641..bd04fd8 100644 --- a/scalpels/cli/actions/start.py +++ b/scalpels/cli/actions/start.py @@ -43,6 +43,7 @@ agents_map = { "oslolock": "stap %s/oslo-lock.stp", # with sudo, need add current user to stapdev group "modelsave": "stap %s/model-save.stp", # with sudo, need add current user to stapdev group "sqlaexec": "stap %s/sqla-exec.stp", # with sudo, need add current user to stapdev group + "rpccount": "stap %s/rpc-count.stp", # with sudo, need add current user to stapdev group } def run(config): diff --git a/scripts/rpc-count.stp b/scripts/rpc-count.stp new file mode 100755 index 0000000..5c475b2 --- /dev/null +++ b/scripts/rpc-count.stp @@ -0,0 +1,14 @@ +#!/usr/bin/stap + +global count = 0; +global old_count = 0; +probe python.function.entry { + if ((funcname == "call" || funcname == "cast") && isinstr(filename, "oslo_messaging/rpc/client.py") ) { + count = count + 1; + } +} +probe timer.ms(1000) { + new_count = count - old_count; + printf("%d\n", new_count); + old_count = count; +}