服务器上奇怪的进程消耗CPU

我注意到当前处于离线状态的服务器上有15%的CPU负载。 它通过TCP挂载了GlusterFS卷。 通过顶部看,它显示我glusterfs。 之后,我试图找出究竟是什么使用它,我得到了这个:

# lsof /storage/ COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME find 16433 nobody cwd DIR 0,19 8192 9259265867489333824 /storage/200000/200000/200700/200704/08 

然后:

 # ps uax | grep find root 16415 0.0 0.0 4400 724 ? SN 06:34 0:00 /bin/sh /usr/bin/updatedb.findutils root 16423 0.0 0.0 4400 336 ? SN 06:34 0:00 /bin/sh /usr/bin/updatedb.findutils nobody 16431 0.0 0.0 39524 1376 ? SN 06:34 0:00 su nobody -s /bin/sh -c /usr/bin/find / -ignore_readdir_race \( -fstype NFS -o -fstype nfs -o -fstype nfs4 -o -fstype afs -o -fstype binfmt_misc -o -fstype proc -o -fstype smbfs -o -fstype autofs -o -fstype iso9660 -o -fstype ncpfs -o -fstype coda -o -fstype devpts -o -fstype ftpfs -o -fstype devfs -o -fstype mfs -o -fstype shfs -o -fstype sysfs -o -fstype cifs -o -fstype lustre_lite -o -fstype tmpfs -o -fstype usbfs -o -fstype udf -o -fstype ocfs2 -o -type d -regex '\(^/tmp$\)\|\(^/usr/tmp$\)\|\(^/var/tmp$\)\|\(^/afs$\)\|\(^/amd$\)\|\(^/alex$\)\|\(^/var/spool$\)\|\(^/sfs$\)\|\(^/media$\)\|\(^/var/lib/schroot/mount$\)' \) -prune -o -print0 nobody 16432 0.0 0.0 4400 616 ? SN 06:34 0:00 sh -c /usr/bin/find / -ignore_readdir_race \( -fstype NFS -o -fstype nfs -o -fstype nfs4 -o -fstype afs -o -fstype binfmt_misc -o -fstype proc -o -fstype smbfs -o -fstype autofs -o -fstype iso9660 -o -fstype ncpfs -o -fstype coda -o -fstype devpts -o -fstype ftpfs -o -fstype devfs -o -fstype mfs -o -fstype shfs -o -fstype sysfs -o -fstype cifs -o -fstype lustre_lite -o -fstype tmpfs -o -fstype usbfs -o -fstype udf -o -fstype ocfs2 -o -type d -regex '\(^/tmp$\)\|\(^/usr/tmp$\)\|\(^/var/tmp$\)\|\(^/afs$\)\|\(^/amd$\)\|\(^/alex$\)\|\(^/var/spool$\)\|\(^/sfs$\)\|\(^/media$\)\|\(^/var/lib/schroot/mount$\)' \) -prune -o -print0 nobody 16433 0.3 0.0 13612 1532 ? SN 06:34 0:38 /usr/bin/find / -ignore_readdir_race ( -fstype NFS -o -fstype nfs -o -fstype nfs4 -o -fstype afs -o -fstype binfmt_misc -o -fstype proc -o -fstype smbfs -o -fstype autofs -o -fstype iso9660 -o -fstype ncpfs -o -fstype coda -o -fstype devpts -o -fstype ftpfs -o -fstype devfs -o -fstype mfs -o -fstype shfs -o -fstype sysfs -o -fstype cifs -o -fstype lustre_lite -o -fstype tmpfs -o -fstype usbfs -o -fstype udf -o -fstype ocfs2 -o -type d -regex \(^/tmp$\)\|\(^/usr/tmp$\)\|\(^/var/tmp$\)\|\(^/afs$\)\|\(^/amd$\)\|\(^/alex$\)\|\(^/var/spool$\)\|\(^/sfs$\)\|\(^/media$\)\|\(^/var/lib/schroot/mount$\) ) -prune -o -print0 

我杀了16432和16433,现在CPU又是%0了。

有人可以告诉我关于这些丑陋的查找命令吗? 是否有可能是由其他服务器,也有这个/存储挂载?

根据监测,它每天都在同一时间发生。

这看起来像是运行更新locate命令使用的数据库的每日updatedb作业的一部分。

你可能会在/etc/cron.dailyfindmlocate或类似的东西。

如果你使用ps -ef你可以得到PID(进程)和PPID(父PID),可以用来追踪。 你可能会看到你杀死的进程PPID为16415,16423。

像pstree这样的工具也适用于这种事情。

 pstree -p -H5295 

给出这样的输出

  |-sshd(5291)---sshd(5294)---bash(5295)-+-more(6098) | `-pstree(6097) 

正如Iain指出的那样,它几乎肯定会被更新updatedb(8)updatedb试图真的很难只索引您的本地文件系统。 在我的机器上,它仅通过包含 HFS和UFStypes的文件系统来完成。 在你的机器上,这是通过特别排除 NFS,AFS,SMB等各种文件系统types来完成的。

你已经注意到排除方法的问题是,当有人创build一个新的networking文件系统types – 例如GlusterFS时,需要修改updatedb以排除该types的文件系统。

对我来说, updatedb是一个shell脚本,所以我可以平凡地改变文件系统types。 我怀疑你的系统也是如此。 假设GlusterFS是glusterfstypes的,你可以添加另一个testing:

 -fstype glusterfs 

在其他文件系统types的testing行,并愉快地在你的路上。

或者,当然,如果您从不使用locate(1)命令,则可以完全closuresupdatedb