3 ms·
Seems like a very Windows tool. By that I mean it's a full "application" to do what could be done in about 15 lines of shell script: #!/bin/bash set -e p
by Hello71 8y ago
Seems like a very Windows tool. By that I mean it's a full "application" to do what could be done in about 15 lines of shell script:
#!/bin/bash
set -e
pid=$1
if [[ "$pid" = *[^0-9]* ]]; then
pid=$(pgrep -x "$pid")
fi
lasttime=$((2**64))
while sleep 10; do
read pid comm state ppid pgrp session tty_nr tpgid flags minflt cminflt majflt cmajflt utime stime cutime cstime priority nice num_threads itrealvalue starttime vsize rss rsslim startcode endcode startstack kstkesp kstkeip signal blocked sigignore sigcatch wchan nswap cnswap exit_signal processor rt_priority policy delayacct_blkio_ticks guest_time cguest_time start_data end_data start_brk arg_start arg_end env_start env_end exit_code < /proc/$pid/stat
newtime=$((utime+stime))
if (( newtime - lasttime > 1 )); then
gcore $pid
fi
lasttime=$newtime
done
This one has the benefit of being extensible to handle whatever metric you want, or execute whatever command you want, change the polling period...
- WalterGR 8y agoWhere are the command line arguments other than the pid? Where are the tests? This one has the benefit of being extensible to handle whatever metric you want, or execute whatever command you want, change the polling period... Yeah, you also have to edit it every time you want to use it. It’s a chunk of shell script, not a reusable tool.
- SmellyGeekBoy 8y agoIs htop very "Windows" as well?