December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Categories

December 2024
M T W T F S S
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

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>