Eu desejo escrever um script que insira informações do sistema de arquivos / proc em uma lista de processos gerados pelo top. Seria algo assim:
Aqui está o exemplo de saída que recebo do topo:
[root@alxc5 ~]# top -n 1 -c | sed '1,7d' | head -n10
20245 1842 20 0 233m 42m 10m R 100.0 0.0 0:00.71 /usr/local/php53/bin/php index.php
19302 1842 20 0 277m 86m 10m R 100.0 0.0 0:01.81 /usr/local/php53/bin/php index.php
20153 1842 20 0 264m 79m 10m R 96.6 0.0 0:00.89 /usr/local/php54/bin/php admin-ajax.php
14390 1842 20 0 228m 43m 10m R 93.6 0.0 0:04.92 /usr/local/php54/bin/php productbrandwithoutsoap.php
20047 1841 20 0 240m 54m 10m R 90.7 0.0 0:01.29 /usr/local/php54/bin/php index.php
20117 1842 20 0 273m 87m 10m R 83.4 0.0 0:01.07 /usr/local/php54/bin/php edit.php
20295 1841 20 0 202m 36m 9m R 80.5 0.0 0:00.55 /usr/local/php53/bin/php index.php
15978 1843 20 0 259m 71m 10m S 58.5 0.0 0:02.70 /usr/local/bin/php /home/groupwa4/public_html/cron.php -mdefault
18745 1842 20 0 247m 56m 11m R 46.8 0.0 0:02.30 /usr/local/bin/php /home/sukhirug/public_html/cron.php -mdefault
10234 1842 20 0 306m 92m 43m R 42.4 0.0 1:14.51 /usr/local/php53/bin/php
[root@alxc5 ~]#
Aqui está o que eu gostaria que o resultado final parecesse:
[root@alxc5 ~]# top -n 1 -c | sed '1,7d' | head -n10
20245 1842 20 0 233m 42m 10m R 100.0 0.0 0:00.71 /usr/local/php53/bin/php index.php
^- Process running in $proc_info
Onde $ proc_info seria algo como:
[root@alxc5 ~]# egrep "c[0-9]{1,5}" /proc/28339/mounts -o |uniq
c8798
[root@alxc5 ~]#
E aqui está o conteúdo original de / proc / 28339 / mounts:
[root@alxc5 ~]# cat /proc/28339/mounts
rootfs / rootfs rw 0 0
/dev/mapper/coregroup-c8798 / ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
/dev/sda3 /proc/loadavg ext4 rw,relatime,data=ordered 0 0
/dev/sda3 /proc/cpuinfo ext4 rw,relatime,data=ordered 0 0
devpts /dev/pts devpts rw,relatime,gid=1342,mode=620,ptmxmode=666 0 0
/dev/mapper/coregroup-c8798 /chroot/tmp ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/baseos/chroot ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/baseos/chroot/tmp ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/admintes ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/admintes/chroot ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/admintes/chroot/tmp ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/admintes/home/admintes ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/dancho ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/dancho/chroot ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/dancho/chroot/tmp ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/dancho/home/dancho ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/sgadmins ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/sgadmins/chroot ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/sgadmins/chroot/tmp ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/sgadmins/home/sgadmins ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/synthesi ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/synthesi/chroot ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/synthesi/chroot/tmp ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
/dev/mapper/coregroup-c8798 /var/suexec/synthesi/home/synthesi ext4 rw,noatime,nodiratime,data=ordered,jqfmt=vfsv0,usrjquota=quota.user 0 0
tmpfs /dev/shm tmpfs rw,relatime,uid=1337,gid=1337 0 0
[root@alxc5 ~]#
Todas as sugestões sobre como proceder com essa tarefa são muito apreciadas!