I did this once.
I did:
exec("ps -elf | egrep ftpd",$tet);
for($l=0;$l<count($tet);$l++){
if(!eregi("egrep",$tet[$l]) && !eregi("accepting connections",$tet[$l])){
$user[]=$tet[$l];
$c++;
}
}
echo "There are $c ftp users.";
And an array $user would have all users names signed in.
I used this with slackware and redhat, using proftpd.