Last active
February 1, 2018 20:26
-
-
Save eddy85br/eeb911b176c44641d080 to your computer and use it in GitHub Desktop.
Revisions
-
eddy85br revised this gist
Feb 1, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ ################################################################################ ## Similar to run: ps aux | grep "RegExp" ## ## Script that receives a list o keywords and search then in "ps axw" command ## ## and returns ps's header and processes that where found with keywords. ## ## Accepts grep options, like '-c' to count number of matched processes. ## ################################################################################ -
eddy85br revised this gist
Jan 18, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -49,7 +49,7 @@ else echo " ## Starting Watch ($seconds seconds) ##" while [ 1 ]; do echo -e "\n ## $(date)\n"; ps axw -o ppid,pid,user,%cpu,%mem,vsz,rss,wchan,nlwp,stime,etime,args | grep -v -e $0 -e $$ | egrep $options "(ELAPSED|$words)" --color=auto; sleep $seconds; done fi -
eddy85br revised this gist
Jan 17, 2018 . 1 changed file with 33 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -6,18 +6,30 @@ ## and returns ps's header and processes that where found with keywords. ## ## Accepts grep options, like '-c' to count number of matched processes. ## ################################################################################ if [ "$#" -eq 0 ]; then echo -e "Must inform at least 1 argument.\n Use '-w' for watch and '-c' for count.\n" && exit 1; fi options='' count='' words='' watch='' seconds=1 for arg in "$@"; do if [[ $arg =~ ^- ]]; then if [[ $arg =~ ^-w ]]; then watch=1 if [[ $arg =~ ([0-9]+) ]]; then seconds=${BASH_REMATCH[1]} fi else if [[ $arg =~ ^-c ]]; then count=1 fi options="$options $arg" fi else if [ -z $words ]; then words="$arg" @@ -26,11 +38,20 @@ do fi fi done if [ -z $watch ]; then if [ -z $count ]; then ps axw -o ppid,pid,user,%cpu,%mem,vsz,rss,wchan,nlwp,stime,etime,args | grep -v -e $0 -e $$ | egrep $options "(ELAPSED|$words)" --color=auto else ps axw -o ppid,pid,args | grep -v -e $0 -e $$ | egrep $options "($words)" --color=auto fi else echo " ## Starting Watch ($seconds seconds) ##" while [ 1 ]; do echo -e "\n ## $(date)\n"; ps axw -o ppid,pid,args,%cpu,%mem,vsz,rss,wchan,nlwp,stime,etime,args | grep -v -e $0 -e $$ | egrep $options "(ELAPSED|$words)" --color=auto; sleep $seconds; done fi exit 0; -
eddy85br revised this gist
Aug 7, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -9,6 +9,7 @@ options='' words='' if [ "$#" -eq 0 ]; then echo "Must inform at least 1 argument" && exit 1; fi -
eddy85br revised this gist
Aug 7, 2015 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,10 @@ options='' words='' if [ "$#" -eq 0 ]; then echo "Must inform at least 1 argument" && exit 1; fi for arg in "$@" do if [[ $arg =~ ^- ]]; then -
eddy85br revised this gist
Apr 17, 2015 . 1 changed file with 0 additions and 27 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,27 +0,0 @@ -
eddy85br created this gist
Apr 17, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ #!/bin/bash ################################################################################ ## Similar to run: ps aux | grep "RegExp" ## ## Script that receives a list o keywords and search then in "ps aux" command ## ## and returns ps's header and processes that where found with keywords. ## ## Accepts grep options, like '-c' to count number of matched processes. ## ################################################################################ options='' words='' for arg in "$@" do if [[ $arg =~ ^- ]]; then options="$options $arg" else if [ -z $words ]; then words="$arg" else words="$words|$arg" fi fi done if [ -z $options ]; then ps axw -o ppid,pid,user,%cpu,%mem,vsz,rss,wchan,nlwp,stime,etime,args | grep -v -e $0 -e $$ | egrep "(ELAPSED|$words)" --color=auto else ps axw -o ppid,pid,args | grep -v -e $0 -e $$ | egrep $options "($words)" --color=auto fi exit 0; This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ #!/bin/bash # Get current swap usage for all running processes # Erik Ljungstrom 27/05/2011 # ## Adapted by Jhonatan Piffer Siqueira and Eduardo Lemons Francisco (eddy85br). OVERALL=0 PROGLIST=$(ps axw -o pid,args --no-headers) while read PID ARGS; do SUM=0 if [ -f "/proc/$PID/smaps" ]; then for SWAP in $(fgrep 'Swap' /proc/$PID/smaps 2>/dev/null | awk '{ print $2 }') ; do let SUM=$SUM+$SWAP done fi if [[ $SUM > 0 ]]; then printf "PID: %-6s | Swap used: %-6s KB => %s\n" $PID $SUM "$ARGS" else printf "Not using Swap, PID: %-6s => %s\n" $PID "$ARGS" 1>/dev/stderr fi let OVERALL=$OVERALL+$SUM done <<<"$PROGLIST" echo "Overall swap used: $OVERALL" exit 0;