run singal agent successfully now
This commit is contained in:
parent
3ec61813cf
commit
abbbc744ba
@ -35,10 +35,10 @@ def _parse_agents_from_file(config):
|
||||
# TODO this map should be saved in a config file
|
||||
# TODO refar to pre/exec/post
|
||||
agents_map = {
|
||||
"mysql": "bash /opt/stack/scalpels/scripts/mysql-live.sh",
|
||||
"rabbit": "",
|
||||
"traffic": "",
|
||||
"rpctraffic": "",
|
||||
"mysql": "bash /opt/stack/scalpels/scripts/mysql-live.sh", #XXX doesn't work now, needs works on interapt pipeline
|
||||
"rabbit": "python /opt/stack/scalpels/scripts/rbt-trace.py",
|
||||
"rpc": "bash /opt/stack/scalpels/scripts/port-input-traffic.sh 5672",
|
||||
"traffic": "bash /opt/stack/scalpels/scripts/device-input-traffic.sh eth1",
|
||||
}
|
||||
|
||||
def run(config):
|
||||
@ -51,12 +51,13 @@ def run(config):
|
||||
if ag_exec:
|
||||
ag_p = subprocess.Popen(ag_exec.split(), stdout=subprocess.PIPE)
|
||||
running_agents.append(ag_p)
|
||||
time.sleep(5)
|
||||
time.sleep(15)
|
||||
data = []
|
||||
for ag_p in running_agents:
|
||||
# shell scripts has depend child which can't be killed by subprocess' API
|
||||
# it should be ag_p.kill()
|
||||
os.system("pkill -P %s" % ag_p.pid)
|
||||
#os.system("pkill -P %s" % ag_p.pid)
|
||||
ag_p.send_signal(signal.SIGINT)
|
||||
stdout = ag_p.stdout.read()
|
||||
data.append(stdout)
|
||||
rets = []
|
||||
|
20
scripts/device-input-traffic.sh
Executable file
20
scripts/device-input-traffic.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
# Author: Kun Huang <academicgareth@gmail.com>
|
||||
|
||||
dev=${1:-eth0}
|
||||
|
||||
packages=`cat /sys/class/net/$dev/statistics/rx_packets `
|
||||
bytes=`cat /sys/class/net/$dev/statistics/rx_bytes `
|
||||
|
||||
interval=3
|
||||
|
||||
trap 'break' INT
|
||||
while [ 1 -eq 1 ] ; do
|
||||
sleep $interval
|
||||
n_packages=`cat /sys/class/net/$dev/statistics/rx_packets `
|
||||
n_bytes=`cat /sys/class/net/$dev/statistics/rx_bytes `
|
||||
python -c "print '%0.2f pkt/s' % (float($n_packages-$packages)/int($interval))"
|
||||
python -c "print '%0.2f byte/s' % (float($n_bytes-$bytes)/int($interval))"
|
||||
packages=$n_packages
|
||||
bytes=$n_bytes
|
||||
done
|
@ -3,6 +3,7 @@
|
||||
# Author: Kun Huang <academicgareth@gmail.com>
|
||||
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
from kombu import Connection
|
||||
from kombu import Exchange
|
||||
@ -53,7 +54,8 @@ class Worker(ConsumerMixin):
|
||||
|
||||
with Connection('amqp://guest:guest@localhost:5672//') as conn:
|
||||
try:
|
||||
subprocess.check_call("sudo rabbitmqctl trace_on", shell=True)
|
||||
worker = Worker(conn)
|
||||
worker.run()
|
||||
except KeyboardInterrupt:
|
||||
print debug
|
||||
subprocess.check_call("sudo rabbitmqctl trace_off", shell=True)
|
||||
|
@ -12,5 +12,6 @@
|
||||
{
|
||||
"name": "rpctraffic"
|
||||
}
|
||||
]
|
||||
],
|
||||
"sleep": 5,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user