查看CPU占用最高的PHP进程
ps -aux --sort=-%cpu|head -10|grep php
查看内存占用最高的PHP进程
ps -aux --sort=-%mem|head -10|grep php
统计PHP进程数量和平均CPU使用率
ps -aux|grep php|awk '{cpu+=$3;count++} END {print "PHP进程数:",count,"平均CPU使用率:",cpu/count"%"}'
ps -aux --sort=-%cpu|head -10|grep php
ps -aux --sort=-%mem|head -10|grep php
ps -aux|grep php|awk '{cpu+=$3;count++} END {print "PHP进程数:",count,"平均CPU使用率:",cpu/count"%"}'
public static function getRandNickName()
{
$data = ARandWord::cache(is_test_ab() ? 100 : 86400 * 3)
->field('type,id')
->select();
$rule = ARandWord::NICK_RULE;
$rand_ids = [];
$ids = [];
$rangeData = [];
$size = 3; //生成3个昵称验证去重
foreach ($data as $item) {
$rangeData[$item['type']][] = $item['id'];
}
foreach ($rule as $type) {
$arr = $rangeData[$type];
$id = [];
for ($j = 0;$j<$size;$j++) {
$id[] = $arr[array_rand($arr)];
}
$rand_ids[$type] = $id;
$ids = array_merge($ids, $id);
}
$keyWords = ARandWord::whereIn('id', $ids)->column('name', 'id');
$names = [];
for ($i = 0; $i < $size; $i++) {
$names[] = $keyWords[$rand_ids[1][$i]] . $keyWords[$rand_ids[2][$i]] . '的' . $keyWords[$rand_ids[3][$i]];
}
$db_exit = AMem::where('nickname', 'in', $names)->column('nickname') ?? [];
$last_names = array_diff($names, $db_exit);
if (!empty($last_names)) {
return array_shift($last_names);
} else {
//兜底基本用不上
return '玩家' . StringUtils::getRandomStr('nl', 8);
}
}