1. ޸Ĵexternal/toys/posix/ps.c top_commonУ
Լ1489У
sprintf(toybuf,
1487             "Tasks: %d total,%4ld running,%4ld sleeping,%4ld stopped,"
1488             "%4ld zombie", mix.count, run[1], run[2], run[3], run[4]);
1489           lines = header_line(lines, 0);

ǰӴ߼:
{
    struct timespec tm;
    clock_gettime(CLOCK_REALTIME, &tm);
 
    sprintf(toybuf,"# started on %s", ctime(&tm.tv_sec));
    lines = header_line(lines, 0);
}	

ͷļ: <time.h>

toybox ʱ

ʹ͵kbox :
docker exec -i kbox_2 mount -o rw,remount /
docker cp ./toybox kbox_2:/
docker exec -I kbox_2 chmod 777 /toybox
docker exec -i kbox_2 /bin/sh -c "export TOPTS=1;/toybox top -b  -d  1" > top.log


ִк󣬽£
# started on Wed Mar 16 09:13:25 2022

Tasks: 97 total,   1 running,  96 sleeping,   0 stopped,   0 zombie
Mem:   4194304k total,   507656k used,  3686648k free,        0k buffers
Swap:  8388604k total,    51280k used,  8337324k free,        0k cached
200%cpu   4%user   0%nice   0%sys 196%idle   0%iow   0%irq   0%sirq   0%host
  PID USER         PR  NI VIRT  RES  SHR S[%CPU] %MEM     TIME+ ARGS                       
 9036 root         20   0  11M 3.5M 3.0M R  0.0   0.0   0:00.00 toybox top -b -d 2
 9029 root         20   0 8.9M 2.2M 1.8M S  0.0   0.0   0:00.01 sh -c export TOPTS=1;/toybox top -b  -d  2
53509 root         20   0  12M 4.1M 3.4M S  0.0   0.0   0:34.99 toybox top -b -d 2
53502 root         20   0 8.9M 2.2M 1.8M S  0.0   0.0   0:00.00 sh -c export TOPTS=1;/toybox top -b  -d  2
52067 root         20   0  12M 3.9M 3.2M S  0.0   0.0   0:32.97 toybox top -b -d 2
52059 root         20   0 8.9M 2.1M 1.8M S  0.0   0.0   0:00.00 sh -c export TOPTS=1;/toybox top -b  -d  2
50058 root         20   0  12M 3.9M 3.2M S  0.0   0.0   0:33.61 toybox top -b -d 2
50051 root         20   0 8.9M 2.2M 1.8M S  0.0   0.0   0:00.00 sh -c export TOPTS=1;/toybox top -b  -d  2
47561 root         20   0  12M 4.0M 3.3M S  0.0   0.0   0:33.45 toybox top -b -d 2
47554 root         20   0 8.9M 2.2M 1.8M S  0.0   0.0   0:00.01 sh -c export TOPTS=1;/toybox top -b  -d  2
47152 root         20   0  12M 3.9M 3.2M S  0.0   0.0   0:32.81 toybox top -b -d 2
47146 root         20   0 8.9M 2.2M 1.8M S  0.0   0.0   0:00.01 sh -c export TOPTS=1;/toybox top -b  -d  2
45817 root         20   0  12M 3.9M 3.2M S  0.0   0.0   0:32.22 toybox top -b -d 2
45809 root         20   0 8.9M 2.2M 1.8M S  0.0   0.0   0:00.00 sh -c export TOPTS=1;/toybox top -b  -d  2
43871 root         20   0  12M 3.9M 3.2M S  0.0   0.0   0:30.38 toybox top -b -d 2
43864 root         20   0 8.9M 2.3M 1.9M S  0.0   0.0   0:00.00 sh -c export TOPTS=1;/toybox top -b  -d  2
41829 root         20   0  12M 4.0M 3.3M S  0.0   0.0   0:31.69 toybox top -b -d 2
41822 root         20   0 8.9M 2.3M 1.9M S  0.0   0.0   0:00.00 sh -c export TOPTS=1;/toybox top -b  -d  2
23310 root         20   0  12M 3.8M 3.1M S  0.0   0.0   0:31.74 toybox top -b -d 2
23303 root         20   0 8.9M 2.2M 1.8M S  0.0   0.0   0:00.00 sh -c export TOPTS=1;/toybox top -b  -d  2
51101 root         20   0  12M 3.9M 3.2M S  0.0   0.0   1:24.76 toybox top -b -d 1
51095 root         20   0 8.9M 2.1M 1.8M S  0.0   0.0   0:00.00 sh -c export TOPTS=1;/toybox top -b  -d  1
50472 root         20   0  12M 3.9M 3.2M S  0.0   0.0   1:24.55 toybox top -b -d 1
50465 root         20   0 8.9M 2.2M 1.8M S  0.0   0.0   0:00.01 sh -c export TOPTS=1;/toybox top -b  -d  1
50303 root         20   0  12M 4.0M 3.3M S  0.0   0.0   1:21.42 toybox top -b -d 1
50297 root         20   0 8.9M 2.2M 1.8M S  0.0   0.0   0:00.00 sh -c export TOPTS=1;/toybox top -b  -d  1
50122 root         20   0  12M 3.9M 3.1M S  0.0   0.0   1:19.27 toybox top -b -d 1
50115 root         20   0 8.9M 2.2M 1.8M S  0.0   0.0   0:00.00 sh -c export TOPTS=1;/toybox top -b  -d  1 log_top_docker_20220315022916/top_data_kbox_2_20220315022916.txt