-
Notifications
You must be signed in to change notification settings - Fork 4
/
vivado-stat-user.sh
executable file
·37 lines (30 loc) · 1.58 KB
/
vivado-stat-user.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
#######################################################################################
## Project : Collect of various scripts for working with EDA-tools (ASIC/FPGA/etc)
## Designer : Dmitry Murzinov ([email protected])
## Link : https://github.com/iDoka/eda-scripts
## Module : Xilinx Vivado CPU and Memory usage statistic
## Description: that prints CPU and Memory usage of current user instances of Vivado
## Usage : refer to vivado-stat.adoc for usage help
## Revision : $Rev
## Date : $LastChangedDate$
## License : MIT
#######################################################################################
CMD="vivado"
PERIOD="3s"
PID=`ps aux | grep $USER | grep ${CMD} | grep lnx64.o | sed 's/\ \{1,\}/\ /g' | cut -d' ' -f2`
while true; do
IS_RUN=`ps -C ${CMD} -o comm= | head -1`
#[ -n ${IS_RUN} ] || break
if [ "${IS_RUN}" == "" ]; then
break
fi
#CPU=`ps -C ${CMD} -o user=,pcpu= | grep $USER | sed 's/\ \{1,\}/\ /g' | cut -d' ' -f2 | sed ':a;N;$!ba;s/\n/\+/g' | bc -l | cut -d. -f1 | sed 's/$/%/'`
#CPU=`top -p ${PID} -n1 | awk '{if (NR==8) print $10 }' | cut -d. -f1 | sed 's/$/%/'`
CPU=`top -p ${PIDS} -n1 | awk '{if (NR>=8) print $10 }' | sed '/^$/d' | sed ':a;N;$!ba;s/\n/\+/g' | bc -l | cut -d. -f1 | sed 's/$/%/'`
MEM=`ps -C ${CMD} -o user=,size= | grep $USER | sed 's/\ \{1,\}/\ /g' | cut -d' ' -f2 | sed 's/$/\/1024/g' | sed ':a;N;$!ba;s/\n/\+/g' | bc -l | cut -d. -f1 | sed 's/$/M/'`
echo -e "$CPU\t$MEM"
sleep ${PERIOD}
done
DATE=`date "+%H:%M %d.%m.%Y"`
echo "*** ${CMD} was finished running at ${DATE} ***"