May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

Categories

May 2024
M T W T F S S
 12345
6789101112
13141516171819
20212223242526
2728293031  

shell to get the process usage in MB

#!/bin/bash
ps -A -o pid,rss,command | grep nginx | grep -v grep | awk ‘{total+=$2}END{printf(“nginx=%dMb\n”, total/1024)}’
ps -A -o pid,rss,command | grep php-fpm | grep -v grep | awk ‘{total+=$2}END{printf(“php-fpm=%dMb\n”, total/1024)}’
ps -A -o pid,rss,command | grep mysqld | grep -v grep | awk ‘{total+=$2}END{printf(“mysql=%dMb\n”, total/1024)}’
ps -A -o pid,rss,command | grep transmission-da | grep -v grep | awk ‘{total+=$2}END{printf(“transmission=%dMb\n”, total/1024)}’
ps -A -o pid,rss,command | grep fail2ban | grep -v grep | awk ‘{total+=$2}END{printf(“fail2ban=%dMb\n”, total/1024)}’
ps -A -o pid,rss,command | grep sshd | grep -v grep | awk ‘{total+=$2}END{printf(“sshd=%dMb\n”, total/1024)}’

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>