amuck-landowner

md5 hash of process names

VPSCorey

New Member
Verified Provider
using output of

ps -eo pid,comm

Would like to do a md5sum of comm while keeping associated with it's pid.


ps -eo pid,comm | awk '{
tmp="echo -n "$2" | openssl md5 | cut -f2 -d\" \""
tmp | getline cksum
$2=cksum
print
}'

The problem with this if you have extra crap in the comm column such as <defunct> child, etc.  It screws everything up.

Open to anything that can pipe this output to a program that calls it.  Perl/Python etc.  It's for a bash script.
 

tchen

New Member
ps -eo pid,comm | awk '{
tmp="echo -n "$2" | openssl md5 | cut -f2 -d\" \""
tmp | getline cksum
tmp2=cksum
printf "%d %s\n", $1, tmp2
}'

Basically, try printf

Nifty idea, BTW.
 
Last edited by a moderator:

jarland

The ocean is digital
I've found md5 hash to be a great way to identify abusive processes that usually belong to bitcoin miners and DOS applications, because the new trend seems to be random generated file names. Don't know if that's what you're doing, but if so...great minds think alike :)
 

VPSCorey

New Member
Verified Provider
Seems something eventually causes the output to get offset, for now I've just greped what I want and that does not get shuffled. 
 
Top
amuck-landowner