What I am doing is running ps and search for any connection that is over a specified number, I set it to "1" for testing I want to send an email when any of them are over 50 I want them all in one email
Below is the code what I want is to display the output of ps and grepping for "httpd" to a single email what it does now is sends an email for each one
#!/bin/bash
ps aux |grep ftp| grep -v nobody|awk '{$1} {++P[$1]} END {for(a in P) if (a !="USER") print a,P[a]}'| while read line;do
if [ $(echo "$line" | awk '{printf int($2)}') -gt 50 ];then
echo -e $line|mail -s "FTP Connections from Server Greater then 50" <email address>
fi
done