System Story/CentOS 5,6
Shell - 특정 프로세스 수와 메모리 사용량 합을 구하고 엑셀용 RAW데이터로 활용
helperchoi
2013. 11. 10. 20:43
※ postgresql 프로세스 예시
#!/bin/bash #postgre_mem.sh
MEMSUM=0
PROC_COUNT=`ps -ef | grep -v "grep" | grep "postgre" | wc -l`
LIST_FILE=`ps -ef | grep -v "grep" | grep "postgre" | awk '{print $2}' | while read PID; do cat /proc/$PID/status | egrep 'VmRSS' | awk '{print $2'} ; done`
for LIST in ${LIST_FILE};
do
MEMSUM=`expr $MEMSUM + $LIST`
done
echo -e "PostgreSQL Process is ${PROC_COUNT} \t/ Memory is ${MEMSUM} KByte"
|
반응형