Debian Codegraph @

Externals/watcher/watcher/tool/show/sysres

raw symbols SCIP
1 #! /usr/bin/env bash
2
3 WATCHER_PID=$(pgrep wtr.watcher || echo false)
4 test "$WATCHER_PID" = false && {
5 echo 'watcher not running.'; exit 1; }
6
7 TIME_SPAN=5
8 test $# -eq 1 \
9 && test $1 -gt 0 \
10 && TIME_SPAN=$1
11
12 RESULT="$( \
13 top \
14 -pid $WATCHER_PID \
15 -s $TIME_SPAN \
16 -l 2 \
17 -c a \
18 -stats cpu,mem \
19 | tail -n 1)"
20
21 echo "time span: ${TIME_SPAN}s"
22 echo "$RESULT" | sed -E 's/(.+)( +)(.+)/cpu usage: \1\nmemory usage: \3/g'