Created
July 27, 2021 23:17
-
-
Save nshores/ef8f209e5368371729f5096998673369 to your computer and use it in GitHub Desktop.
sysmon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#hahriar Shovon | |
#@Github https://github.com/shovon8/sysmon | |
printf "%-10s%-15s%-15s%s\n" "PID" "OWNER" "MEMORY" "COMMAND" | |
function sysmon_main() { | |
RAWIN=$(ps -o pid,user,%mem,command ax | grep -v PID | awk '/[0-9]*/{print $1 ":" $2 ":" $4}') | |
for i in $RAWIN | |
do | |
PID=$(echo $i | cut -d: -f1) | |
OWNER=$(echo $i | cut -d: -f2) | |
COMMAND=$(echo $i | cut -d: -f3) | |
MEMORY=$(pmap $PID | tail -n 1 | awk '/[0-9]K/{print $2}') | |
printf "%-10s%-15s%-15s%s\n" "$PID" "$OWNER" "$MEMORY" "$COMMAND" | |
done | |
} | |
sysmon_main | sort -bnr -k3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment