Skip to content

Commit

Permalink
eos/collectors: sum up multiple instances of each agent
Browse files Browse the repository at this point in the history
When an agent has multiple processes, aggregate their stats together
upfront to make things easier to graph.  We could also report a break
down per instance but it's hard to tag these properly.  Typically there
would be one per VRF or per Linecard, but we don't really have a generic
way of extracting an appropriate tag, and using the PID as a substitute
isn't really useful because it's impossible in hindsight to graph things
properly as we don't know which pid was used for each instance at any
given point in the past.
  • Loading branch information
tsuna committed Dec 1, 2017
1 parent 126ba5d commit 8a953d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions eos/collectors/agentcpu.sh
Expand Up @@ -44,15 +44,17 @@ ribd

while :; do
for task in $agents; do
usercpu=0
systcpu=0
for pid in `pidof $task`; do
ts=`date +%s`
eval `awk '{print "ppid=" $4 ";usercpu=" $14 "; systcpu=" $15 ";"}' /proc/$pid/stat`
eval `awk '{print "ppid=" $4 ";usercpu=$((usercpu+" $14 ")); systcpu=$((systcpu+" $15 "));"}' /proc/$pid/stat`
if fgrep -q $task /proc/$ppid/stat; then
continue # We are a fork of the agent.
fi
echo "proc.stat.cpu.task $ts $usercpu type=user task=$task"
echo "proc.stat.cpu.task $ts $systcpu type=system task=$task"
done
echo "proc.stat.cpu.task $ts $usercpu type=user task=$task"
echo "proc.stat.cpu.task $ts $systcpu type=system task=$task"
done
sleep 5
done
8 changes: 5 additions & 3 deletions eos/collectors/agentmem.sh
Expand Up @@ -44,15 +44,17 @@ ribd

while :; do
for task in $agents; do
rss=0
vsize=0
for pid in `pidof $task`; do
ts=`date +%s`
eval `awk '{print "ppid=" $4 ";rss=" ($24*4096) "; vsize=" $23 ";"}' /proc/$pid/stat`
eval `awk '{print "ppid=" $4 ";rss=$((rss+" ($24*4096) ")); vsize=$((vsize+" $23 "));"}' /proc/$pid/stat`
if fgrep -q $task /proc/$ppid/stat; then
continue # We are a fork of the agent.
fi
echo "proc.stat.mem.rss $ts $rss task=$task"
echo "proc.stat.mem.vsize $ts $vsize task=$task"
done
echo "proc.stat.mem.rss $ts $rss task=$task"
echo "proc.stat.mem.vsize $ts $vsize task=$task"
done
sleep 5
done

0 comments on commit 8a953d1

Please sign in to comment.